@matheusbsbs / matheus-bagliano / commits / 9e4b7ab652
Fork 0

git status: not "commit --dry-run" anymore

This removes tentative "git stat" and make it take over "git status". There are some tests that expect "git status" to exit with non-zero status when there is something staged. Some tests expect "git status path..." to show the status for a partial commit. For these, replace "git status" with "git commit --dry-run". For the ones that do not attempt a dry-run of a partial commit that check the output from the command, check the output from "git status" as well, as they should be identical. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Aug 15, 2009 at 02:27 UTC 9e4b7ab652561e1807702fe5288e04b8873fc437
9 files changed +89 -50
Documentation/git-status.txt
+69 -10
@@ -8,7 +8,7 @@ git-status - Show the working tree status
8
9 SYNOPSIS
10 --------
11 -'git status' <options>...
11 +'git status' [<options>...] [--] [<pathspec>...]
12
13 DESCRIPTION
14 -----------
@@ -20,25 +20,85 @@ are what you _would_ commit by running `git commit`; the second and
20 third are what you _could_ commit by running 'git-add' before running
21 `git commit`.
22
23 -The command takes the same set of options as 'git-commit'; it
24 -shows what would be committed if the same options are given to
25 -'git-commit'.
26 -
27 -If there is no path that is different between the index file and
28 -the current HEAD commit (i.e., there is nothing to commit by running
29 -`git commit`), the command exits with non-zero status.
23 +OPTIONS
24 +-------
25 +
26 +-s::
27 +--short::
28 + Give the output in the short-format.
29 +
30 +-u[<mode>]::
31 +--untracked-files[=<mode>]::
32 + Show untracked files (Default: 'all').
33 ++
34 +The mode parameter is optional, and is used to specify
35 +the handling of untracked files. The possible options are:
36 ++
37 +--
38 + - 'no' - Show no untracked files
39 + - 'normal' - Shows untracked files and directories
40 + - 'all' - Also shows individual files in untracked directories.
41 +--
42 ++
43 +See linkgit:git-config[1] for configuration variable
44 +used to change the default for when the option is not
45 +specified.
46 +
47 +-z::
48 + Terminate entries with NUL, instead of LF. This implies `-s`
49 + (short status) output format.
50
51
52 OUTPUT
53 ------
54 The output from this command is designed to be used as a commit
55 template comment, and all the output lines are prefixed with '#'.
56 +The default, long format, is designed to be human readable,
57 +verbose and descriptive. They are subject to change in any time.
58
59 The paths mentioned in the output, unlike many other git commands, are
60 made relative to the current directory if you are working in a
61 subdirectory (this is on purpose, to help cutting and pasting). See
62 the status.relativePaths config option below.
63
64 +In short-format, the status of each path is shown as
65 +
66 + XY PATH1 -> PATH2
67 +
68 +where `PATH1` is the path in the `HEAD`, and ` -> PATH2` part is
69 +shown only when `PATH1` corresponds to a different path in the
70 +index/worktree (i.e. renamed).
71 +
72 +For unmerged entries, `X` shows the status of stage #2 (i.e. ours) and `Y`
73 +shows the status of stage #3 (i.e. theirs).
74 +
75 +For entries that do not have conflicts, `X` shows the status of the index,
76 +and `Y` shows the status of the work tree. For untracked paths, `XY` are
77 +`??`.
78 +
79 + X Y Meaning
80 + -------------------------------------------------
81 + [MD] not updated
82 + M [ MD] updated in index
83 + A [ MD] added to index
84 + D [ MD] deleted from index
85 + R [ MD] renamed in index
86 + C [ MD] copied in index
87 + [MARC] index and work tree matches
88 + [ MARC] M work tree changed since index
89 + [ MARC] D deleted in work tree
90 + -------------------------------------------------
91 + D D unmerged, both deleted
92 + A U unmerged, added by us
93 + U D unmerged, deleted by them
94 + U A unmerged, added by them
95 + D U unmerged, deleted by us
96 + A A unmerged, both added
97 + U U unmerged, both modified
98 + -------------------------------------------------
99 + ? ? untracked
100 + -------------------------------------------------
101 +
102
103 CONFIGURATION
104 -------------
@@ -63,8 +123,7 @@ linkgit:gitignore[5]
123
124 Author
125 ------
66 -Written by Linus Torvalds <torvalds@osdl.org> and
67 -Junio C Hamano <gitster@pobox.com>.
126 +Written by Junio C Hamano <gitster@pobox.com>.
127
128 Documentation
129 --------------
Makefile
-1
@@ -378,7 +378,6 @@ BUILT_INS += git-init$X
378 BUILT_INS += git-merge-subtree$X
379 BUILT_INS += git-peek-remote$X
380 BUILT_INS += git-repo-config$X
381 -BUILT_INS += git-stat$X
381 BUILT_INS += git-show$X
382 BUILT_INS += git-stage$X
383 BUILT_INS += git-status$X
builtin-commit.c
+4 -25
@@ -36,11 +36,6 @@ static const char * const builtin_status_usage[] = {
36 NULL
37 };
38
39 -static const char * const builtin_stat_usage[] = {
40 - "git stat [options]",
41 - NULL
42 -};
43 -
39 static unsigned char head_sha1[20], merge_head_sha1[20];
40 static char *use_message_buffer;
41 static const char commit_editmsg[] = "COMMIT_EDITMSG";
@@ -971,13 +966,13 @@ static void short_untracked(int null_termination, struct string_list_item *it,
966 }
967 }
968
974 -int cmd_stat(int argc, const char **argv, const char *prefix)
969 +int cmd_status(int argc, const char **argv, const char *prefix)
970 {
971 struct wt_status s;
972 static int null_termination, shortstatus;
973 int i;
974 unsigned char sha1[20];
980 - static struct option builtin_stat_options[] = {
975 + static struct option builtin_status_options[] = {
976 OPT__VERBOSE(&verbose),
977 OPT_BOOLEAN('s', "short", &shortstatus,
978 "show status concicely"),
@@ -996,8 +991,8 @@ int cmd_stat(int argc, const char **argv, const char *prefix)
991 wt_status_prepare(&s);
992 git_config(git_status_config, &s);
993 argc = parse_options(argc, argv, prefix,
999 - builtin_stat_options,
1000 - builtin_stat_usage, 0);
994 + builtin_status_options,
995 + builtin_status_usage, 0);
996 handle_untracked_files_arg(&s);
997
998 if (*argv)
@@ -1039,22 +1034,6 @@ int cmd_stat(int argc, const char **argv, const char *prefix)
1034 return 0;
1035 }
1036
1042 -int cmd_status(int argc, const char **argv, const char *prefix)
1043 -{
1044 - struct wt_status s;
1045 -
1046 - wt_status_prepare(&s);
1047 - git_config(git_status_config, &s);
1048 - if (s.use_color == -1)
1049 - s.use_color = git_use_color_default;
1050 - if (diff_use_color_default == -1)
1051 - diff_use_color_default = git_use_color_default;
1052 -
1053 - argc = parse_and_validate_options(argc, argv, builtin_status_usage,
1054 - prefix, &s);
1055 - return dry_run_commit(argc, argv, prefix, &s);
1056 -}
1057 -
1037 static void print_summary(const char *prefix, const unsigned char *sha1)
1038 {
1039 struct rev_info rev;
builtin.h
-1
@@ -95,7 +95,6 @@ extern int cmd_send_pack(int argc, const char **argv, const char *prefix);
95 extern int cmd_shortlog(int argc, const char **argv, const char *prefix);
96 extern int cmd_show(int argc, const char **argv, const char *prefix);
97 extern int cmd_show_branch(int argc, const char **argv, const char *prefix);
98 -extern int cmd_stat(int argc, const char **argv, const char *prefix);
98 extern int cmd_status(int argc, const char **argv, const char *prefix);
99 extern int cmd_stripspace(int argc, const char **argv, const char *prefix);
100 extern int cmd_symbolic_ref(int argc, const char **argv, const char *prefix);
git.c
-1
@@ -350,7 +350,6 @@ static void handle_internal_command(int argc, const char **argv)
350 { "shortlog", cmd_shortlog, USE_PAGER },
351 { "show-branch", cmd_show_branch, RUN_SETUP },
352 { "show", cmd_show, RUN_SETUP | USE_PAGER },
353 - { "stat", cmd_stat, RUN_SETUP | NEED_WORK_TREE },
353 { "status", cmd_status, RUN_SETUP | NEED_WORK_TREE },
354 { "stripspace", cmd_stripspace },
355 { "symbolic-ref", cmd_symbolic_ref, RUN_SETUP },
t/t6040-tracking-info.sh
+1 -1
@@ -69,7 +69,7 @@ test_expect_success 'status' '
69 cd test &&
70 git checkout b1 >/dev/null &&
71 # reports nothing to commit
72 - test_must_fail git status
72 + test_must_fail git commit --dry-run
73 ) >actual &&
74 grep "have 1 and 1 different" actual
75 '
t/t7060-wtstatus.sh
+5 -3
@@ -50,9 +50,11 @@ test_expect_success 'M/D conflict does not segfault' '
50 git rm foo &&
51 git commit -m delete &&
52 test_must_fail git merge master &&
53 - test_must_fail git status > ../actual
54 - ) &&
55 - test_cmp expect actual
53 + test_must_fail git commit --dry-run >../actual &&
54 + test_cmp ../expect ../actual &&
55 + git status >../actual &&
56 + test_cmp ../expect ../actual
57 + )
58 '
59
60 test_done
t/t7506-status-submodule.sh
+3 -3
@@ -19,8 +19,8 @@ test_expect_success 'status clean' '
19 git status |
20 grep "nothing to commit"
21 '
22 -test_expect_success 'status -a clean' '
23 - git status -a |
22 +test_expect_success 'commit --dry-run -a clean' '
23 + git commit --dry-run -a |
24 grep "nothing to commit"
25 '
26 test_expect_success 'rm submodule contents' '
@@ -31,7 +31,7 @@ test_expect_success 'status clean (empty submodule dir)' '
31 grep "nothing to commit"
32 '
33 test_expect_success 'status -a clean (empty submodule dir)' '
34 - git status -a |
34 + git commit --dry-run -a |
35 grep "nothing to commit"
36 '
37
t/t7508-status.sh
+7 -5
@@ -248,8 +248,8 @@ cat <<EOF >expect
248 # output
249 # untracked
250 EOF
251 -test_expect_success 'status of partial commit excluding new file in index' '
252 - git status dir1/modified >output &&
251 +test_expect_success 'dry-run of partial commit excluding new file in index' '
252 + git commit --dry-run dir1/modified >output &&
253 test_cmp expect output
254 '
255
@@ -358,7 +358,9 @@ EOF
358 test_expect_success 'status submodule summary (clean submodule)' '
359 git commit -m "commit submodule" &&
360 git config status.submodulesummary 10 &&
361 - test_must_fail git status >output &&
361 + test_must_fail git commit --dry-run >output &&
362 + test_cmp expect output &&
363 + git status >output &&
364 test_cmp expect output
365 '
366
@@ -391,9 +393,9 @@ cat >expect <<EOF
393 # output
394 # untracked
395 EOF
394 -test_expect_success 'status submodule summary (--amend)' '
396 +test_expect_success 'commit --dry-run submodule summary (--amend)' '
397 git config status.submodulesummary 10 &&
396 - git status --amend >output &&
398 + git commit --dry-run --amend >output &&
399 test_cmp expect output
400 '
401