"git status" that is not "git commit --dry-run"
Subsystems (2)
cover "git status" that is not "git commit --dry-run"
Here is an update relative to 7637868 (wt-status: collect untracked files in a separate "collect" phase, 2009-08-10) that has been queued in 'next'.
[PATCH 1/9] and [PATCH 2/9] are the same from last night's fixes.
[PATCH 3/9] through [PATCH 6/9] introduce a new "git status" with different semantics for 1.7.0 under a tentative name "git stat". They will be squashed into one commit in the final round, as 4, 5, and 6 are fix-ups, but are keft separate for easier review.
The new "git status" handles paths differently from the traditional one. It used to be the preview of "git commit paths...", IOW, "show what would happen if we try to make a partial commit of only these paths". The new "git status" only limits the paths the output talks about and is not a preview of anything at all anymore.
Another semantic change is that its exit status no longer says if there is something to be committed in the index. We used to exit with non-zero status if there is nothing to commit.
[PATCH 7/9] introduces a short format output.
The last two patches make the new "git status" official. They will be squashed together into one commit in the final round, but are kept separate for reviewability.
Junio C Hamano (9):
Documentation/git-commit.txt: describe --dry-run
git commit --dry-run -v: show diff in color when asked git stat: the beginning
git stat: honor relative paths setting
git stat: show traditional status headers and trailers as well git stat: pathspec limits, unlike traditional "git status" git stat -s: short status output
git status: not "commit --dry-run" anymore
git-status: adjust tests
Documentation/git-commit.txt | 13 ++- Documentation/git-status.txt | 79 +++++++++++++++++--- Makefile | 1 + builtin-commit.c | 172 +++++++++++++++++++++++++++++++++++++----- t/t6040-tracking-info.sh | 2 +- t/t7060-wtstatus.sh | 8 +- t/t7506-status-submodule.sh | 6 +- t/t7508-status.sh | 12 ++- wt-status.c | 10 ++- wt-status.h | 1 + 10 files changed, 255 insertions(+), 49 deletions(-)
PATCH 1/9 Documentation/git-commit.txt: describe --dry-run
---
* Unchanged since the last round.
Documentation/git-commit.txt | 13 +++++++++---- 1 files changed, 9 insertions(+), 4 deletions(-)
Documentation/git-commit.txt +9 -4
@@ -9,7 +9,7 @@ SYNOPSIS -------- [verse] 'git commit' [-a | --interactive] [-s] [-v] [-u<mode>] [--amend] [--dry-run] - [(-c | -C) <commit>] [-F <file> | -m <msg>] + [(-c | -C) <commit>] [-F <file> | -m <msg>] [--dry-run] [--allow-empty] [--no-verify] [-e] [--author=<author>] [--cleanup=<mode>] [--] [[-i | -o ]<file>...]
@@ -42,10 +42,9 @@ The content to be added can be specified in several ways: by one which files should be part of the commit, before finalizing the operation. Currently, this is done by invoking 'git-add --interactive'. -The 'git-status' command can be used to obtain a +The `--dry-run` option can be used to obtain a summary of what is included by any of the above for the next -commit by giving the same set of parameters you would give to -this command. +commit by giving the same set of parameters (options and paths). If you make a commit and then find a mistake immediately after that, you can recover from it with 'git-reset'.
@@ -70,6 +69,12 @@ OPTIONS Like '-C', but with '-c' the editor is invoked, so that the user can further edit the commit message. +--dry-run:: + Do not actually make a commit, but show the list of paths + with updates in the index, paths with changes in the work tree, + and paths that are untracked, similar to the one that is given + in the commit log editor. + -F <file>:: --file=<file>:: Take the commit message from the given file. Use '-' to
Signature · 1 line
1.6.4.224.g3be84
PATCH 2/9 git commit --dry-run -v: show diff in color when asked
The earlier implementation of --dry-run didn't duplicate the use of color "git status -v" set up for diff output.
---
* Unchanged since the last round.
builtin-commit.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-)
builtin-commit.c +4 -2
@@ -979,9 +979,11 @@ int cmd_commit(int argc, const char **argv, const char *prefix) argc =parse_and_validate_options (argc, argv, builtin_commit_usage, prefix, &s); -if (dry_run) +if (dry_run) { +if (diff_use_color_default ==-1 ) + diff_use_color_default = git_use_color_default;return dry_run_commit (argc, argv, prefix, &s); - + } index_file =prepare_index (argc, argv, prefix,0 );/* Set up everything for writing the commit object. This includes
Signature · 1 line
1.6.4.224.g3be84
PATCH 3/9 git stat: the beginning
Tentatively add "git stat" as a new command. This does not munge the index with paths parameters before showing the status like "git status" does. In later rounds, we will take path parameters as pathspec to limit the output.
---
* Unchanged since the last round.
Makefile | 1 + builtin-commit.c | 64 +++++++++++++++++++++++++++++++++++++++++++++-------- builtin.h | 1 + git.c | 1 + wt-status.c | 23 +++++++++++------- wt-status.h | 1 + 6 files changed, 72 insertions(+), 19 deletions(-)
Makefile +1 -0
@@ -378,6 +378,7 @@ BUILT_INS += git-init$X BUILT_INS += git-merge-subtree$X BUILT_INS += git-peek-remote$X BUILT_INS += git-repo-config$X +BUILT_INS += git-stat$X BUILT_INS += git-show$X BUILT_INS += git-stage$X BUILT_INS += git-status$X
builtin-commit.c +54 -10
94 lines not on this page · raw message
builtin.h +1 -0
@@ -95,6 +95,7 @@ extern int cmd_send_pack(int argc, const char **argv, const char *prefix);extern int cmd_shortlog (int argc,const char **argv,const char *prefix);extern int cmd_show (int argc,const char **argv,const char *prefix);extern int cmd_show_branch (int argc,const char **argv,const char *prefix); +extern int cmd_stat (int argc,const char **argv,const char *prefix);extern int cmd_status (int argc,const char **argv,const char *prefix);extern int cmd_stripspace (int argc,const char **argv,const char *prefix);extern int cmd_symbolic_ref (int argc,const char **argv,const char *prefix);
git.c +1 -0
@@ -350,6 +350,7 @@ static void handle_internal_command(int argc, const char **argv) { "shortlog", cmd_shortlog, USE_PAGER }, { "show-branch", cmd_show_branch, RUN_SETUP }, { "show", cmd_show, RUN_SETUP | USE_PAGER }, + { "stat", cmd_stat, RUN_SETUP | NEED_WORK_TREE }, { "status", cmd_status, RUN_SETUP | NEED_WORK_TREE }, { "stripspace", cmd_stripspace }, { "symbolic-ref", cmd_symbolic_ref, RUN_SETUP },
wt-status.c +14 -9
@@ -531,6 +531,19 @@ static void wt_status_print_tracking(struct wt_status *s)color_fprintf_ln (s->fp,color (WT_STATUS_HEADER , s),"#" ); } +void wt_status_print_body (struct wt_status *s) +{ +wt_status_print_unmerged (s); +wt_status_print_updated (s); +wt_status_print_changed (s); +if (s->submodule_summary) +wt_status_print_submodule_summary (s); +if (s->show_untracked_files) +wt_status_print_untracked (s); +else if (s->commitable) +fprintf (s->fp,"# Untracked files not listed (use -u option to show untracked files)\n" ); +} +void wt_status_print (struct wt_status *s) {unsigned char sha1[20 ];
@@ -561,15 +574,7 @@ void wt_status_print(struct wt_status *s)color_fprintf_ln (s->fp,color (WT_STATUS_HEADER , s),"#" ); } -wt_status_print_unmerged (s); -wt_status_print_updated (s); -wt_status_print_changed (s); -if (s->submodule_summary) -wt_status_print_submodule_summary (s); -if (s->show_untracked_files) -wt_status_print_untracked (s); -else if (s->commitable) -fprintf (s->fp,"# Untracked files not listed (use -u option to show untracked files)\n" ); +wt_status_print_body (s);if (s->verbose)wt_status_print_verbose (s);
wt-status.h +1 -0
@@ -54,5 +54,6 @@ struct wt_status {void wt_status_prepare (struct wt_status *s);void wt_status_print (struct wt_status *s);void wt_status_collect (struct wt_status *s); +void wt_status_print_body (struct wt_status *s);#endif /* STATUS_H */
Signature · 1 line
1.6.4.224.g3be84
PATCH 4/9 git stat: honor relative paths setting
When run from a subdirectory, by default (and when status.relativepaths is set), we should pass it to wt_status_print_body()
---
* Fix-up to 3/9; will be squashed in the final round.
builtin-commit.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
builtin-commit.c +2 -0
@@ -922,6 +922,8 @@ int cmd_stat(int argc, const char **argv, const char *prefix) s.is_initial =get_sha1 (s.reference, sha1) ?1 :0 ;wt_status_collect (&s); +if (s.relative_paths) + s.prefix = prefix;if (s.use_color ==-1 ) s.use_color = git_use_color_default;if (diff_use_color_default ==-1 )
Signature · 1 line
1.6.4.224.g3be84
PATCH 5/9 git stat: show traditional status headers and trailers as well
Also honor -v to show the "diff --cached" output.
---
* Fix-up to 3/9; will be squashed in the final round to remove the trace of ill conceived wt_status_print_body() refactoring.
builtin-commit.c | 8 +++++++- wt-status.c | 27 +++++++++------------------ wt-status.h | 1 - 3 files changed, 16 insertions(+), 20 deletions(-)
builtin-commit.c +7 -1
@@ -352,6 +352,8 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, intstatic int run_status (FILE *fp,const char *index_file,const char *prefix,int nowarn,struct wt_status *s) { +unsigned char sha1[20 ]; +if (s->relative_paths) s->prefix = prefix;
@@ -363,7 +365,9 @@ static int run_status(FILE *fp, const char *index_file, const char *prefix, int s->index_file = index_file; s->fp = fp; s->nowarn = nowarn; + s->is_initial =get_sha1 (s->reference, sha1) ?1 :0 ; +wt_status_collect (s);wt_status_print (s);return s->commitable;
@@ -903,6 +907,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix)struct wt_status s;unsigned char sha1[20 ];static struct option builtin_stat_options[] = { +OPT__VERBOSE (&verbose), {OPTION_STRING ,'u' ,"untracked-files" , &untracked_files_arg,"mode" ,"show untracked files, optional modes: all, normal, no. (Default: all)" ,
@@ -922,13 +927,14 @@ int cmd_stat(int argc, const char **argv, const char *prefix) s.is_initial =get_sha1 (s.reference, sha1) ?1 :0 ;wt_status_collect (&s); + s.verbose = verbose;if (s.relative_paths) s.prefix = prefix;if (s.use_color ==-1 ) s.use_color = git_use_color_default;if (diff_use_color_default ==-1 ) diff_use_color_default = git_use_color_default; -wt_status_print_body (&s); +wt_status_print (&s);return 0 ; }
wt-status.c +9 -18
@@ -531,25 +531,10 @@ static void wt_status_print_tracking(struct wt_status *s)color_fprintf_ln (s->fp,color (WT_STATUS_HEADER , s),"#" ); } -void wt_status_print_body (struct wt_status *s) -{ -wt_status_print_unmerged (s); -wt_status_print_updated (s); -wt_status_print_changed (s); -if (s->submodule_summary) -wt_status_print_submodule_summary (s); -if (s->show_untracked_files) -wt_status_print_untracked (s); -else if (s->commitable) -fprintf (s->fp,"# Untracked files not listed (use -u option to show untracked files)\n" ); -} -void wt_status_print (struct wt_status *s) { -unsigned char sha1[20 ];const char *branch_color =color (WT_STATUS_HEADER , s); - s->is_initial =get_sha1 (s->reference, sha1) ?1 :0 ;if (s->branch) {const char *on_what ="On branch " ;const char *branch_name = s->branch;
@@ -566,15 +551,21 @@ void wt_status_print(struct wt_status *s)wt_status_print_tracking (s); } -wt_status_collect (s); -if (s->is_initial) {color_fprintf_ln (s->fp,color (WT_STATUS_HEADER , s),"#" );color_fprintf_ln (s->fp,color (WT_STATUS_HEADER , s),"# Initial commit" );color_fprintf_ln (s->fp,color (WT_STATUS_HEADER , s),"#" ); } -wt_status_print_body (s); +wt_status_print_unmerged (s); +wt_status_print_updated (s); +wt_status_print_changed (s); +if (s->submodule_summary) +wt_status_print_submodule_summary (s); +if (s->show_untracked_files) +wt_status_print_untracked (s); +else if (s->commitable) +fprintf (s->fp,"# Untracked files not listed (use -u option to show untracked files)\n" );if (s->verbose)wt_status_print_verbose (s);
wt-status.h +0 -1
@@ -54,6 +54,5 @@ struct wt_status {void wt_status_prepare (struct wt_status *s);void wt_status_print (struct wt_status *s);void wt_status_collect (struct wt_status *s); -void wt_status_print_body (struct wt_status *s);#endif /* STATUS_H */
Signature · 1 line
1.6.4.224.g3be84
PATCH 6/9 git stat: pathspec limits, unlike traditional "git status"
The "git stat" command is not "preview of commit with the same arguments"; the path parameters are not paths to be added to the pristine index (aka "--only" option), but are taken as pathspecs to limit the output.
---
* Fix-up to 3/9; will be squashed in the final round.
builtin-commit.c | 3 +++ wt-status.c | 6 ++++++ wt-status.h | 1 + 3 files changed, 10 insertions(+), 0 deletions(-)
builtin-commit.c +3 -0
@@ -922,6 +922,9 @@ int cmd_stat(int argc, const char **argv, const char *prefix) builtin_stat_usage, 0);handle_untracked_files_arg (&s); +if (*argv) + s.pathspec =get_pathspec (prefix, argv); +read_cache ();refresh_cache (REFRESH_QUIET |REFRESH_UNMERGED ); s.is_initial =get_sha1 (s.reference, sha1) ?1 :0 ;
wt-status.c +6 -0
@@ -269,6 +269,7 @@ static void wt_status_collect_changes_worktree(struct wt_status *s) rev.diffopt.output_format |=DIFF_FORMAT_CALLBACK ; rev.diffopt.format_callback = wt_status_collect_changed_cb; rev.diffopt.format_callback_data = s; + rev.prune_data = s->pathspec;run_diff_files (&rev,0 ); }
@@ -285,6 +286,7 @@ static void wt_status_collect_changes_index(struct wt_status *s) rev.diffopt.detect_rename =1 ; rev.diffopt.rename_limit =200 ; rev.diffopt.break_opt =0 ; + rev.prune_data = s->pathspec;run_diff_index (&rev,1 ); }
@@ -297,6 +299,8 @@ static void wt_status_collect_changes_initial(struct wt_status *s)struct wt_status_change_data *d;struct cache_entry *ce = active_cache[i]; +if (!ce_path_match (ce, s->pathspec)) +continue ; it =string_list_insert (ce->name, &s->change); d = it->util;if (!d) {
@@ -330,6 +334,8 @@ static void wt_status_collect_untracked(struct wt_status *s)struct dir_entry *ent = dir.entries[i];if (!cache_name_is_other (ent->name, ent->len))continue ; +if (!match_pathspec (s->pathspec, ent->name, ent->len,0 ,NULL )) +continue ; s->workdir_untracked =1 ;string_list_insert (ent->name, &s->untracked); }
wt-status.h +1 -0
@@ -31,6 +31,7 @@ struct wt_status {int is_initial;char *branch;const char *reference; +const char **pathspec;int verbose;int amend;int nowarn;
Signature · 1 line
1.6.4.224.g3be84
PATCH 7/9 git stat -s: short status output
Give -s(hort) option to "git stat" that shows the status of paths in a more concise way.
XY PATH1 -> PATH2
format to be more machine readable than output from "git status", which is about previewing of "git commit" with the same arguments.
PATH1 is the path in the HEAD, and " -> PATH2" part is shown only when PATH1 corresponds to a different path in the index/worktree.
For unmerged entries, X shows the status of stage #2 (i.e. ours) and Y shows the status of stage #3 (i.e. theirs). For entries that do not have conflicts, X shows the status of the index, and Y shows the status of the work tree. For untracked paths, XY are "??".
X Y Meaning
-------------------------------------------------
[MD] not updated
M [ MD] updated in index
A [ MD] added to index
D [ MD] deleted from index
R [ MD] renamed in index
C [ MD] copied in index
[MARC] index and work tree matches
[ MARC] M work tree changed since index
[ MARC] D deleted in work tree
D D unmerged, both deleted
A U unmerged, added by us
U D unmerged, deleted by them
U A unmerged, added by them
D U unmerged, deleted by us
A A unmerged, both added
U U unmerged, both modified
? ? untracked
When given -z option, the records are terminated by NUL characters for better machine readability. Because the traditional long format is designed for human consumption, NUL termination does not make sense. For this reason, -z option implies -s (short output).
---
* Unchanged since the last round; rebased on top of the updated code to support the long format output.
builtin-commit.c | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 106 insertions(+), 8 deletions(-)
builtin-commit.c +106 -8
@@ -902,12 +902,87 @@ static int git_status_config(const char *k, const char *v, void *cb)return git_diff_ui_config (k, v,NULL ); } +#define quote_path quote_path_relative + +static void short_unmerged (int null_termination,struct string_list_item *it, +struct wt_status *s) +{ +struct wt_status_change_data *d = it->util; +const char *how ="??" ; + +switch (d->stagemask) { +case 1 : how ="DD" ;break ;/* both deleted */ +case 2 : how ="AU" ;break ;/* added by us */ +case 3 : how ="UD" ;break ;/* deleted by them */ +case 4 : how ="UA" ;break ;/* added by them */ +case 5 : how ="DU" ;break ;/* deleted by us */ +case 6 : how ="AA" ;break ;/* both added */ +case 7 : how ="UU" ;break ;/* both modified */ + } +printf ("%s " , how); +if (null_termination) { +fprintf (stdout,"%s%c" , it->string,0 ); + }else { +struct strbuf onebuf =STRBUF_INIT ; +const char *one; + one =quote_path (it->string,-1 , &onebuf, s->prefix); +printf ("%s\n" , one); +strbuf_release (&onebuf); + } +} + +static void short_status (int null_termination,struct string_list_item *it, +struct wt_status *s) +{ +struct wt_status_change_data *d = it->util; + +printf ("%c%c " , + !d->index_status ?' ' : d->index_status, + !d->worktree_status ?' ' : d->worktree_status); +if (null_termination) { +fprintf (stdout,"%s%c" , it->string,0 ); +if (d->head_path) +fprintf (stdout,"%s%c" , d->head_path,0 ); + }else { +struct strbuf onebuf =STRBUF_INIT ; +const char *one; +if (d->head_path) { + one =quote_path (d->head_path,-1 , &onebuf, s->prefix); +printf ("%s -> " , one); +strbuf_release (&onebuf); + } + one =quote_path (it->string,-1 , &onebuf, s->prefix); +printf ("%s\n" , one); +strbuf_release (&onebuf); + } +} + +static void short_untracked (int null_termination,struct string_list_item *it, +struct wt_status *s) +{ +if (null_termination) { +fprintf (stdout,"?? %s%c" , it->string,0 ); + }else { +struct strbuf onebuf =STRBUF_INIT ; +const char *one; + one =quote_path (it->string,-1 , &onebuf, s->prefix); +printf ("?? %s\n" , one); +strbuf_release (&onebuf); + } +} +int cmd_stat (int argc,const char **argv,const char *prefix) {struct wt_status s; +static int null_termination, shortstatus; +int i;unsigned char sha1[20 ];static struct option builtin_stat_options[] = {OPT__VERBOSE (&verbose), +OPT_BOOLEAN ('s' ,"short" , &shortstatus, +"show status concicely" ), +OPT_BOOLEAN ('z' ,"null" , &null_termination, +"terminate entries with NUL" ), {OPTION_STRING ,'u' ,"untracked-files" , &untracked_files_arg,"mode" ,"show untracked files, optional modes: all, normal, no. (Default: all)" ,
@@ -915,6 +990,9 @@ int cmd_stat(int argc, const char **argv, const char *prefix) OPT_END(), }; +if (null_termination) + shortstatus =1 ; +wt_status_prepare (&s);git_config (git_status_config, &s); argc = parse_options(argc, argv, prefix,
@@ -930,14 +1008,34 @@ int cmd_stat(int argc, const char **argv, const char *prefix) s.is_initial =get_sha1 (s.reference, sha1) ?1 :0 ;wt_status_collect (&s); - s.verbose = verbose; -if (s.relative_paths) - s.prefix = prefix; -if (s.use_color ==-1 ) - s.use_color = git_use_color_default; -if (diff_use_color_default ==-1 ) - diff_use_color_default = git_use_color_default; -wt_status_print (&s); +if (shortstatus) { +for (i =0 ; i < s.change.nr; i++) { +struct wt_status_change_data *d; +struct string_list_item *it; + + it = &(s.change.items[i]); + d = it->util; +if (d->stagemask) +short_unmerged (null_termination, it, &s); +else +short_status (null_termination, it, &s); + } +for (i =0 ; i < s.untracked.nr; i++) { +struct string_list_item *it; + + it = &(s.untracked.items[i]); +short_untracked (null_termination, it, &s); + } + }else { + s.verbose = verbose; +if (s.relative_paths) + s.prefix = prefix; +if (s.use_color ==-1 ) + s.use_color = git_use_color_default; +if (diff_use_color_default ==-1 ) + diff_use_color_default = git_use_color_default; +wt_status_print (&s); + }return 0 ; }
Signature · 1 line
1.6.4.224.g3be84
PATCH 8/9 git status: not "commit --dry-run" anymore
This removes tentative "git stat" and make it take over "git status".
---
* This alone fails some tests; 9/9 will be squashed in in the final round.
Documentation/git-status.txt | 79 ++++++++++++++++++++++++++++++++++++----- builtin-commit.c | 29 ++------------- builtin.h | 1 - git.c | 1 - 4 files changed, 73 insertions(+), 37 deletions(-)
Documentation/git-status.txt +69 -10
@@ -8,7 +8,7 @@ git-status - Show the working tree status SYNOPSIS -------- -'git status' <options>... +'git status' [<options>...] [--] [<pathspec>...] DESCRIPTION -----------
@@ -20,25 +20,85 @@ are what you _would_ commit by running `git commit`; the second and third are what you _could_ commit by running 'git-add' before running `git commit`. -The command takes the same set of options as 'git-commit'; it -shows what would be committed if the same options are given to -'git-commit'. - -If there is no path that is different between the index file and -the current HEAD commit (i.e., there is nothing to commit by running -`git commit`), the command exits with non-zero status. +OPTIONS +------- + +-s:: +--short:: + Give the output in the short-format. + +-u[<mode>]:: +--untracked-files[=<mode>]:: + Show untracked files (Default: 'all'). ++ +The mode parameter is optional, and is used to specify +the handling of untracked files. The possible options are: ++ +-- + - 'no' - Show no untracked files + - 'normal' - Shows untracked files and directories + - 'all' - Also shows individual files in untracked directories. +-- ++ +See linkgit:git-config[1] for configuration variable +used to change the default for when the option is not +specified. + +-z:: + Terminate entries with NUL, instead of LF. This implies `-s` + (short status) output format. OUTPUT ------ The output from this command is designed to be used as a commit template comment, and all the output lines are prefixed with '#'. +The default, long format, is designed to be human readable, +verbose and descriptive. They are subject to change in any time. The paths mentioned in the output, unlike many other git commands, are made relative to the current directory if you are working in a subdirectory (this is on purpose, to help cutting and pasting). See the status.relativePaths config option below. +In short-format, the status of each path is shown as + + XY PATH1 -> PATH2 + +where `PATH1` is the path in the `HEAD`, and ` -> PATH2` part is +shown only when `PATH1` corresponds to a different path in the +index/worktree (i.e. renamed). + +For unmerged entries, `X` shows the status of stage #2 (i.e. ours) and `Y` +shows the status of stage #3 (i.e. theirs). + +For entries that do not have conflicts, `X` shows the status of the index, +and `Y` shows the status of the work tree. For untracked paths, `XY` are +`??`. + + X Y Meaning + ------------------------------------------------- + [MD] not updated + M [ MD] updated in index + A [ MD] added to index + D [ MD] deleted from index + R [ MD] renamed in index + C [ MD] copied in index + [MARC] index and work tree matches + [ MARC] M work tree changed since index + [ MARC] D deleted in work tree + ------------------------------------------------- + D D unmerged, both deleted + A U unmerged, added by us + U D unmerged, deleted by them + U A unmerged, added by them + D U unmerged, deleted by us + A A unmerged, both added + U U unmerged, both modified + ------------------------------------------------- + ? ? untracked + ------------------------------------------------- + CONFIGURATION -------------
@@ -63,8 +123,7 @@ linkgit:gitignore[5] Author ------ -Written by Linus Torvalds <[email protected]> and -Junio C Hamano <[email protected]>. +Written by Junio C Hamano <[email protected]>. Documentation --------------
builtin-commit.c +4 -25
@@ -36,11 +36,6 @@ static const char * const builtin_status_usage[] = { NULL }; -static const char *const builtin_stat_usage[] = { -"git stat [options]" , -NULL -}; -static unsigned char head_sha1[20 ], merge_head_sha1[20 ];static char *use_message_buffer;static const char commit_editmsg[] ="COMMIT_EDITMSG" ;
@@ -971,13 +966,13 @@ static void short_untracked(int null_termination, struct string_list_item *it, } } -int cmd_stat (int argc,const char **argv,const char *prefix) +int cmd_status (int argc,const char **argv,const char *prefix) {struct wt_status s;static int null_termination, shortstatus;int i;unsigned char sha1[20 ]; -static struct option builtin_stat_options[] = { +static struct option builtin_status_options[] = {OPT__VERBOSE (&verbose),OPT_BOOLEAN ('s' ,"short" , &shortstatus,"show status concicely" ),
@@ -996,8 +991,8 @@ int cmd_stat(int argc, const char **argv, const char *prefix)wt_status_prepare (&s);git_config (git_status_config, &s); argc =parse_options (argc, argv, prefix, - builtin_stat_options, - builtin_stat_usage,0 ); + builtin_status_options, + builtin_status_usage,0 );handle_untracked_files_arg (&s);if (*argv)
@@ -1039,22 +1034,6 @@ int cmd_stat(int argc, const char **argv, const char *prefix)return 0 ; } -int cmd_status (int argc,const char **argv,const char *prefix) -{ -struct wt_status s; - -wt_status_prepare (&s); -git_config (git_status_config, &s); -if (s.use_color ==-1 ) - s.use_color = git_use_color_default; -if (diff_use_color_default ==-1 ) - diff_use_color_default = git_use_color_default; - - argc =parse_and_validate_options (argc, argv, builtin_status_usage, - prefix, &s); -return dry_run_commit (argc, argv, prefix, &s); -} -static void print_summary (const char *prefix,const unsigned char *sha1) {struct rev_info rev;
builtin.h +0 -1
@@ -95,7 +95,6 @@ extern int cmd_send_pack(int argc, const char **argv, const char *prefix);extern int cmd_shortlog (int argc,const char **argv,const char *prefix);extern int cmd_show (int argc,const char **argv,const char *prefix);extern int cmd_show_branch (int argc,const char **argv,const char *prefix); -extern int cmd_stat (int argc,const char **argv,const char *prefix);extern int cmd_status (int argc,const char **argv,const char *prefix);extern int cmd_stripspace (int argc,const char **argv,const char *prefix);extern int cmd_symbolic_ref (int argc,const char **argv,const char *prefix);
git.c +0 -1
@@ -350,7 +350,6 @@ static void handle_internal_command(int argc, const char **argv) { "shortlog", cmd_shortlog, USE_PAGER }, { "show-branch", cmd_show_branch, RUN_SETUP }, { "show", cmd_show, RUN_SETUP | USE_PAGER }, - { "stat", cmd_stat, RUN_SETUP | NEED_WORK_TREE }, { "status", cmd_status, RUN_SETUP | NEED_WORK_TREE }, { "stripspace", cmd_stripspace }, { "symbolic-ref", cmd_symbolic_ref, RUN_SETUP },
Signature · 1 line
1.6.4.224.g3be84
PATCH 9/9 git-status: adjust tests
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.
---
* Kept separate for easier review; shows the extent of damage from the change in semantics rather well.
t/t6040-tracking-info.sh | 2 +- t/t7060-wtstatus.sh | 8 +++++--- t/t7506-status-submodule.sh | 6 +++--- t/t7508-status.sh | 12 +++++++----- 4 files changed, 16 insertions(+), 12 deletions(-)
t/t6040-tracking-info.sh +1 -1
@@ -69,7 +69,7 @@ test_expect_success 'status' ' cd test && git checkout b1 >/dev/null && # reports nothing to commit - test_must_fail git status + test_must_fail git commit --dry-run ) >actual && grep "have 1 and 1 different" actual '
t/t7060-wtstatus.sh +5 -3
@@ -50,9 +50,11 @@ test_expect_success 'M/D conflict does not segfault' ' git rm foo && git commit -m delete && test_must_fail git merge master && - test_must_fail git status > ../actual - ) && - test_cmp expect actual + test_must_fail git commit --dry-run >../actual && + test_cmp ../expect ../actual && + git status >../actual && + test_cmp ../expect ../actual + ) ' test_done
t/t7506-status-submodule.sh +3 -3
@@ -19,8 +19,8 @@ test_expect_success 'status clean' ' git status | grep "nothing to commit" ' -test_expect_success 'status -a clean' ' - git status -a | +test_expect_success 'commit --dry-run -a clean' ' + git commit --dry-run -a | grep "nothing to commit" ' test_expect_success 'rm submodule contents' '
@@ -31,7 +31,7 @@ test_expect_success 'status clean (empty submodule dir)' ' grep "nothing to commit" ' test_expect_success 'status -a clean (empty submodule dir)' ' - git status -a | + git commit --dry-run -a | grep "nothing to commit" '
t/t7508-status.sh +7 -5
@@ -248,8 +248,8 @@ cat <<EOF >expect # output # untracked EOF -test_expect_success 'status of partial commit excluding new file in index' ' - git status dir1/modified >output && +test_expect_success 'dry-run of partial commit excluding new file in index' ' + git commit --dry-run dir1/modified >output && test_cmp expect output '
@@ -358,7 +358,9 @@ EOF test_expect_success 'status submodule summary (clean submodule)' ' git commit -m "commit submodule" && git config status.submodulesummary 10 && - test_must_fail git status >output && + test_must_fail git commit --dry-run >output && + test_cmp expect output && + git status >output && test_cmp expect output '
@@ -391,9 +393,9 @@ cat >expect <<EOF # output # untracked EOF -test_expect_success 'status submodule summary (--amend)' ' +test_expect_success 'commit --dry-run submodule summary (--amend)' ' git config status.submodulesummary 10 && - git status --amend >output && + git commit --dry-run --amend >output && test_cmp expect output '
Signature · 1 line
1.6.4.224.g3be84
Re: [PATCH 8/9] git status: not "commit --dry-run" anymore
In reply to Junio C HamanoQuoted 12 lines · Junio C Hamano
This removes tentative "git stat" and make it take over "git status".
Signed-off-by Junio C Hamano <[email protected]>---
* This alone fails some tests; 9/9 will be squashed in in the final round.
Documentation/git-status.txt | 79 ++++++++++++++++++++++++++++++++++++----- builtin-commit.c | 29 ++------------- builtin.h | 1 - git.c | 1 - 4 files changed, 73 insertions(+), 37 deletions(-)
[...]
Review
Quoted 2 lines
(quoted diff) +0
-1- { "stat", cmd_stat, RUN_SETUP | NEED_WORK_TREE }, { "status", cmd_status, RUN_SETUP | NEED_WORK_TREE },
This lacks a corresponding update to the Makefile:
Makefile +0 -1
@@ -383,7 +383,6 @@ BUILT_INS += git-init$X BUILT_INS += git-merge-subtree$X BUILT_INS += git-peek-remote$X BUILT_INS += git-repo-config$X -BUILT_INS += git-stat$X BUILT_INS += git-show$X BUILT_INS += git-stage$X BUILT_INS += git-status$X
Signature · 2 lines
Thomas Rast
trast@{inf,student}.ethz.ch