{"thread":{"id":"20603","subject":"[PATCH 0/6] \"git commit --dry-run\" updates","startedAt":"2009-08-15T10:06:37Z","lastAt":"2009-08-17T19:16:25Z","messageCount":10,"participants":["Junio C Hamano","Thomas Rast"],"isPatch":true,"patchVersion":1,"patchTotal":6},"messages":[{"id":"120696","messageId":"1250330803-22171-1-git-send-email-gitster@pobox.com","threadId":"20603","inReplyTo":null,"subject":"[PATCH 0/6] \"git commit --dry-run\" updates","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-08-15T10:06:37Z","receivedAt":"2009-08-15T10:06:37Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"The first patch describes --dry-run option, and stops mentioning the\nequivalence to \"git status\" in the documentation for \"git commit\".\n\nThe second one fixes \"git commit --dry-run -v\", which did not show the\ndiff text in color when asked with the configuration.\n\nThe third and the fourth ones tentatively introduce \"git stat\".  The\nformer is an incomplete implementation that ignores the pathspec, and the\nlatter adds pathspec limiting to it.  In the final form before it goes to\n'next', these two should probably be squashed.\n\nThe fifth one introduces \"git stat -s\" (short output format) that is\ndesigned to be machine readable, especially with -z (NUL termination).\n\nThe sixth one renames \"git stat\" to take over the traditional \"git status\"\nand obviously is a 1.7.0 material.\n\nThe tests still have breakages that future updates to the sixth patch need\nto fix.  t4030 still assumes \"git status\" is \"git commit --dry-run\" and\nexpects it to take \"-v\" to produce diffs, for example.\n"},{"id":"120698","messageId":"1250330803-22171-2-git-send-email-gitster@pobox.com","threadId":"20603","inReplyTo":"1250330803-22171-1-git-send-email-gitster@pobox.com","subject":"[PATCH 1/6] Documentation/git-commit.txt: describe --dry-run","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-08-15T10:06:38Z","receivedAt":"2009-08-15T10:06:38Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Signed-off-by: Junio C Hamano <gitster@pobox.com>\n---\n\n* The --dry-run option is already in 'next', but haven't been described.\n\n Documentation/git-commit.txt |   13 +++++++++----\n 1 files changed, 9 insertions(+), 4 deletions(-)\n\ndiff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt\nindex d01ff5a..64f94cf 100644\n--- a/Documentation/git-commit.txt\n+++ b/Documentation/git-commit.txt\n@@ -9,7 +9,7 @@ SYNOPSIS\n --------\n [verse]\n 'git commit' [-a | --interactive] [-s] [-v] [-u<mode>] [--amend] [--dry-run]\n-\t   [(-c | -C) <commit>] [-F <file> | -m <msg>]\n+\t   [(-c | -C) <commit>] [-F <file> | -m <msg>] [--dry-run]\n \t   [--allow-empty] [--no-verify] [-e] [--author=<author>]\n \t   [--cleanup=<mode>] [--] [[-i | -o ]<file>...]\n \n@@ -42,10 +42,9 @@ The content to be added can be specified in several ways:\n    by one which files should be part of the commit, before finalizing the\n    operation.  Currently, this is done by invoking 'git-add --interactive'.\n \n-The 'git-status' command can be used to obtain a\n+The `--dry-run` option can be used to obtain a\n summary of what is included by any of the above for the next\n-commit by giving the same set of parameters you would give to\n-this command.\n+commit by giving the same set of parameters (options and paths).\n \n If you make a commit and then find a mistake immediately after\n that, you can recover from it with 'git-reset'.\n@@ -70,6 +69,12 @@ OPTIONS\n \tLike '-C', but with '-c' the editor is invoked, so that\n \tthe user can further edit the commit message.\n \n+--dry-run::\n+\tDo not actually make a commit, but show the list of paths\n+\twith updates in the index, paths with changes in the work tree,\n+\tand paths that are untracked, similar to the one that is given\n+\tin the commit log editor.\n+\n -F <file>::\n --file=<file>::\n \tTake the commit message from the given file.  Use '-' to\n-- \n1.6.4.224.g3be84\n"},{"id":"120697","messageId":"1250330803-22171-3-git-send-email-gitster@pobox.com","threadId":"20603","inReplyTo":"1250330803-22171-2-git-send-email-gitster@pobox.com","subject":"[PATCH 2/6] git commit --dry-run -v: show diff in color when asked","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-08-15T10:06:39Z","receivedAt":"2009-08-15T10:06:39Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"The earlier implementation of --dry-run didn't duplicate the use of color\n\"git status -v\" set up for diff output.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n\n* Fixes what is already queued in 'next'.\n\n builtin-commit.c |    6 ++++--\n 1 files changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin-commit.c b/builtin-commit.c\nindex 1c200eb..200ffda 100644\n--- a/builtin-commit.c\n+++ b/builtin-commit.c\n@@ -979,9 +979,11 @@ int cmd_commit(int argc, const char **argv, const char *prefix)\n \n \targc = parse_and_validate_options(argc, argv, builtin_commit_usage,\n \t\t\t\t\t  prefix, &s);\n-\tif (dry_run)\n+\tif (dry_run) {\n+\t\tif (diff_use_color_default == -1)\n+\t\t\tdiff_use_color_default = git_use_color_default;\n \t\treturn dry_run_commit(argc, argv, prefix, &s);\n-\n+\t}\n \tindex_file = prepare_index(argc, argv, prefix, 0);\n \n \t/* Set up everything for writing the commit object.  This includes\n-- \n1.6.4.224.g3be84\n"},{"id":"120702","messageId":"1250330803-22171-4-git-send-email-gitster@pobox.com","threadId":"20603","inReplyTo":"1250330803-22171-3-git-send-email-gitster@pobox.com","subject":"[PATCH 3/6] git stat: the beginning","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-08-15T10:06:40Z","receivedAt":"2009-08-15T10:06:40Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Tentatively add \"git stat\" as a new command.  This does not munge the\nindex with paths parameters before showing the status like \"git status\"\ndoes.  In later rounds, we will take path parameters as pathspec to limit\nthe output.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n\n* The change since the version cooking in 'pu' is that the long format\n  honors the color (both \"status\" colors and \"diff\" colors).\n\n Makefile         |    1 +\n builtin-commit.c |   64 +++++++++++++++++++++++++++++++++++++++++++++--------\n builtin.h        |    1 +\n git.c            |    1 +\n wt-status.c      |   23 +++++++++++-------\n wt-status.h      |    1 +\n 6 files changed, 72 insertions(+), 19 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex daf4296..39dd334 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -378,6 +378,7 @@ BUILT_INS += git-init$X\n BUILT_INS += git-merge-subtree$X\n BUILT_INS += git-peek-remote$X\n BUILT_INS += git-repo-config$X\n+BUILT_INS += git-stat$X\n BUILT_INS += git-show$X\n BUILT_INS += git-stage$X\n BUILT_INS += git-status$X\ndiff --git a/builtin-commit.c b/builtin-commit.c\nindex 200ffda..0ef7c8f 100644\n--- a/builtin-commit.c\n+++ b/builtin-commit.c\n@@ -24,6 +24,7 @@\n #include \"string-list.h\"\n #include \"rerere.h\"\n #include \"unpack-trees.h\"\n+#include \"quote.h\"\n \n static const char * const builtin_commit_usage[] = {\n \t\"git commit [options] [--] <filepattern>...\",\n@@ -35,6 +36,11 @@ static const char * const builtin_status_usage[] = {\n \tNULL\n };\n \n+static const char * const builtin_stat_usage[] = {\n+\t\"git stat [options]\",\n+\tNULL\n+};\n+\n static unsigned char head_sha1[20], merge_head_sha1[20];\n static char *use_message_buffer;\n static const char commit_editmsg[] = \"COMMIT_EDITMSG\";\n@@ -691,6 +697,21 @@ static const char *find_author_by_nickname(const char *name)\n \tdie(\"No existing author found with '%s'\", name);\n }\n \n+\n+static void handle_untracked_files_arg(struct wt_status *s)\n+{\n+\tif (!untracked_files_arg)\n+\t\t; /* default already initialized */\n+\telse if (!strcmp(untracked_files_arg, \"no\"))\n+\t\ts->show_untracked_files = SHOW_NO_UNTRACKED_FILES;\n+\telse if (!strcmp(untracked_files_arg, \"normal\"))\n+\t\ts->show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;\n+\telse if (!strcmp(untracked_files_arg, \"all\"))\n+\t\ts->show_untracked_files = SHOW_ALL_UNTRACKED_FILES;\n+\telse\n+\t\tdie(\"Invalid untracked files mode '%s'\", untracked_files_arg);\n+}\n+\n static int parse_and_validate_options(int argc, const char *argv[],\n \t\t\t\t      const char * const usage[],\n \t\t\t\t      const char *prefix,\n@@ -794,16 +815,7 @@ static int parse_and_validate_options(int argc, const char *argv[],\n \telse\n \t\tdie(\"Invalid cleanup mode %s\", cleanup_arg);\n \n-\tif (!untracked_files_arg)\n-\t\t; /* default already initialized */\n-\telse if (!strcmp(untracked_files_arg, \"no\"))\n-\t\ts->show_untracked_files = SHOW_NO_UNTRACKED_FILES;\n-\telse if (!strcmp(untracked_files_arg, \"normal\"))\n-\t\ts->show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;\n-\telse if (!strcmp(untracked_files_arg, \"all\"))\n-\t\ts->show_untracked_files = SHOW_ALL_UNTRACKED_FILES;\n-\telse\n-\t\tdie(\"Invalid untracked files mode '%s'\", untracked_files_arg);\n+\thandle_untracked_files_arg(s);\n \n \tif (all && argc > 0)\n \t\tdie(\"Paths with -a does not make sense.\");\n@@ -886,6 +898,38 @@ static int git_status_config(const char *k, const char *v, void *cb)\n \treturn git_diff_ui_config(k, v, NULL);\n }\n \n+int cmd_stat(int argc, const char **argv, const char *prefix)\n+{\n+\tstruct wt_status s;\n+\tunsigned char sha1[20];\n+\tstatic struct option builtin_stat_options[] = {\n+\t\t{ OPTION_STRING, 'u', \"untracked-files\", &untracked_files_arg,\n+\t\t  \"mode\",\n+\t\t  \"show untracked files, optional modes: all, normal, no. (Default: all)\",\n+\t\t  PARSE_OPT_OPTARG, NULL, (intptr_t)\"all\" },\n+\t\tOPT_END(),\n+\t};\n+\n+\twt_status_prepare(&s);\n+\tgit_config(git_status_config, &s);\n+\targc = parse_options(argc, argv, prefix,\n+\t\t\t     builtin_stat_options,\n+\t\t\t     builtin_stat_usage, 0);\n+\thandle_untracked_files_arg(&s);\n+\n+\tread_cache();\n+\trefresh_cache(REFRESH_QUIET|REFRESH_UNMERGED);\n+\ts.is_initial = get_sha1(s.reference, sha1) ? 1 : 0;\n+\twt_status_collect(&s);\n+\n+\tif (s.use_color == -1)\n+\t\ts.use_color = git_use_color_default;\n+\tif (diff_use_color_default == -1)\n+\t\tdiff_use_color_default = git_use_color_default;\n+\twt_status_print_body(&s);\n+\treturn 0;\n+}\n+\n int cmd_status(int argc, const char **argv, const char *prefix)\n {\n \tstruct wt_status s;\ndiff --git a/builtin.h b/builtin.h\nindex 20427d2..eeaf0b6 100644\n--- a/builtin.h\n+++ b/builtin.h\n@@ -95,6 +95,7 @@ extern int cmd_send_pack(int argc, const char **argv, const char *prefix);\n extern int cmd_shortlog(int argc, const char **argv, const char *prefix);\n extern int cmd_show(int argc, const char **argv, const char *prefix);\n extern int cmd_show_branch(int argc, const char **argv, const char *prefix);\n+extern int cmd_stat(int argc, const char **argv, const char *prefix);\n extern int cmd_status(int argc, const char **argv, const char *prefix);\n extern int cmd_stripspace(int argc, const char **argv, const char *prefix);\n extern int cmd_symbolic_ref(int argc, const char **argv, const char *prefix);\ndiff --git a/git.c b/git.c\nindex 807d875..de7fcf6 100644\n--- a/git.c\n+++ b/git.c\n@@ -350,6 +350,7 @@ static void handle_internal_command(int argc, const char **argv)\n \t\t{ \"shortlog\", cmd_shortlog, USE_PAGER },\n \t\t{ \"show-branch\", cmd_show_branch, RUN_SETUP },\n \t\t{ \"show\", cmd_show, RUN_SETUP | USE_PAGER },\n+\t\t{ \"stat\", cmd_stat, RUN_SETUP | NEED_WORK_TREE },\n \t\t{ \"status\", cmd_status, RUN_SETUP | NEED_WORK_TREE },\n \t\t{ \"stripspace\", cmd_stripspace },\n \t\t{ \"symbolic-ref\", cmd_symbolic_ref, RUN_SETUP },\ndiff --git a/wt-status.c b/wt-status.c\nindex 63598ce..c887a90 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -531,6 +531,19 @@ static void wt_status_print_tracking(struct wt_status *s)\n \tcolor_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), \"#\");\n }\n \n+void wt_status_print_body(struct wt_status *s)\n+{\n+\twt_status_print_unmerged(s);\n+\twt_status_print_updated(s);\n+\twt_status_print_changed(s);\n+\tif (s->submodule_summary)\n+\t\twt_status_print_submodule_summary(s);\n+\tif (s->show_untracked_files)\n+\t\twt_status_print_untracked(s);\n+\telse if (s->commitable)\n+\t\t fprintf(s->fp, \"# Untracked files not listed (use -u option to show untracked files)\\n\");\n+}\n+\n void wt_status_print(struct wt_status *s)\n {\n \tunsigned char sha1[20];\n@@ -561,15 +574,7 @@ void wt_status_print(struct wt_status *s)\n \t\tcolor_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), \"#\");\n \t}\n \n-\twt_status_print_unmerged(s);\n-\twt_status_print_updated(s);\n-\twt_status_print_changed(s);\n-\tif (s->submodule_summary)\n-\t\twt_status_print_submodule_summary(s);\n-\tif (s->show_untracked_files)\n-\t\twt_status_print_untracked(s);\n-\telse if (s->commitable)\n-\t\t fprintf(s->fp, \"# Untracked files not listed (use -u option to show untracked files)\\n\");\n+\twt_status_print_body(s);\n \n \tif (s->verbose)\n \t\twt_status_print_verbose(s);\ndiff --git a/wt-status.h b/wt-status.h\nindex a0e7517..ab52ce1 100644\n--- a/wt-status.h\n+++ b/wt-status.h\n@@ -54,5 +54,6 @@ struct wt_status {\n void wt_status_prepare(struct wt_status *s);\n void wt_status_print(struct wt_status *s);\n void wt_status_collect(struct wt_status *s);\n+void wt_status_print_body(struct wt_status *s);\n \n #endif /* STATUS_H */\n-- \n1.6.4.224.g3be84\n"},{"id":"120699","messageId":"1250330803-22171-5-git-send-email-gitster@pobox.com","threadId":"20603","inReplyTo":"1250330803-22171-4-git-send-email-gitster@pobox.com","subject":"[PATCH 4/6] git stat: pathspec limits, unlike traditional \"git status\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-08-15T10:06:41Z","receivedAt":"2009-08-15T10:06:41Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"The \"git stat\" command is not \"preview of commit with the same arguments\";\nthe path parameters are not paths to be added to the pristine index (aka\n\"--only\" option), but are taken as pathspecs to limit the output.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n\n* Unchanged since what has been queued in 'pu'.  This should probably be\n  squashed to the previous one in the final form after review.\n\n builtin-commit.c |    3 +++\n wt-status.c      |    6 ++++++\n wt-status.h      |    1 +\n 3 files changed, 10 insertions(+), 0 deletions(-)\n\ndiff --git a/builtin-commit.c b/builtin-commit.c\nindex 0ef7c8f..64ae45f 100644\n--- a/builtin-commit.c\n+++ b/builtin-commit.c\n@@ -917,6 +917,9 @@ int cmd_stat(int argc, const char **argv, const char *prefix)\n \t\t\t     builtin_stat_usage, 0);\n \thandle_untracked_files_arg(&s);\n \n+\tif (*argv)\n+\t\ts.pathspec = get_pathspec(prefix, argv);\n+\n \tread_cache();\n \trefresh_cache(REFRESH_QUIET|REFRESH_UNMERGED);\n \ts.is_initial = get_sha1(s.reference, sha1) ? 1 : 0;\ndiff --git a/wt-status.c b/wt-status.c\nindex c887a90..11db07e 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -269,6 +269,7 @@ static void wt_status_collect_changes_worktree(struct wt_status *s)\n \trev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;\n \trev.diffopt.format_callback = wt_status_collect_changed_cb;\n \trev.diffopt.format_callback_data = s;\n+\trev.prune_data = s->pathspec;\n \trun_diff_files(&rev, 0);\n }\n \n@@ -285,6 +286,7 @@ static void wt_status_collect_changes_index(struct wt_status *s)\n \trev.diffopt.detect_rename = 1;\n \trev.diffopt.rename_limit = 200;\n \trev.diffopt.break_opt = 0;\n+\trev.prune_data = s->pathspec;\n \trun_diff_index(&rev, 1);\n }\n \n@@ -297,6 +299,8 @@ static void wt_status_collect_changes_initial(struct wt_status *s)\n \t\tstruct wt_status_change_data *d;\n \t\tstruct cache_entry *ce = active_cache[i];\n \n+\t\tif (!ce_path_match(ce, s->pathspec))\n+\t\t\tcontinue;\n \t\tit = string_list_insert(ce->name, &s->change);\n \t\td = it->util;\n \t\tif (!d) {\n@@ -330,6 +334,8 @@ static void wt_status_collect_untracked(struct wt_status *s)\n \t\tstruct dir_entry *ent = dir.entries[i];\n \t\tif (!cache_name_is_other(ent->name, ent->len))\n \t\t\tcontinue;\n+\t\tif (!match_pathspec(s->pathspec, ent->name, ent->len, 0, NULL))\n+\t\t\tcontinue;\n \t\ts->workdir_untracked = 1;\n \t\tstring_list_insert(ent->name, &s->untracked);\n \t}\ndiff --git a/wt-status.h b/wt-status.h\nindex ab52ce1..4bc1a59 100644\n--- a/wt-status.h\n+++ b/wt-status.h\n@@ -31,6 +31,7 @@ struct wt_status {\n \tint is_initial;\n \tchar *branch;\n \tconst char *reference;\n+\tconst char **pathspec;\n \tint verbose;\n \tint amend;\n \tint nowarn;\n-- \n1.6.4.224.g3be84\n"},{"id":"120701","messageId":"1250330803-22171-6-git-send-email-gitster@pobox.com","threadId":"20603","inReplyTo":"1250330803-22171-5-git-send-email-gitster@pobox.com","subject":"[PATCH 5/6] git stat -s: short status output","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-08-15T10:06:42Z","receivedAt":"2009-08-15T10:06:42Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Give -s(hort) option to \"git stat\" that shows the status of paths in a\nmore concise way.\n\n    XY PATH1 -> PATH2\n\nformat to be more machine readable than output from \"git status\", which is\nabout previewing of \"git commit\" with the same arguments.\n\nPATH1 is the path in the HEAD, and \" -> PATH2\" part is shown only when\nPATH1 corresponds to a different path in the index/worktree.\n\nFor unmerged entries, X shows the status of stage #2 (i.e. ours) and Y\nshows the status of stage #3 (i.e. theirs).  For entries that do not have\nconflicts, X shows the status of the index, and Y shows the status of the\nwork tree.  For untracked paths, XY are \"??\".\n\n    X          Y     Meaning\n    -------------------------------------------------\n              [MD]   not updated\n    M        [ MD]   updated in index\n    A        [ MD]   added to index\n    D        [ MD]   deleted from index\n    R        [ MD]   renamed in index\n    C        [ MD]   copied in index\n    [MARC]           index and work tree matches\n    [ MARC]     M    work tree changed since index\n    [ MARC]     D    deleted in work tree\n\n    D           D    unmerged, both deleted\n    A           U    unmerged, added by us\n    U           D    unmerged, deleted by them\n    U           A    unmerged, added by them\n    D           U    unmerged, deleted by us\n    A           A    unmerged, both added\n    U           U    unmerged, both modified\n\n    ?           ?    untracked\n\nWhen given -z option, the records are terminated by NUL characters for\nbetter machine readability.  Because the traditional long format is\ndesigned for human consumption, NUL termination does not make sense.\nFor this reason, -z option implies -s (short output).\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n\n* Unlike what was in 'pu', -z now implies -s.  I do not think the machine\n  readble -s format should use color, but I _could_ be talked into\n  coloring the output when -z is not used.\n\n builtin-commit.c |  108 +++++++++++++++++++++++++++++++++++++++++++++++++++--\n 1 files changed, 103 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin-commit.c b/builtin-commit.c\nindex 64ae45f..6d9bd84 100644\n--- a/builtin-commit.c\n+++ b/builtin-commit.c\n@@ -898,11 +898,86 @@ static int git_status_config(const char *k, const char *v, void *cb)\n \treturn git_diff_ui_config(k, v, NULL);\n }\n \n+#define quote_path quote_path_relative\n+\n+static void short_unmerged(int null_termination, struct string_list_item *it,\n+\t\t\t   struct wt_status *s)\n+{\n+\tstruct wt_status_change_data *d = it->util;\n+\tconst char *how = \"??\";\n+\n+\tswitch (d->stagemask) {\n+\tcase 1: how = \"DD\"; break; /* both deleted */\n+\tcase 2: how = \"AU\"; break; /* added by us */\n+\tcase 3: how = \"UD\"; break; /* deleted by them */\n+\tcase 4: how = \"UA\"; break; /* added by them */\n+\tcase 5: how = \"DU\"; break; /* deleted by us */\n+\tcase 6: how = \"AA\"; break; /* both added */\n+\tcase 7: how = \"UU\"; break; /* both modified */\n+\t}\n+\tprintf(\"%s \", how);\n+\tif (null_termination) {\n+\t\tfprintf(stdout, \"%s%c\", it->string, 0);\n+\t} else {\n+\t\tstruct strbuf onebuf = STRBUF_INIT;\n+\t\tconst char *one;\n+\t\tone = quote_path(it->string, -1, &onebuf, s->prefix);\n+\t\tprintf(\"%s\\n\", one);\n+\t\tstrbuf_release(&onebuf);\n+\t}\n+}\n+\n+static void short_status(int null_termination, struct string_list_item *it,\n+\t\t\t struct wt_status *s)\n+{\n+\tstruct wt_status_change_data *d = it->util;\n+\n+\tprintf(\"%c%c \",\n+\t       !d->index_status ? ' ' : d->index_status,\n+\t       !d->worktree_status ? ' ' : d->worktree_status);\n+\tif (null_termination) {\n+\t\tfprintf(stdout, \"%s%c\", it->string, 0);\n+\t\tif (d->head_path)\n+\t\t\tfprintf(stdout, \"%s%c\", d->head_path, 0);\n+\t} else {\n+\t\tstruct strbuf onebuf = STRBUF_INIT;\n+\t\tconst char *one;\n+\t\tif (d->head_path) {\n+\t\t\tone = quote_path(d->head_path, -1, &onebuf, s->prefix);\n+\t\t\tprintf(\"%s -> \", one);\n+\t\t\tstrbuf_release(&onebuf);\n+\t\t}\n+\t\tone = quote_path(it->string, -1, &onebuf, s->prefix);\n+\t\tprintf(\"%s\\n\", one);\n+\t\tstrbuf_release(&onebuf);\n+\t}\n+}\n+\n+static void short_untracked(int null_termination, struct string_list_item *it,\n+\t\t\t    struct wt_status *s)\n+{\n+\tif (null_termination) {\n+\t\tfprintf(stdout, \"?? %s%c\", it->string, 0);\n+\t} else {\n+\t\tstruct strbuf onebuf = STRBUF_INIT;\n+\t\tconst char *one;\n+\t\tone = quote_path(it->string, -1, &onebuf, s->prefix);\n+\t\tprintf(\"?? %s\\n\", one);\n+\t\tstrbuf_release(&onebuf);\n+\t}\n+}\n+\n int cmd_stat(int argc, const char **argv, const char *prefix)\n {\n \tstruct wt_status s;\n+\tstatic int null_termination, shortstatus;\n+\tint i;\n \tunsigned char sha1[20];\n \tstatic struct option builtin_stat_options[] = {\n+\t\tOPT_BOOLEAN('s', \"short\", &shortstatus,\n+\t\t\t    \"show status concicely\"),\n+\t\tOPT_BOOLEAN('z', \"null\", &null_termination,\n+\t\t\t    \"terminate entries with NUL\"),\n \t\t{ OPTION_STRING, 'u', \"untracked-files\", &untracked_files_arg,\n \t\t  \"mode\",\n \t\t  \"show untracked files, optional modes: all, normal, no. (Default: all)\",\n@@ -910,6 +985,9 @@ int cmd_stat(int argc, const char **argv, const char *prefix)\n \t\tOPT_END(),\n \t};\n \n+\tif (null_termination)\n+\t\tshortstatus = 1;\n+\n \twt_status_prepare(&s);\n \tgit_config(git_status_config, &s);\n \targc = parse_options(argc, argv, prefix,\n@@ -925,11 +1003,31 @@ int cmd_stat(int argc, const char **argv, const char *prefix)\n \ts.is_initial = get_sha1(s.reference, sha1) ? 1 : 0;\n \twt_status_collect(&s);\n \n-\tif (s.use_color == -1)\n-\t\ts.use_color = git_use_color_default;\n-\tif (diff_use_color_default == -1)\n-\t\tdiff_use_color_default = git_use_color_default;\n-\twt_status_print_body(&s);\n+\tif (shortstatus) {\n+\t\tfor (i = 0; i < s.change.nr; i++) {\n+\t\t\tstruct wt_status_change_data *d;\n+\t\t\tstruct string_list_item *it;\n+\n+\t\t\tit = &(s.change.items[i]);\n+\t\t\td = it->util;\n+\t\t\tif (d->stagemask)\n+\t\t\t\tshort_unmerged(null_termination, it, &s);\n+\t\t\telse\n+\t\t\t\tshort_status(null_termination, it, &s);\n+\t\t}\n+\t\tfor (i = 0; i < s.untracked.nr; i++) {\n+\t\t\tstruct string_list_item *it;\n+\n+\t\t\tit = &(s.untracked.items[i]);\n+\t\t\tshort_untracked(null_termination, it, &s);\n+\t\t}\n+\t} else {\n+\t\tif (s.use_color == -1)\n+\t\t\ts.use_color = git_use_color_default;\n+\t\tif (diff_use_color_default == -1)\n+\t\t\tdiff_use_color_default = git_use_color_default;\n+\t\twt_status_print_body(&s);\n+\t}\n \treturn 0;\n }\n \n-- \n1.6.4.224.g3be84\n"},{"id":"120700","messageId":"1250330803-22171-7-git-send-email-gitster@pobox.com","threadId":"20603","inReplyTo":"1250330803-22171-6-git-send-email-gitster@pobox.com","subject":"[PATCH 6/6] git status: not \"commit --dry-run\" anymore","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-08-15T10:06:43Z","receivedAt":"2009-08-15T10:06:43Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"This removes tentative \"git stat\" and make it take over \"git status\".\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n Documentation/git-status.txt |   79 ++++++++++++++++++++++++++++++++++++-----\n builtin-commit.c             |   29 ++-------------\n builtin.h                    |    1 -\n git.c                        |    1 -\n 4 files changed, 73 insertions(+), 37 deletions(-)\n\ndiff --git a/Documentation/git-status.txt b/Documentation/git-status.txt\nindex 84f60f3..b5939d6 100644\n--- a/Documentation/git-status.txt\n+++ b/Documentation/git-status.txt\n@@ -8,7 +8,7 @@ git-status - Show the working tree status\n \n SYNOPSIS\n --------\n-'git status' <options>...\n+'git status' [<options>...] [--] [<pathspec>...]\n \n DESCRIPTION\n -----------\n@@ -20,25 +20,85 @@ are what you _would_ commit by running `git commit`; the second and\n third are what you _could_ commit by running 'git-add' before running\n `git commit`.\n \n-The command takes the same set of options as 'git-commit'; it\n-shows what would be committed if the same options are given to\n-'git-commit'.\n-\n-If there is no path that is different between the index file and\n-the current HEAD commit (i.e., there is nothing to commit by running\n-`git commit`), the command exits with non-zero status.\n+OPTIONS\n+-------\n+\n+-s::\n+--short::\n+\tGive the output in the short-format.\n+\n+-u[<mode>]::\n+--untracked-files[=<mode>]::\n+\tShow untracked files (Default: 'all').\n++\n+The mode parameter is optional, and is used to specify\n+the handling of untracked files. The possible options are:\n++\n+--\n+\t- 'no'     - Show no untracked files\n+\t- 'normal' - Shows untracked files and directories\n+\t- 'all'    - Also shows individual files in untracked directories.\n+--\n++\n+See linkgit:git-config[1] for configuration variable\n+used to change the default for when the option is not\n+specified.\n+\n+-z::\n+\tTerminate entries with NUL, instead of LF.  This implies `-s`\n+\t(short status) output format.\n \n \n OUTPUT\n ------\n The output from this command is designed to be used as a commit\n template comment, and all the output lines are prefixed with '#'.\n+The default, long format, is designed to be human readable,\n+verbose and descriptive.  They are subject to change in any time.\n \n The paths mentioned in the output, unlike many other git commands, are\n made relative to the current directory if you are working in a\n subdirectory (this is on purpose, to help cutting and pasting). See\n the status.relativePaths config option below.\n \n+In short-format, the status of each path is shown as\n+\n+\tXY PATH1 -> PATH2\n+\n+where `PATH1` is the path in the `HEAD`, and ` -> PATH2` part is\n+shown only when `PATH1` corresponds to a different path in the\n+index/worktree (i.e. renamed).\n+\n+For unmerged entries, `X` shows the status of stage #2 (i.e. ours) and `Y`\n+shows the status of stage #3 (i.e. theirs).\n+\n+For entries that do not have conflicts, `X` shows the status of the index,\n+and `Y` shows the status of the work tree.  For untracked paths, `XY` are\n+`??`.\n+\n+    X          Y     Meaning\n+    -------------------------------------------------\n+              [MD]   not updated\n+    M        [ MD]   updated in index\n+    A        [ MD]   added to index\n+    D        [ MD]   deleted from index\n+    R        [ MD]   renamed in index\n+    C        [ MD]   copied in index\n+    [MARC]           index and work tree matches\n+    [ MARC]     M    work tree changed since index\n+    [ MARC]     D    deleted in work tree\n+    -------------------------------------------------\n+    D           D    unmerged, both deleted\n+    A           U    unmerged, added by us\n+    U           D    unmerged, deleted by them\n+    U           A    unmerged, added by them\n+    D           U    unmerged, deleted by us\n+    A           A    unmerged, both added\n+    U           U    unmerged, both modified\n+    -------------------------------------------------\n+    ?           ?    untracked\n+    -------------------------------------------------\n+\n \n CONFIGURATION\n -------------\n@@ -63,8 +123,7 @@ linkgit:gitignore[5]\n \n Author\n ------\n-Written by Linus Torvalds <torvalds@osdl.org> and\n-Junio C Hamano <gitster@pobox.com>.\n+Written by Junio C Hamano <gitster@pobox.com>.\n \n Documentation\n --------------\ndiff --git a/builtin-commit.c b/builtin-commit.c\nindex 6d9bd84..efbcd16 100644\n--- a/builtin-commit.c\n+++ b/builtin-commit.c\n@@ -36,11 +36,6 @@ static const char * const builtin_status_usage[] = {\n \tNULL\n };\n \n-static const char * const builtin_stat_usage[] = {\n-\t\"git stat [options]\",\n-\tNULL\n-};\n-\n static unsigned char head_sha1[20], merge_head_sha1[20];\n static char *use_message_buffer;\n static const char commit_editmsg[] = \"COMMIT_EDITMSG\";\n@@ -967,13 +962,13 @@ static void short_untracked(int null_termination, struct string_list_item *it,\n \t}\n }\n \n-int cmd_stat(int argc, const char **argv, const char *prefix)\n+int cmd_status(int argc, const char **argv, const char *prefix)\n {\n \tstruct wt_status s;\n \tstatic int null_termination, shortstatus;\n \tint i;\n \tunsigned char sha1[20];\n-\tstatic struct option builtin_stat_options[] = {\n+\tstatic struct option builtin_status_options[] = {\n \t\tOPT_BOOLEAN('s', \"short\", &shortstatus,\n \t\t\t    \"show status concicely\"),\n \t\tOPT_BOOLEAN('z', \"null\", &null_termination,\n@@ -991,8 +986,8 @@ int cmd_stat(int argc, const char **argv, const char *prefix)\n \twt_status_prepare(&s);\n \tgit_config(git_status_config, &s);\n \targc = parse_options(argc, argv, prefix,\n-\t\t\t     builtin_stat_options,\n-\t\t\t     builtin_stat_usage, 0);\n+\t\t\t     builtin_status_options,\n+\t\t\t     builtin_status_usage, 0);\n \thandle_untracked_files_arg(&s);\n \n \tif (*argv)\n@@ -1031,22 +1026,6 @@ int cmd_stat(int argc, const char **argv, const char *prefix)\n \treturn 0;\n }\n \n-int cmd_status(int argc, const char **argv, const char *prefix)\n-{\n-\tstruct wt_status s;\n-\n-\twt_status_prepare(&s);\n-\tgit_config(git_status_config, &s);\n-\tif (s.use_color == -1)\n-\t\ts.use_color = git_use_color_default;\n-\tif (diff_use_color_default == -1)\n-\t\tdiff_use_color_default = git_use_color_default;\n-\n-\targc = parse_and_validate_options(argc, argv, builtin_status_usage,\n-\t\t\t\t\t  prefix, &s);\n-\treturn dry_run_commit(argc, argv, prefix, &s);\n-}\n-\n static void print_summary(const char *prefix, const unsigned char *sha1)\n {\n \tstruct rev_info rev;\ndiff --git a/builtin.h b/builtin.h\nindex eeaf0b6..20427d2 100644\n--- a/builtin.h\n+++ b/builtin.h\n@@ -95,7 +95,6 @@ extern int cmd_send_pack(int argc, const char **argv, const char *prefix);\n extern int cmd_shortlog(int argc, const char **argv, const char *prefix);\n extern int cmd_show(int argc, const char **argv, const char *prefix);\n extern int cmd_show_branch(int argc, const char **argv, const char *prefix);\n-extern int cmd_stat(int argc, const char **argv, const char *prefix);\n extern int cmd_status(int argc, const char **argv, const char *prefix);\n extern int cmd_stripspace(int argc, const char **argv, const char *prefix);\n extern int cmd_symbolic_ref(int argc, const char **argv, const char *prefix);\ndiff --git a/git.c b/git.c\nindex de7fcf6..807d875 100644\n--- a/git.c\n+++ b/git.c\n@@ -350,7 +350,6 @@ static void handle_internal_command(int argc, const char **argv)\n \t\t{ \"shortlog\", cmd_shortlog, USE_PAGER },\n \t\t{ \"show-branch\", cmd_show_branch, RUN_SETUP },\n \t\t{ \"show\", cmd_show, RUN_SETUP | USE_PAGER },\n-\t\t{ \"stat\", cmd_stat, RUN_SETUP | NEED_WORK_TREE },\n \t\t{ \"status\", cmd_status, RUN_SETUP | NEED_WORK_TREE },\n \t\t{ \"stripspace\", cmd_stripspace },\n \t\t{ \"symbolic-ref\", cmd_symbolic_ref, RUN_SETUP },\n-- \n1.6.4.224.g3be84\n"},{"id":"120858","messageId":"200908171201.43343.trast@student.ethz.ch","threadId":"20603","inReplyTo":"1250330803-22171-1-git-send-email-gitster@pobox.com","subject":"Re: [PATCH 0/6] \"git commit --dry-run\" updates","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2009-08-17T10:01:41Z","receivedAt":"2009-08-17T10:01:41Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Junio C Hamano wrote:\n> The third and the fourth ones tentatively introduce \"git stat\".  The\n> former is an incomplete implementation that ignores the pathspec, and the\n> latter adds pathspec limiting to it.  In the final form before it goes to\n> 'next', these two should probably be squashed.\n\nIf it's not too much work, it would be nice to somehow detect if -u\ncan have any influence at all.  For example,\n\n  $ git status bar\n  # Not currently on any branch.\n  nothing to commit (use -u to show untracked files)\n\nis a bit misleading if 'bar' is tracked because adding a -u won't make\nany difference.\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"120904","messageId":"7vljlixwkz.fsf@alter.siamese.dyndns.org","threadId":"20603","inReplyTo":"200908171201.43343.trast@student.ethz.ch","subject":"Re: [PATCH 0/6] \"git commit --dry-run\" updates","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-08-17T15:57:00Z","receivedAt":"2009-08-17T15:57:00Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thomas Rast <trast@student.ethz.ch> writes:\n\n> If it's not too much work, it would be nice to somehow detect if -u\n> can have any influence at all.  For example,\n>\n>   $ git status bar\n>   # Not currently on any branch.\n>   nothing to commit (use -u to show untracked files)\n>\n> is a bit misleading if 'bar' is tracked because adding a -u won't make\n> any difference.\n\nIt is an issue shared with the original \"git status\".  Running\n\n    git init\n    >file\n    git add file\n    git commit -m initial\n    git status -uno\n\nwill give the same \"use -u to show\" message.\n\nThe thing is, \"use -u to show\" is because you told git not to check if\nthere is any untracked file.  Whoever added -uno wanted not to run the\nrecursive read_directory() to find them.\n\nThe message says \"you told me not to check about untracked files, so I can\nnot show you any, because I did not check; if you want, please use -u to\ntell me to check so that I can show them to you\".  \n\nIt is not about \"we know that there are untracked files but you told me\nnot to show it, so I am not telling\".  We simply do not know at the point\nwe give that message.  In other words, conditional removal of that message\nis fundamentally incompatible with the use of -uno.\n"},{"id":"120960","messageId":"200908172116.26737.trast@student.ethz.ch","threadId":"20603","inReplyTo":"7vljlixwkz.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 0/6] \"git commit --dry-run\" updates","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2009-08-17T19:16:25Z","receivedAt":"2009-08-17T19:16:25Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Junio C Hamano wrote:\n> Thomas Rast <trast@student.ethz.ch> writes:\n> \n> > If it's not too much work, it would be nice to somehow detect if -u\n> > can have any influence at all.  For example,\n> >\n> >   $ git status bar\n> >   # Not currently on any branch.\n> >   nothing to commit (use -u to show untracked files)\n> >\n> > is a bit misleading if 'bar' is tracked because adding a -u won't make\n> > any difference.\n[...]\n> It is not about \"we know that there are untracked files but you told me\n> not to show it, so I am not telling\".  We simply do not know at the point\n> we give that message.  In other words, conditional removal of that message\n> is fundamentally incompatible with the use of -uno.\n\nOk.  I hoped there would be an easy way to know that all pathspecs\nexactly matched a tracked file, and thus no untracked files can\npossibly change the listing.\n\nBut you convinced me that it doesn't fit into the current scheme, and\nit doesn't really matter...\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"}]}