{"thread":{"id":"42922","subject":"[PATCH v2 0/8] status: V2 porcelain status","startedAt":"2016-07-25T19:28:51Z","lastAt":"2016-07-26T19:46:18Z","messageCount":20,"participants":["Jeff Hostetler","Jakub Narębski","Junio C Hamano","Johannes Schindelin"],"isPatch":true,"patchVersion":2,"patchTotal":8},"messages":[{"id":"292121","messageId":"1469474750-49075-1-git-send-email-jeffhost@microsoft.com","threadId":"42922","inReplyTo":null,"subject":"[PATCH v2 0/8] status: V2 porcelain status","fromName":"Jeff Hostetler","fromEmail":"jeffhost@microsoft.com","sentAt":"2016-07-25T19:25:42Z","receivedAt":"2016-07-25T19:28:51Z","isPatch":true,"sender":{"key":"jeffhost@microsoft.com","avatar":"https://avatars.githubusercontent.com/u/7493832?v=4"},"body":"This patch series adds porcelain V2 format to status.\nThis provides detailed information about file changes\nand about the current branch.\n\nThe new output is accessed via:\n    git status --porcelain=v2 [--branch]\n\nThis patch series hopefully addresses all of the\ncomments from the previous series.  The first 2\ncommits move the choice of output routines into\nwt-status.c and cleanup the API from builtin/commit.c.\nThe command line parameter is \"v2\" to make it easier\nto define other formats and/or JSON output later if\nwe want.  Detail lines for ordinary changes and\nunmerged changes are now completely separate and have\na unique prefix key (and are grouped by type).  The\nunit tests have been converted to use heredoc's.\n\nI removed the v2 argument from git commit --porcelain\nsince it didn't really fit here.\n\nJeff Hostetler (8):\n  status: rename long-format print routines\n  status: cleanup API to wt_status_print\n  status: support --porcelain[=<version>]\n  status: per-file data collection for --porcelain=v2\n  status: print per-file porcelain v2 status data\n  status: print branch info with --porcelain=v2 --branch\n  status: update git-status.txt for --porcelain=v2\n  status: tests for --porcelain=v2\n\n Documentation/git-status.txt |  90 ++++++-\n builtin/commit.c             |  78 +++---\n t/t7060-wtstatus.sh          |  21 ++\n t/t7064-wtstatus-pv2.sh      | 542 +++++++++++++++++++++++++++++++++++++\n wt-status.c                  | 616 +++++++++++++++++++++++++++++++++++++++----\n wt-status.h                  |  32 ++-\n 6 files changed, 1269 insertions(+), 110 deletions(-)\n create mode 100755 t/t7064-wtstatus-pv2.sh\n\n-- \n2.8.0.rc4.17.gac42084.dirty\n\n"},{"id":"292122","messageId":"1469474750-49075-2-git-send-email-jeffhost@microsoft.com","threadId":"42922","inReplyTo":"1469474750-49075-1-git-send-email-jeffhost@microsoft.com","subject":"[PATCH v2 1/8] status: rename long-format print routines","fromName":"Jeff Hostetler","fromEmail":"jeffhost@microsoft.com","sentAt":"2016-07-25T19:25:43Z","receivedAt":"2016-07-25T19:28:55Z","isPatch":true,"sender":{"key":"jeffhost@microsoft.com","avatar":"https://avatars.githubusercontent.com/u/7493832?v=4"},"body":"Renamed the various wt_status_print*() routines to be\nwt_longstatus_print*() to make it clear that these\nroutines are only concerned with the normal/long\nstatus output.\n\nThis will hopefully reduce confusion as other status\nformats are added in the future.\n\nSigned-off-by: Jeff Hostetler <jeffhost@microsoft.com>\n---\n builtin/commit.c |   4 +-\n wt-status.c      | 110 +++++++++++++++++++++++++++----------------------------\n wt-status.h      |   2 +-\n 3 files changed, 58 insertions(+), 58 deletions(-)\n\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 1f6dbcd..b80273b 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -515,7 +515,7 @@ static int run_status(FILE *fp, const char *index_file, const char *prefix, int\n \t\tbreak;\n \tcase STATUS_FORMAT_NONE:\n \tcase STATUS_FORMAT_LONG:\n-\t\twt_status_print(s);\n+\t\twt_longstatus_print(s);\n \t\tbreak;\n \t}\n \n@@ -1403,7 +1403,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)\n \tcase STATUS_FORMAT_LONG:\n \t\ts.verbose = verbose;\n \t\ts.ignore_submodule_arg = ignore_submodule_arg;\n-\t\twt_status_print(&s);\n+\t\twt_longstatus_print(&s);\n \t\tbreak;\n \t}\n \treturn 0;\ndiff --git a/wt-status.c b/wt-status.c\nindex de62ab2..b9a58fd 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -139,7 +139,7 @@ void wt_status_prepare(struct wt_status *s)\n \ts->display_comment_prefix = 0;\n }\n \n-static void wt_status_print_unmerged_header(struct wt_status *s)\n+static void wt_longstatus_print_unmerged_header(struct wt_status *s)\n {\n \tint i;\n \tint del_mod_conflict = 0;\n@@ -191,7 +191,7 @@ static void wt_status_print_unmerged_header(struct wt_status *s)\n \tstatus_printf_ln(s, c, \"%s\", \"\");\n }\n \n-static void wt_status_print_cached_header(struct wt_status *s)\n+static void wt_longstatus_print_cached_header(struct wt_status *s)\n {\n \tconst char *c = color(WT_STATUS_HEADER, s);\n \n@@ -207,9 +207,9 @@ static void wt_status_print_cached_header(struct wt_status *s)\n \tstatus_printf_ln(s, c, \"%s\", \"\");\n }\n \n-static void wt_status_print_dirty_header(struct wt_status *s,\n-\t\t\t\t\t int has_deleted,\n-\t\t\t\t\t int has_dirty_submodules)\n+static void wt_longstatus_print_dirty_header(struct wt_status *s,\n+\t\t\t\t\t     int has_deleted,\n+\t\t\t\t\t     int has_dirty_submodules)\n {\n \tconst char *c = color(WT_STATUS_HEADER, s);\n \n@@ -226,9 +226,9 @@ static void wt_status_print_dirty_header(struct wt_status *s,\n \tstatus_printf_ln(s, c, \"%s\", \"\");\n }\n \n-static void wt_status_print_other_header(struct wt_status *s,\n-\t\t\t\t\t const char *what,\n-\t\t\t\t\t const char *how)\n+static void wt_longstatus_print_other_header(struct wt_status *s,\n+\t\t\t\t\t     const char *what,\n+\t\t\t\t\t     const char *how)\n {\n \tconst char *c = color(WT_STATUS_HEADER, s);\n \tstatus_printf_ln(s, c, \"%s:\", what);\n@@ -238,7 +238,7 @@ static void wt_status_print_other_header(struct wt_status *s,\n \tstatus_printf_ln(s, c, \"%s\", \"\");\n }\n \n-static void wt_status_print_trailer(struct wt_status *s)\n+static void wt_longstatus_print_trailer(struct wt_status *s)\n {\n \tstatus_printf_ln(s, color(WT_STATUS_HEADER, s), \"%s\", \"\");\n }\n@@ -304,8 +304,8 @@ static int maxwidth(const char *(*label)(int), int minval, int maxval)\n \treturn result;\n }\n \n-static void wt_status_print_unmerged_data(struct wt_status *s,\n-\t\t\t\t\t  struct string_list_item *it)\n+static void wt_longstatus_print_unmerged_data(struct wt_status *s,\n+\t\t\t\t\t      struct string_list_item *it)\n {\n \tconst char *c = color(WT_STATUS_UNMERGED, s);\n \tstruct wt_status_change_data *d = it->util;\n@@ -331,9 +331,9 @@ static void wt_status_print_unmerged_data(struct wt_status *s,\n \tstrbuf_release(&onebuf);\n }\n \n-static void wt_status_print_change_data(struct wt_status *s,\n-\t\t\t\t\tint change_type,\n-\t\t\t\t\tstruct string_list_item *it)\n+static void wt_longstatus_print_change_data(struct wt_status *s,\n+\t\t\t\t\t    int change_type,\n+\t\t\t\t\t    struct string_list_item *it)\n {\n \tstruct wt_status_change_data *d = it->util;\n \tconst char *c = color(change_type, s);\n@@ -378,7 +378,7 @@ static void wt_status_print_change_data(struct wt_status *s,\n \t\tstatus = d->worktree_status;\n \t\tbreak;\n \tdefault:\n-\t\tdie(\"BUG: unhandled change_type %d in wt_status_print_change_data\",\n+\t\tdie(\"BUG: unhandled change_type %d in wt_longstatus_print_change_data\",\n \t\t    change_type);\n \t}\n \n@@ -627,7 +627,7 @@ void wt_status_collect(struct wt_status *s)\n \twt_status_collect_untracked(s);\n }\n \n-static void wt_status_print_unmerged(struct wt_status *s)\n+static void wt_longstatus_print_unmerged(struct wt_status *s)\n {\n \tint shown_header = 0;\n \tint i;\n@@ -640,17 +640,17 @@ static void wt_status_print_unmerged(struct wt_status *s)\n \t\tif (!d->stagemask)\n \t\t\tcontinue;\n \t\tif (!shown_header) {\n-\t\t\twt_status_print_unmerged_header(s);\n+\t\t\twt_longstatus_print_unmerged_header(s);\n \t\t\tshown_header = 1;\n \t\t}\n-\t\twt_status_print_unmerged_data(s, it);\n+\t\twt_longstatus_print_unmerged_data(s, it);\n \t}\n \tif (shown_header)\n-\t\twt_status_print_trailer(s);\n+\t\twt_longstatus_print_trailer(s);\n \n }\n \n-static void wt_status_print_updated(struct wt_status *s)\n+static void wt_longstatus_print_updated(struct wt_status *s)\n {\n \tint shown_header = 0;\n \tint i;\n@@ -664,14 +664,14 @@ static void wt_status_print_updated(struct wt_status *s)\n \t\t    d->index_status == DIFF_STATUS_UNMERGED)\n \t\t\tcontinue;\n \t\tif (!shown_header) {\n-\t\t\twt_status_print_cached_header(s);\n+\t\t\twt_longstatus_print_cached_header(s);\n \t\t\ts->commitable = 1;\n \t\t\tshown_header = 1;\n \t\t}\n-\t\twt_status_print_change_data(s, WT_STATUS_UPDATED, it);\n+\t\twt_longstatus_print_change_data(s, WT_STATUS_UPDATED, it);\n \t}\n \tif (shown_header)\n-\t\twt_status_print_trailer(s);\n+\t\twt_longstatus_print_trailer(s);\n }\n \n /*\n@@ -703,7 +703,7 @@ static int wt_status_check_worktree_changes(struct wt_status *s,\n \treturn changes;\n }\n \n-static void wt_status_print_changed(struct wt_status *s)\n+static void wt_longstatus_print_changed(struct wt_status *s)\n {\n \tint i, dirty_submodules;\n \tint worktree_changes = wt_status_check_worktree_changes(s, &dirty_submodules);\n@@ -711,7 +711,7 @@ static void wt_status_print_changed(struct wt_status *s)\n \tif (!worktree_changes)\n \t\treturn;\n \n-\twt_status_print_dirty_header(s, worktree_changes < 0, dirty_submodules);\n+\twt_longstatus_print_dirty_header(s, worktree_changes < 0, dirty_submodules);\n \n \tfor (i = 0; i < s->change.nr; i++) {\n \t\tstruct wt_status_change_data *d;\n@@ -721,12 +721,12 @@ static void wt_status_print_changed(struct wt_status *s)\n \t\tif (!d->worktree_status ||\n \t\t    d->worktree_status == DIFF_STATUS_UNMERGED)\n \t\t\tcontinue;\n-\t\twt_status_print_change_data(s, WT_STATUS_CHANGED, it);\n+\t\twt_longstatus_print_change_data(s, WT_STATUS_CHANGED, it);\n \t}\n-\twt_status_print_trailer(s);\n+\twt_longstatus_print_trailer(s);\n }\n \n-static void wt_status_print_submodule_summary(struct wt_status *s, int uncommitted)\n+static void wt_longstatus_print_submodule_summary(struct wt_status *s, int uncommitted)\n {\n \tstruct child_process sm_summary = CHILD_PROCESS_INIT;\n \tstruct strbuf cmd_stdout = STRBUF_INIT;\n@@ -772,10 +772,10 @@ static void wt_status_print_submodule_summary(struct wt_status *s, int uncommitt\n \tstrbuf_release(&summary);\n }\n \n-static void wt_status_print_other(struct wt_status *s,\n-\t\t\t\t  struct string_list *l,\n-\t\t\t\t  const char *what,\n-\t\t\t\t  const char *how)\n+static void wt_longstatus_print_other(struct wt_status *s,\n+\t\t\t\t      struct string_list *l,\n+\t\t\t\t      const char *what,\n+\t\t\t\t      const char *how)\n {\n \tint i;\n \tstruct strbuf buf = STRBUF_INIT;\n@@ -785,7 +785,7 @@ static void wt_status_print_other(struct wt_status *s,\n \tif (!l->nr)\n \t\treturn;\n \n-\twt_status_print_other_header(s, what, how);\n+\twt_longstatus_print_other_header(s, what, how);\n \n \tfor (i = 0; i < l->nr; i++) {\n \t\tstruct string_list_item *it;\n@@ -845,7 +845,7 @@ void wt_status_add_cut_line(FILE *fp)\n \tstrbuf_release(&buf);\n }\n \n-static void wt_status_print_verbose(struct wt_status *s)\n+static void wt_longstatus_print_verbose(struct wt_status *s)\n {\n \tstruct rev_info rev;\n \tstruct setup_revision_opt opt;\n@@ -878,7 +878,7 @@ static void wt_status_print_verbose(struct wt_status *s)\n \tif (s->verbose > 1 && s->commitable) {\n \t\t/* print_updated() printed a header, so do we */\n \t\tif (s->fp != stdout)\n-\t\t\twt_status_print_trailer(s);\n+\t\t\twt_longstatus_print_trailer(s);\n \t\tstatus_printf_ln(s, c, _(\"Changes to be committed:\"));\n \t\trev.diffopt.a_prefix = \"c/\";\n \t\trev.diffopt.b_prefix = \"i/\";\n@@ -896,7 +896,7 @@ static void wt_status_print_verbose(struct wt_status *s)\n \t}\n }\n \n-static void wt_status_print_tracking(struct wt_status *s)\n+static void wt_longstatus_print_tracking(struct wt_status *s)\n {\n \tstruct strbuf sb = STRBUF_INIT;\n \tconst char *cp, *ep, *branch_name;\n@@ -959,7 +959,7 @@ static void show_merge_in_progress(struct wt_status *s,\n \t\t\tstatus_printf_ln(s, color,\n \t\t\t\t_(\"  (use \\\"git commit\\\" to conclude merge)\"));\n \t}\n-\twt_status_print_trailer(s);\n+\twt_longstatus_print_trailer(s);\n }\n \n static void show_am_in_progress(struct wt_status *s,\n@@ -980,7 +980,7 @@ static void show_am_in_progress(struct wt_status *s,\n \t\tstatus_printf_ln(s, color,\n \t\t\t_(\"  (use \\\"git am --abort\\\" to restore the original branch)\"));\n \t}\n-\twt_status_print_trailer(s);\n+\twt_longstatus_print_trailer(s);\n }\n \n static char *read_line_from_git_path(const char *filename)\n@@ -1204,7 +1204,7 @@ static void show_rebase_in_progress(struct wt_status *s,\n \t\t\t\t_(\"  (use \\\"git rebase --continue\\\" once you are satisfied with your changes)\"));\n \t\t}\n \t}\n-\twt_status_print_trailer(s);\n+\twt_longstatus_print_trailer(s);\n }\n \n static void show_cherry_pick_in_progress(struct wt_status *s,\n@@ -1223,7 +1223,7 @@ static void show_cherry_pick_in_progress(struct wt_status *s,\n \t\tstatus_printf_ln(s, color,\n \t\t\t_(\"  (use \\\"git cherry-pick --abort\\\" to cancel the cherry-pick operation)\"));\n \t}\n-\twt_status_print_trailer(s);\n+\twt_longstatus_print_trailer(s);\n }\n \n static void show_revert_in_progress(struct wt_status *s,\n@@ -1242,7 +1242,7 @@ static void show_revert_in_progress(struct wt_status *s,\n \t\tstatus_printf_ln(s, color,\n \t\t\t_(\"  (use \\\"git revert --abort\\\" to cancel the revert operation)\"));\n \t}\n-\twt_status_print_trailer(s);\n+\twt_longstatus_print_trailer(s);\n }\n \n static void show_bisect_in_progress(struct wt_status *s,\n@@ -1259,7 +1259,7 @@ static void show_bisect_in_progress(struct wt_status *s,\n \tif (s->hints)\n \t\tstatus_printf_ln(s, color,\n \t\t\t_(\"  (use \\\"git bisect reset\\\" to get back to the original branch)\"));\n-\twt_status_print_trailer(s);\n+\twt_longstatus_print_trailer(s);\n }\n \n /*\n@@ -1429,8 +1429,8 @@ void wt_status_get_state(struct wt_status_state *state,\n \t\twt_status_get_detached_from(state);\n }\n \n-static void wt_status_print_state(struct wt_status *s,\n-\t\t\t\t  struct wt_status_state *state)\n+static void wt_longstatus_print_state(struct wt_status *s,\n+\t\t\t\t      struct wt_status_state *state)\n {\n \tconst char *state_color = color(WT_STATUS_HEADER, s);\n \tif (state->merge_in_progress)\n@@ -1447,7 +1447,7 @@ static void wt_status_print_state(struct wt_status *s,\n \t\tshow_bisect_in_progress(s, state, state_color);\n }\n \n-void wt_status_print(struct wt_status *s)\n+void wt_longstatus_print(struct wt_status *s)\n {\n \tconst char *branch_color = color(WT_STATUS_ONBRANCH, s);\n \tconst char *branch_status_color = color(WT_STATUS_HEADER, s);\n@@ -1484,10 +1484,10 @@ void wt_status_print(struct wt_status *s)\n \t\tstatus_printf_more(s, branch_status_color, \"%s\", on_what);\n \t\tstatus_printf_more(s, branch_color, \"%s\\n\", branch_name);\n \t\tif (!s->is_initial)\n-\t\t\twt_status_print_tracking(s);\n+\t\t\twt_longstatus_print_tracking(s);\n \t}\n \n-\twt_status_print_state(s, &state);\n+\twt_longstatus_print_state(s, &state);\n \tfree(state.branch);\n \tfree(state.onto);\n \tfree(state.detached_from);\n@@ -1498,19 +1498,19 @@ void wt_status_print(struct wt_status *s)\n \t\tstatus_printf_ln(s, color(WT_STATUS_HEADER, s), \"%s\", \"\");\n \t}\n \n-\twt_status_print_updated(s);\n-\twt_status_print_unmerged(s);\n-\twt_status_print_changed(s);\n+\twt_longstatus_print_updated(s);\n+\twt_longstatus_print_unmerged(s);\n+\twt_longstatus_print_changed(s);\n \tif (s->submodule_summary &&\n \t    (!s->ignore_submodule_arg ||\n \t     strcmp(s->ignore_submodule_arg, \"all\"))) {\n-\t\twt_status_print_submodule_summary(s, 0);  /* staged */\n-\t\twt_status_print_submodule_summary(s, 1);  /* unstaged */\n+\t\twt_longstatus_print_submodule_summary(s, 0);  /* staged */\n+\t\twt_longstatus_print_submodule_summary(s, 1);  /* unstaged */\n \t}\n \tif (s->show_untracked_files) {\n-\t\twt_status_print_other(s, &s->untracked, _(\"Untracked files\"), \"add\");\n+\t\twt_longstatus_print_other(s, &s->untracked, _(\"Untracked files\"), \"add\");\n \t\tif (s->show_ignored_files)\n-\t\t\twt_status_print_other(s, &s->ignored, _(\"Ignored files\"), \"add -f\");\n+\t\t\twt_longstatus_print_other(s, &s->ignored, _(\"Ignored files\"), \"add -f\");\n \t\tif (advice_status_u_option && 2000 < s->untracked_in_ms) {\n \t\t\tstatus_printf_ln(s, GIT_COLOR_NORMAL, \"%s\", \"\");\n \t\t\tstatus_printf_ln(s, GIT_COLOR_NORMAL,\n@@ -1525,7 +1525,7 @@ void wt_status_print(struct wt_status *s)\n \t\t\t? _(\" (use -u option to show untracked files)\") : \"\");\n \n \tif (s->verbose)\n-\t\twt_status_print_verbose(s);\n+\t\twt_longstatus_print_verbose(s);\n \tif (!s->commitable) {\n \t\tif (s->amend)\n \t\t\tstatus_printf_ln(s, GIT_COLOR_NORMAL, _(\"No changes\"));\ndiff --git a/wt-status.h b/wt-status.h\nindex 2ca93f6..2023a3c 100644\n--- a/wt-status.h\n+++ b/wt-status.h\n@@ -99,7 +99,6 @@ struct wt_status_state {\n void wt_status_truncate_message_at_cut_line(struct strbuf *);\n void wt_status_add_cut_line(FILE *fp);\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_get_state(struct wt_status_state *state, int get_detached_from);\n int wt_status_check_rebase(const struct worktree *wt,\n@@ -107,6 +106,7 @@ int wt_status_check_rebase(const struct worktree *wt,\n int wt_status_check_bisect(const struct worktree *wt,\n \t\t\t   struct wt_status_state *state);\n \n+void wt_longstatus_print(struct wt_status *s);\n void wt_shortstatus_print(struct wt_status *s);\n void wt_porcelain_print(struct wt_status *s);\n \n-- \n2.8.0.rc4.17.gac42084.dirty\n\n"},{"id":"292123","messageId":"1469474750-49075-3-git-send-email-jeffhost@microsoft.com","threadId":"42922","inReplyTo":"1469474750-49075-1-git-send-email-jeffhost@microsoft.com","subject":"[PATCH v2 2/8] status: cleanup API to wt_status_print","fromName":"Jeff Hostetler","fromEmail":"jeffhost@microsoft.com","sentAt":"2016-07-25T19:25:44Z","receivedAt":"2016-07-25T19:29:02Z","isPatch":true,"sender":{"key":"jeffhost@microsoft.com","avatar":"https://avatars.githubusercontent.com/u/7493832?v=4"},"body":"Refactor the API between builtin/commit.c and wt-status.[ch].\nHide details of the various wt_*status_print() routines inside\nwt-status.c behind a single (new) wt_status_print() routine\nand eliminate the switch statements from builtin/commit.c\n\nThis will allow us to more easily add new status formats\nand isolate that within wt-status.c\n\nSigned-off-by: Jeff Hostetler <jeffhost@microsoft.com>\n---\n builtin/commit.c | 51 +++++++++------------------------------------------\n wt-status.c      | 25 ++++++++++++++++++++++---\n wt-status.h      | 16 ++++++++++++----\n 3 files changed, 43 insertions(+), 49 deletions(-)\n\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex b80273b..a792deb 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -142,14 +142,7 @@ static int show_ignored_in_status, have_option_m;\n static const char *only_include_assumed;\n static struct strbuf message = STRBUF_INIT;\n \n-static enum status_format {\n-\tSTATUS_FORMAT_NONE = 0,\n-\tSTATUS_FORMAT_LONG,\n-\tSTATUS_FORMAT_SHORT,\n-\tSTATUS_FORMAT_PORCELAIN,\n-\n-\tSTATUS_FORMAT_UNSPECIFIED\n-} status_format = STATUS_FORMAT_UNSPECIFIED;\n+static enum wt_status_format status_format = STATUS_FORMAT_UNSPECIFIED;\n \n static int opt_parse_m(const struct option *opt, const char *arg, int unset)\n {\n@@ -500,24 +493,11 @@ static int run_status(FILE *fp, const char *index_file, const char *prefix, int\n \ts->fp = fp;\n \ts->nowarn = nowarn;\n \ts->is_initial = get_sha1(s->reference, sha1) ? 1 : 0;\n+\ts->status_format = status_format;\n+\ts->ignore_submodule_arg = ignore_submodule_arg;\n \n \twt_status_collect(s);\n-\n-\tswitch (status_format) {\n-\tcase STATUS_FORMAT_SHORT:\n-\t\twt_shortstatus_print(s);\n-\t\tbreak;\n-\tcase STATUS_FORMAT_PORCELAIN:\n-\t\twt_porcelain_print(s);\n-\t\tbreak;\n-\tcase STATUS_FORMAT_UNSPECIFIED:\n-\t\tdie(\"BUG: finalize_deferred_config() should have been called\");\n-\t\tbreak;\n-\tcase STATUS_FORMAT_NONE:\n-\tcase STATUS_FORMAT_LONG:\n-\t\twt_longstatus_print(s);\n-\t\tbreak;\n-\t}\n+\twt_status_print(s);\n \n \treturn s->commitable;\n }\n@@ -1099,7 +1079,7 @@ static const char *read_commit_message(const char *name)\n  * is not in effect here.\n  */\n static struct status_deferred_config {\n-\tenum status_format status_format;\n+\tenum wt_status_format status_format;\n \tint show_branch;\n } status_deferred_config = {\n \tSTATUS_FORMAT_UNSPECIFIED,\n@@ -1381,6 +1361,9 @@ int cmd_status(int argc, const char **argv, const char *prefix)\n \n \ts.is_initial = get_sha1(s.reference, sha1) ? 1 : 0;\n \ts.ignore_submodule_arg = ignore_submodule_arg;\n+\ts.status_format = status_format;\n+\ts.verbose = verbose;\n+\n \twt_status_collect(&s);\n \n \tif (0 <= fd)\n@@ -1389,23 +1372,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)\n \tif (s.relative_paths)\n \t\ts.prefix = prefix;\n \n-\tswitch (status_format) {\n-\tcase STATUS_FORMAT_SHORT:\n-\t\twt_shortstatus_print(&s);\n-\t\tbreak;\n-\tcase STATUS_FORMAT_PORCELAIN:\n-\t\twt_porcelain_print(&s);\n-\t\tbreak;\n-\tcase STATUS_FORMAT_UNSPECIFIED:\n-\t\tdie(\"BUG: finalize_deferred_config() should have been called\");\n-\t\tbreak;\n-\tcase STATUS_FORMAT_NONE:\n-\tcase STATUS_FORMAT_LONG:\n-\t\ts.verbose = verbose;\n-\t\ts.ignore_submodule_arg = ignore_submodule_arg;\n-\t\twt_longstatus_print(&s);\n-\t\tbreak;\n-\t}\n+\twt_status_print(&s);\n \treturn 0;\n }\n \ndiff --git a/wt-status.c b/wt-status.c\nindex b9a58fd..a9031e4 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -1447,7 +1447,7 @@ static void wt_longstatus_print_state(struct wt_status *s,\n \t\tshow_bisect_in_progress(s, state, state_color);\n }\n \n-void wt_longstatus_print(struct wt_status *s)\n+static void wt_longstatus_print(struct wt_status *s)\n {\n \tconst char *branch_color = color(WT_STATUS_ONBRANCH, s);\n \tconst char *branch_status_color = color(WT_STATUS_HEADER, s);\n@@ -1714,7 +1714,7 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)\n \tfputc(s->null_termination ? '\\0' : '\\n', s->fp);\n }\n \n-void wt_shortstatus_print(struct wt_status *s)\n+static void wt_shortstatus_print(struct wt_status *s)\n {\n \tint i;\n \n@@ -1746,7 +1746,7 @@ void wt_shortstatus_print(struct wt_status *s)\n \t}\n }\n \n-void wt_porcelain_print(struct wt_status *s)\n+static void wt_porcelain_print(struct wt_status *s)\n {\n \ts->use_color = 0;\n \ts->relative_paths = 0;\n@@ -1754,3 +1754,22 @@ void wt_porcelain_print(struct wt_status *s)\n \ts->no_gettext = 1;\n \twt_shortstatus_print(s);\n }\n+\n+void wt_status_print(struct wt_status *s)\n+{\n+\tswitch (s->status_format) {\n+\tcase STATUS_FORMAT_SHORT:\n+\t\twt_shortstatus_print(s);\n+\t\tbreak;\n+\tcase STATUS_FORMAT_PORCELAIN:\n+\t\twt_porcelain_print(s);\n+\t\tbreak;\n+\tcase STATUS_FORMAT_UNSPECIFIED:\n+\t\tdie(\"BUG: finalize_deferred_config() should have been called\");\n+\t\tbreak;\n+\tcase STATUS_FORMAT_NONE:\n+\tcase STATUS_FORMAT_LONG:\n+\t\twt_longstatus_print(s);\n+\t\tbreak;\n+\t}\n+}\ndiff --git a/wt-status.h b/wt-status.h\nindex 2023a3c..a859a12 100644\n--- a/wt-status.h\n+++ b/wt-status.h\n@@ -43,6 +43,15 @@ struct wt_status_change_data {\n \tunsigned new_submodule_commits : 1;\n };\n \n+ enum wt_status_format {\n+\tSTATUS_FORMAT_NONE = 0,\n+\tSTATUS_FORMAT_LONG,\n+\tSTATUS_FORMAT_SHORT,\n+\tSTATUS_FORMAT_PORCELAIN,\n+\n+\tSTATUS_FORMAT_UNSPECIFIED\n+ };\n+\n struct wt_status {\n \tint is_initial;\n \tchar *branch;\n@@ -66,6 +75,8 @@ struct wt_status {\n \tint show_branch;\n \tint hints;\n \n+\tenum wt_status_format status_format;\n+\n \t/* These are computed during processing of the individual sections */\n \tint commitable;\n \tint workdir_dirty;\n@@ -99,6 +110,7 @@ struct wt_status_state {\n void wt_status_truncate_message_at_cut_line(struct strbuf *);\n void wt_status_add_cut_line(FILE *fp);\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_get_state(struct wt_status_state *state, int get_detached_from);\n int wt_status_check_rebase(const struct worktree *wt,\n@@ -106,10 +118,6 @@ int wt_status_check_rebase(const struct worktree *wt,\n int wt_status_check_bisect(const struct worktree *wt,\n \t\t\t   struct wt_status_state *state);\n \n-void wt_longstatus_print(struct wt_status *s);\n-void wt_shortstatus_print(struct wt_status *s);\n-void wt_porcelain_print(struct wt_status *s);\n-\n __attribute__((format (printf, 3, 4)))\n void status_printf_ln(struct wt_status *s, const char *color, const char *fmt, ...);\n __attribute__((format (printf, 3, 4)))\n-- \n2.8.0.rc4.17.gac42084.dirty\n\n"},{"id":"292124","messageId":"1469474750-49075-4-git-send-email-jeffhost@microsoft.com","threadId":"42922","inReplyTo":"1469474750-49075-1-git-send-email-jeffhost@microsoft.com","subject":"[PATCH v2 3/8] status: support --porcelain[=<version>]","fromName":"Jeff Hostetler","fromEmail":"jeffhost@microsoft.com","sentAt":"2016-07-25T19:25:45Z","receivedAt":"2016-07-25T19:29:06Z","isPatch":true,"sender":{"key":"jeffhost@microsoft.com","avatar":"https://avatars.githubusercontent.com/u/7493832?v=4"},"body":"Update --porcelain argument to take optional version parameter\nto allow multiple porcelain formats to be supported in the future.\n\nThe token \"v1\" is the default value and indicates the traditional\nporcelain format.\n\nSigned-off-by: Jeff Hostetler <jeffhost@microsoft.com>\n---\n Documentation/git-status.txt |  7 +++++--\n builtin/commit.c             | 21 ++++++++++++++++++---\n t/t7060-wtstatus.sh          | 21 +++++++++++++++++++++\n 3 files changed, 44 insertions(+), 5 deletions(-)\n\ndiff --git a/Documentation/git-status.txt b/Documentation/git-status.txt\nindex e1e8f57..6b1454b 100644\n--- a/Documentation/git-status.txt\n+++ b/Documentation/git-status.txt\n@@ -32,11 +32,14 @@ OPTIONS\n --branch::\n \tShow the branch and tracking info even in short-format.\n \n---porcelain::\n+--porcelain[=<version>]::\n \tGive the output in an easy-to-parse format for scripts.\n \tThis is similar to the short output, but will remain stable\n \tacross Git versions and regardless of user configuration. See\n \tbelow for details.\n++\n+The version parameter is used to specify the format version.\n+This is optional and defaults to the original version 'v1' format.\n \n --long::\n \tGive the output in the long-format. This is the default.\n@@ -96,7 +99,7 @@ configuration variable documented in linkgit:git-config[1].\n \n -z::\n \tTerminate entries with NUL, instead of LF.  This implies\n-\tthe `--porcelain` output format if no other format is given.\n+\tthe `--porcelain=v1` output format if no other format is given.\n \n --column[=<options>]::\n --no-column::\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex a792deb..e6bbb12 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -144,6 +144,21 @@ static struct strbuf message = STRBUF_INIT;\n \n static enum wt_status_format status_format = STATUS_FORMAT_UNSPECIFIED;\n \n+static int opt_parse_porcelain(const struct option *opt, const char *arg, int unset)\n+{\n+\tenum wt_status_format *value = (enum wt_status_format *)opt->value;\n+\tif (unset)\n+\t\t*value = STATUS_FORMAT_NONE;\n+\telse if (!arg)\n+\t\t*value = STATUS_FORMAT_PORCELAIN;\n+\telse if (!strcmp(arg, \"v1\"))\n+\t\t*value = STATUS_FORMAT_PORCELAIN;\n+\telse\n+\t\tdie(\"unsupported porcelain version\");\n+\n+\treturn 0;\n+}\n+\n static int opt_parse_m(const struct option *opt, const char *arg, int unset)\n {\n \tstruct strbuf *buf = opt->value;\n@@ -1316,9 +1331,9 @@ int cmd_status(int argc, const char **argv, const char *prefix)\n \t\t\t    N_(\"show status concisely\"), STATUS_FORMAT_SHORT),\n \t\tOPT_BOOL('b', \"branch\", &s.show_branch,\n \t\t\t N_(\"show branch information\")),\n-\t\tOPT_SET_INT(0, \"porcelain\", &status_format,\n-\t\t\t    N_(\"machine-readable output\"),\n-\t\t\t    STATUS_FORMAT_PORCELAIN),\n+\t\t{ OPTION_CALLBACK, 0, \"porcelain\", &status_format,\n+\t\t  N_(\"version\"), N_(\"machine-readable output\"),\n+\t\t  PARSE_OPT_OPTARG, opt_parse_porcelain },\n \t\tOPT_SET_INT(0, \"long\", &status_format,\n \t\t\t    N_(\"show status in long format (default)\"),\n \t\t\t    STATUS_FORMAT_LONG),\ndiff --git a/t/t7060-wtstatus.sh b/t/t7060-wtstatus.sh\nindex 44bf1d8..00e0ceb 100755\n--- a/t/t7060-wtstatus.sh\n+++ b/t/t7060-wtstatus.sh\n@@ -228,4 +228,25 @@ test_expect_success 'status --branch with detached HEAD' '\n \ttest_i18ncmp expected actual\n '\n \n+## Duplicate the above test and verify --porcelain=v1 arg parsing.\n+test_expect_success 'status --porcelain=v1 --branch with detached HEAD' '\n+\tgit reset --hard &&\n+\tgit checkout master^0 &&\n+\tgit status --branch --porcelain=v1 >actual &&\n+\tcat >expected <<-EOF &&\n+\t## HEAD (no branch)\n+\t?? .gitconfig\n+\t?? actual\n+\t?? expect\n+\t?? expected\n+\t?? mdconflict/\n+\tEOF\n+\ttest_i18ncmp expected actual\n+'\n+\n+## Verify parser error on invalid --porcelain argument.\n+test_expect_success 'status --porcelain=bogus' '\n+\ttest_must_fail git status --porcelain=bogus\n+'\n+\n test_done\n-- \n2.8.0.rc4.17.gac42084.dirty\n\n"},{"id":"292125","messageId":"1469474750-49075-6-git-send-email-jeffhost@microsoft.com","threadId":"42922","inReplyTo":"1469474750-49075-1-git-send-email-jeffhost@microsoft.com","subject":"[PATCH v2 5/8] status: print per-file porcelain v2 status data","fromName":"Jeff Hostetler","fromEmail":"jeffhost@microsoft.com","sentAt":"2016-07-25T19:25:47Z","receivedAt":"2016-07-25T19:29:10Z","isPatch":true,"sender":{"key":"jeffhost@microsoft.com","avatar":"https://avatars.githubusercontent.com/u/7493832?v=4"},"body":"Print per-file information in porcelain v2 format.\n\nSigned-off-by: Jeff Hostetler <jeffhost@microsoft.com>\n---\n wt-status.c | 285 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-\n 1 file changed, 284 insertions(+), 1 deletion(-)\n\ndiff --git a/wt-status.c b/wt-status.c\nindex 54aedc1..ffdfe11 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -1864,6 +1864,8 @@ static void wt_porcelain_print(struct wt_status *s)\n \twt_shortstatus_print(s);\n }\n \n+static void wt_porcelain_v2_print(struct wt_status *s);\n+\n void wt_status_print(struct wt_status *s)\n {\n \tswitch (s->status_format) {\n@@ -1874,7 +1876,7 @@ void wt_status_print(struct wt_status *s)\n \t\twt_porcelain_print(s);\n \t\tbreak;\n \tcase STATUS_FORMAT_PORCELAIN_V2:\n-\t\t/* TODO */\n+\t\twt_porcelain_v2_print(s);\n \t\tbreak;\n \tcase STATUS_FORMAT_UNSPECIFIED:\n \t\tdie(\"BUG: finalize_deferred_config() should have been called\");\n@@ -1885,3 +1887,284 @@ void wt_status_print(struct wt_status *s)\n \t\tbreak;\n \t}\n }\n+\n+/*\n+ * Convert various submodule status values into a\n+ * string of characters in the buffer provided.\n+ */\n+static void wt_porcelain_v2_submodule_state(\n+\tstruct wt_status_change_data *d,\n+\tchar sub[5])\n+{\n+\tif (S_ISGITLINK(d->aux.porcelain_v2.mode_head) ||\n+\t\tS_ISGITLINK(d->aux.porcelain_v2.mode_index) ||\n+\t\tS_ISGITLINK(d->aux.porcelain_v2.mode_worktree)) {\n+\t\tsub[0] = 'S';\n+\t\tsub[1] = d->new_submodule_commits ? 'C' : '.';\n+\t\tsub[2] = (d->dirty_submodule & DIRTY_SUBMODULE_MODIFIED) ? 'M' : '.';\n+\t\tsub[3] = (d->dirty_submodule & DIRTY_SUBMODULE_UNTRACKED) ? 'U' : '.';\n+\t} else {\n+\t\tsub[0] = 'N';\n+\t\tsub[1] = '.';\n+\t\tsub[2] = '.';\n+\t\tsub[3] = '.';\n+\t}\n+\tsub[4] = 0;\n+}\n+\n+/*\n+ * Fix-up changed entries before we print them.\n+ */\n+static void wt_porcelain_v2_fix_up_changed(\n+\tstruct string_list_item *it,\n+\tstruct wt_status *s)\n+{\n+\tstruct wt_status_change_data *d = it->util;\n+\n+\tif (!d->index_status) {\n+\t\t/*\n+\t\t * This entry is unchanged in the index (relative to the head).\n+\t\t * Therefore, the collect_updated_cb was never called for this\n+\t\t * entry (during the head-vs-index scan) and so the head column\n+\t\t * fields were never set.\n+\t\t *\n+\t\t * We must have data for the index column (from the\n+\t\t * index-vs-worktree scan (otherwise, this entry should not be\n+\t\t * in the list of changes)).\n+\t\t *\n+\t\t * Copy index column fields to the head column, so that our\n+\t\t * output looks complete.\n+\t\t */\n+\t\tassert(d->aux.porcelain_v2.mode_head == 0);\n+\t\td->aux.porcelain_v2.mode_head = d->aux.porcelain_v2.mode_index;\n+\t\toidcpy(&d->aux.porcelain_v2.oid_head, &d->aux.porcelain_v2.oid_index);\n+\t}\n+\n+\tif (!d->worktree_status) {\n+\t\t/*\n+\t\t * This entry is unchanged in the worktree (relative to the index).\n+\t\t * Therefore, the collect_changed_cb was never called for this entry\n+\t\t * (during the index-vs-worktree scan) and so the worktree column\n+\t\t * fields were never set.\n+\t\t *\n+\t\t * We must have data for the index column (from the head-vs-index\n+\t\t * scan).\n+\t\t *\n+\t\t * Copy the index column fields to the worktree column so that\n+\t\t * our output looks complete.\n+\t\t *\n+\t\t * Note that we only have a mode field in the worktree column\n+\t\t * because the scan code tries really hard to not have to compute it.\n+\t\t */\n+\t\tassert(d->aux.porcelain_v2.mode_worktree == 0);\n+\t\td->aux.porcelain_v2.mode_worktree = d->aux.porcelain_v2.mode_index;\n+\t}\n+}\n+\n+/*\n+ * Print porcelain v2 info for tracked entries with changes.\n+ */\n+static void wt_porcelain_v2_print_changed_entry(\n+\tstruct string_list_item *it,\n+\tstruct wt_status *s)\n+{\n+\tstruct wt_status_change_data *d = it->util;\n+\tstruct strbuf buf_current = STRBUF_INIT;\n+\tstruct strbuf buf_rename_src = STRBUF_INIT;\n+\tconst char *path_current = NULL;\n+\tconst char *path_rename_src = NULL;\n+\tchar key[3];\n+\tchar submodule_token[5];\n+\tchar changed_prefix = 'c';\n+\tchar sep_char, eol_char;\n+\n+\twt_porcelain_v2_fix_up_changed(it, s);\n+\twt_porcelain_v2_submodule_state(d, submodule_token);\n+\n+\tkey[0] = d->index_status ? d->index_status : '.';\n+\tkey[1] = d->worktree_status ? d->worktree_status : '.';\n+\tkey[2] = 0;\n+\n+\tif (s->null_termination) {\n+\t\t/*\n+\t\t * In -z mode, we DO NOT C-Quote pathnames.  Current path is ALWAYS first.\n+\t\t * A single NUL character separates them.\n+\t\t */\n+\t\tsep_char = '\\0';\n+\t\teol_char = '\\0';\n+\t\tpath_current = it->string;\n+\t\tpath_rename_src = d->head_path;\n+\t} else {\n+\t\t/*\n+\t\t * Path(s) are C-Quoted if necessary. Current path is ALWAYS first.\n+\t\t * The rename source path is only present when necessary.\n+\t\t * A single TAB separates them (because paths can contain spaces\n+\t\t * which are not escaped and C-Quoting does escape TAB characters).\n+\t\t */\n+\t\tsep_char = '\\t';\n+\t\teol_char = '\\n';\n+\t\tpath_current = quote_path(it->string, s->prefix, &buf_current);\n+\t\tif (d->head_path)\n+\t\t\tpath_rename_src = quote_path(d->head_path, s->prefix, &buf_rename_src);\n+\t}\n+\n+\tfprintf(s->fp, \"%c %s %s %06o %06o %06o %s %s R%d %s\",\n+\t\t\tchanged_prefix, key, submodule_token,\n+\t\t\td->aux.porcelain_v2.mode_head,\n+\t\t\td->aux.porcelain_v2.mode_index,\n+\t\t\td->aux.porcelain_v2.mode_worktree,\n+\t\t\toid_to_hex(&d->aux.porcelain_v2.oid_head),\n+\t\t\toid_to_hex(&d->aux.porcelain_v2.oid_index),\n+\t\t\td->aux.porcelain_v2.rename_score,\n+\t\t\tpath_current);\n+\tif (path_rename_src)\n+\t\tfprintf(s->fp, \"%c%s\", sep_char, path_rename_src);\n+\tfprintf(s->fp, \"%c\", eol_char);\n+\t\n+\tstrbuf_release(&buf_current);\n+\tstrbuf_release(&buf_rename_src);\n+}\n+\n+/*\n+ * Print porcelain v2 status info for unmerged entries.\n+ */\n+static void wt_porcelain_v2_print_unmerged_entry(\n+\tstruct string_list_item *it,\n+\tstruct wt_status *s)\n+{\n+\tstruct wt_status_change_data *d = it->util;\n+\tconst struct cache_entry *ce;\n+\tstruct strbuf buf_current = STRBUF_INIT;\n+\tconst char *path_current = NULL;\n+\tint pos, stage, sum;\n+\tstruct {\n+\t\tint mode;\n+\t\tstruct object_id oid;\n+\t} stages[3];\n+\tchar *key;\n+\tchar submodule_token[5];\n+\tchar unmerged_prefix = 'u';\n+\tchar eol_char = s->null_termination ? '\\0' : '\\n';\n+\n+\twt_porcelain_v2_submodule_state(d, submodule_token);\n+\n+\tswitch (d->stagemask) {\n+\tcase 1: key = \"DD\"; break; /* both deleted */\n+\tcase 2: key = \"AU\"; break; /* added by us */\n+\tcase 3: key = \"UD\"; break; /* deleted by them */\n+\tcase 4: key = \"UA\"; break; /* added by them */\n+\tcase 5: key = \"DU\"; break; /* deleted by us */\n+\tcase 6: key = \"AA\"; break; /* both added */\n+\tcase 7: key = \"UU\"; break; /* both modified */\n+\t}\n+\n+\t/*\n+\t * Disregard d.aux.porcelain_v2 data that we accumulated\n+\t * for the head and index columns during the scans and\n+\t * replace with the actual stage data.\n+\t *\n+\t * Note that this is a last-one-wins for each the individual\n+\t * stage [123] columns in the event of multiple cache rows\n+\t * for a stage.\n+\t */\n+\tmemset(stages, 0, sizeof(stages));\n+\tsum = 0;\n+\tpos = cache_name_pos(it->string, strlen(it->string));\n+\tassert(pos < 0);\n+\tpos = -pos-1;\n+\twhile (pos < active_nr) {\n+\t\tce = active_cache[pos++];\n+\t\tstage = ce_stage(ce);\n+\t\tif (strcmp(ce->name, it->string) || !stage)\n+\t\t\tbreak;\n+\t\tstages[stage - 1].mode = ce->ce_mode;\n+\t\thashcpy(stages[stage - 1].oid.hash, ce->sha1);\n+\t\tsum++;\n+\t}\n+\tif (!sum)\n+\t\tdie(\"BUG: unmerged entry without any stages\");\n+\n+\tif (s->null_termination)\n+\t\tpath_current = it->string;\n+\telse\n+\t\tpath_current = quote_path(it->string, s->prefix, &buf_current);\n+\n+\tfprintf(s->fp, \"%c %s %s %06o %06o %06o %06o %s %s %s %s%c\",\n+\t\t\tunmerged_prefix, key, submodule_token,\n+\t\t\tstages[0].mode, /* stage 1 */\n+\t\t\tstages[1].mode, /* stage 2 */\n+\t\t\tstages[2].mode, /* stage 3 */\n+\t\t\td->aux.porcelain_v2.mode_worktree,\n+\t\t\toid_to_hex(&stages[0].oid), /* stage 1 */\n+\t\t\toid_to_hex(&stages[1].oid), /* stage 2 */\n+\t\t\toid_to_hex(&stages[2].oid), /* stage 3 */\n+\t\t\tpath_current,\n+\t\t\teol_char);\n+\n+\tstrbuf_release(&buf_current);\n+}\n+\n+/*\n+ * Print porcelain V2 status info for untracked and ignored entries.\n+ */\n+static void wt_porcelain_v2_print_other(\n+\tstruct string_list_item *it,\n+\tstruct wt_status *s,\n+\tchar prefix)\n+{\n+\tstruct strbuf buf = STRBUF_INIT;\n+\tconst char *path;\n+\tchar eol_char;\n+\n+\tif (s->null_termination) {\n+\t\tpath = it->string;\n+\t\teol_char = '\\0';\n+\t} else {\n+\t\tpath = quote_path(it->string, s->prefix, &buf);\n+\t\teol_char = '\\n';\n+\t}\n+\n+\tfprintf(s->fp, \"%c %s%c\", prefix, path, eol_char);\n+\n+\tstrbuf_release(&buf);\n+}\n+\n+/*\n+ * Print porcelain V2 status.\n+ *\n+ * [<v2_changed_items>]*\n+ * [<v2_unmerged_items>]*\n+ * [<v2_untracked_items>]*\n+ * [<v2_ignored_items>]*\n+ *\n+ */\n+void wt_porcelain_v2_print(struct wt_status *s)\n+{\n+\tstruct wt_status_change_data *d;\n+\tstruct string_list_item *it;\n+\tint i;\n+\n+\tfor (i = 0; i < s->change.nr; i++) {\n+\t\tit = &(s->change.items[i]);\n+\t\td = it->util;\n+\t\tif (!d->stagemask)\n+\t\t\twt_porcelain_v2_print_changed_entry(it, s);\n+\t}\n+\n+\tfor (i = 0; i < s->change.nr; i++) {\n+\t\tit = &(s->change.items[i]);\n+\t\td = it->util;\n+\t\tif (d->stagemask)\n+\t\t\twt_porcelain_v2_print_unmerged_entry(it, s);\n+\t}\n+\n+\tfor (i = 0; i < s->untracked.nr; i++) {\n+\t\tit = &(s->untracked.items[i]);\n+\t\twt_porcelain_v2_print_other(it, s, '?');\n+\t}\n+\n+\tfor (i = 0; i < s->ignored.nr; i++) {\n+\t\tit = &(s->ignored.items[i]);\n+\t\twt_porcelain_v2_print_other(it, s, '!');\n+\t}\n+}\n-- \n2.8.0.rc4.17.gac42084.dirty\n\n"},{"id":"292126","messageId":"1469474750-49075-8-git-send-email-jeffhost@microsoft.com","threadId":"42922","inReplyTo":"1469474750-49075-1-git-send-email-jeffhost@microsoft.com","subject":"[PATCH v2 7/8] status: update git-status.txt for --porcelain=v2","fromName":"Jeff Hostetler","fromEmail":"jeffhost@microsoft.com","sentAt":"2016-07-25T19:25:49Z","receivedAt":"2016-07-25T19:29:11Z","isPatch":true,"sender":{"key":"jeffhost@microsoft.com","avatar":"https://avatars.githubusercontent.com/u/7493832?v=4"},"body":"Update status manpage to include information about\nporcelain v2 format.\n\nSigned-off-by: Jeff Hostetler <jeffhost@microsoft.com>\n---\n Documentation/git-status.txt | 83 ++++++++++++++++++++++++++++++++++++++++++--\n 1 file changed, 80 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/git-status.txt b/Documentation/git-status.txt\nindex 6b1454b..e64b1b8 100644\n--- a/Documentation/git-status.txt\n+++ b/Documentation/git-status.txt\n@@ -185,10 +185,10 @@ If -b is used the short-format status is preceded by a line\n \n ## branchname tracking info\n \n-Porcelain Format\n-~~~~~~~~~~~~~~~~\n+Porcelain Format Version 1\n+~~~~~~~~~~~~~~~~~~~~~~~~~~\n \n-The porcelain format is similar to the short format, but is guaranteed\n+Version 1 porcelain format is similar to the short format, but is guaranteed\n not to change in a backwards-incompatible way between Git versions or\n based on user configuration. This makes it ideal for parsing by scripts.\n The description of the short format above also describes the porcelain\n@@ -210,6 +210,83 @@ field from the first filename).  Third, filenames containing special\n characters are not specially formatted; no quoting or\n backslash-escaping is performed.\n \n+Porcelain Format Version 2\n+~~~~~~~~~~~~~~~~~~~~~~~~~~\n+\n+Version 2 format adds more detailed information about the state of\n+the worktree and the changed items.\n+\n+If `--branch` is given, a header line showing branch tracking information\n+is printed.  This line begins with \"### branch: \".  Fields are separated\n+by a single space.\n+\n+    Field                    Meaning\n+    --------------------------------------------------------\n+    <sha> | (initial)        Current commit\n+    <branch> | (detached)    Current branch\n+    <upstream>               Upstream branch, if set\n+    +<ahead>                 Ahead count, if upstream present\n+    -<behind>                Behind count, if upstream present\n+    --------------------------------------------------------\n+\n+A series of lines are then displayed for the tracked entries.\n+Ordinary changed entries have the following format; the first\n+character is a 'c' to distinguish them from unmerged entries.\n+\n+    c <xy> <sub> <mH> <mI> <mW> <hH> <hI> R<nr> <path>[\\t<pathSrc>]\n+\n+    Field       Meaning\n+    --------------------------------------------------------\n+    <xy>        A 2 character field containing the staged and\n+                unstaged XY values described in the short format,\n+                with unchanged indicated by a \".\" rather than\n+                a space.\n+    <sub>       A 4 character field describing the submodule state.\n+                \"N...\" when the entry is not a submodule.\n+                \"S<c><m><u>\" when the entry is a submodule.\n+                <c> is \"C\" if the commit changed; otherwise \".\".\n+                <m> is \"M\" if it has tracked changes; otherwise \".\".\n+                <u> is \"U\" if there are untracked changes; otherwise \".\".\n+    <m*>        The 6 character octal file modes for head, index,\n+                and worktree.\n+    <h*>        The head and index SHA1 values.\n+    R<nr>       The rename percentage score.\n+    <path>      The current pathname. It is C-Quoted if it contains\n+                special control characters.\n+    <pathSrc>   The original path. This is only present for staged renames.\n+                It is C-Quoted if necessary.\n+    --------------------------------------------------------\n+\n+Unmerged entries have the following format; the first character is\n+a \"u\" to distinguish from ordinary changed entries.\n+\n+    u <xy> <sub> <m1> <m2> <m3> <h1> <h2> <h3> <path>\n+\n+    Field       Meaning\n+    --------------------------------------------------------\n+    <xy>        A 2 character field describing the conflict type\n+                as described in the short format.\n+    <sub>       A 4 character field describing the submodule state\n+                as described above.\n+    <m*>        The 6 character octal file modes for the stage 1,\n+                stage 2, stage 3, and worktree.\n+                For regular entries, these are the head, index, and\n+                worktree modes; the fourth is zero.\n+    <h*>        The stage 1, stage 2, and stage 3 SHA1 values.\n+    <path>      The current pathname. It is C-Quoted if necessary.\n+    --------------------------------------------------------\n+\n+A series of lines are then displayed for untracked and ignored entries.\n+\n+    <x> <path>\n+\n+Where <x> is \"?\" for untracked entries and \"!\" for ignored entries.\n+\n+When the `-z` option is given, a NUL (zero) byte follows each pathname;\n+serving as both a separator and line termination. No pathname quoting\n+or backslash escaping is performed. All fields are output in the same\n+order.\n+\n CONFIGURATION\n -------------\n \n-- \n2.8.0.rc4.17.gac42084.dirty\n\n"},{"id":"292127","messageId":"1469474750-49075-9-git-send-email-jeffhost@microsoft.com","threadId":"42922","inReplyTo":"1469474750-49075-1-git-send-email-jeffhost@microsoft.com","subject":"[PATCH v2 8/8] status: tests for --porcelain=v2","fromName":"Jeff Hostetler","fromEmail":"jeffhost@microsoft.com","sentAt":"2016-07-25T19:25:50Z","receivedAt":"2016-07-25T19:29:13Z","isPatch":true,"sender":{"key":"jeffhost@microsoft.com","avatar":"https://avatars.githubusercontent.com/u/7493832?v=4"},"body":"Unit tests for porcelain v2 status format.\n\nSigned-off-by: Jeff Hostetler <jeffhost@microsoft.com>\n---\n t/t7064-wtstatus-pv2.sh | 542 ++++++++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 542 insertions(+)\n create mode 100755 t/t7064-wtstatus-pv2.sh\n\ndiff --git a/t/t7064-wtstatus-pv2.sh b/t/t7064-wtstatus-pv2.sh\nnew file mode 100755\nindex 0000000..7a7f777\n--- /dev/null\n+++ b/t/t7064-wtstatus-pv2.sh\n@@ -0,0 +1,542 @@\n+#!/bin/sh\n+\n+test_description='git status --porcelain=v2\n+\n+This test exercises porcelain V2 output for git status.'\n+\n+\n+. ./test-lib.sh\n+\n+test_expect_success setup '\n+\ttest_tick &&\n+\tgit config --local core.autocrlf false &&\n+\techo x >file_x &&\n+\techo y >file_y &&\n+\techo z >file_z &&\n+\tmkdir dir1 &&\n+\techo a >dir1/file_a &&\n+\techo b >dir1/file_b\n+'\n+\n+\n+##################################################################\n+## Confirm VVP output prior to initial commit.\n+##################################################################\n+\n+test_expect_success pre_initial_commit_0 '\n+\tcat >expected <<-EOF &&\n+\t## branch: (initial) master\n+\t? actual\n+\t? dir1/\n+\t? expected\n+\t? file_x\n+\t? file_y\n+\t? file_z\n+\tEOF\n+\n+\tgit status --porcelain=v2 --branch --ignored --untracked-files=normal >actual &&\n+\ttest_cmp expected actual\n+'\n+\n+\n+test_expect_success pre_initial_commit_1 '\n+\tgit add file_x file_y file_z dir1 &&\n+\tSHA_A=`git hash-object -t blob -- dir1/file_a` &&\n+\tSHA_B=`git hash-object -t blob -- dir1/file_b` &&\n+\tSHA_X=`git hash-object -t blob -- file_x` &&\n+\tSHA_Y=`git hash-object -t blob -- file_y` &&\n+\tSHA_Z=`git hash-object -t blob -- file_z` &&\n+\tSHA_ZERO=0000000000000000000000000000000000000000 &&\n+\n+\tcat >expected <<-EOF &&\n+\t## branch: (initial) master\n+\tc A. N... 000000 100644 100644 $SHA_ZERO $SHA_A R0 dir1/file_a\n+\tc A. N... 000000 100644 100644 $SHA_ZERO $SHA_B R0 dir1/file_b\n+\tc A. N... 000000 100644 100644 $SHA_ZERO $SHA_X R0 file_x\n+\tc A. N... 000000 100644 100644 $SHA_ZERO $SHA_Y R0 file_y\n+\tc A. N... 000000 100644 100644 $SHA_ZERO $SHA_Z R0 file_z\n+\t? actual\n+\t? expected\n+\tEOF\n+\n+\tgit status --porcelain=v2 --branch --ignored --untracked-files=all >actual &&\n+\ttest_cmp expected actual\n+'\n+\n+## Try -z on the above\n+test_expect_success pre_initial_commit_2 '\n+\tcat >expected.lf <<-EOF &&\n+\t## branch: (initial) master\n+\tc A. N... 000000 100644 100644 $SHA_ZERO $SHA_A R0 dir1/file_a\n+\tc A. N... 000000 100644 100644 $SHA_ZERO $SHA_B R0 dir1/file_b\n+\tc A. N... 000000 100644 100644 $SHA_ZERO $SHA_X R0 file_x\n+\tc A. N... 000000 100644 100644 $SHA_ZERO $SHA_Y R0 file_y\n+\tc A. N... 000000 100644 100644 $SHA_ZERO $SHA_Z R0 file_z\n+\t? actual\n+\t? expected\n+\tEOF\n+\tperl -pe y/\\\\012/\\\\000/ <expected.lf >expected &&\n+\trm expected.lf &&\n+\n+\tgit status -z --porcelain=v2 --branch --ignored --untracked-files=all >actual &&\n+\ttest_cmp expected actual\n+'\n+\n+##################################################################\n+## Create first commit. Confirm commit sha in new track header.\n+## Then make some changes on top of it.\n+##################################################################\n+\n+test_expect_success initial_commit_0 '\n+\tgit commit -m initial &&\n+\tH0=`git rev-parse HEAD` &&\n+\tcat >expected <<-EOF &&\n+\t## branch: $H0 master\n+\t? actual\n+\t? expected\n+\tEOF\n+\n+\tgit status --porcelain=v2 --branch --ignored --untracked-files=all >actual &&\n+\ttest_cmp expected actual\n+'\n+\n+\n+test_expect_success initial_commit_1 '\n+\techo x >>file_x &&\n+\tSHA_X1=`git hash-object -t blob -- file_x` &&\n+\trm file_z &&\n+\tH0=`git rev-parse HEAD` &&\n+\n+\tcat >expected <<-EOF &&\n+\t## branch: $H0 master\n+\tc .M N... 100644 100644 100644 $SHA_X $SHA_X R0 file_x\n+\tc .D N... 100644 100644 000000 $SHA_Z $SHA_Z R0 file_z\n+\t? actual\n+\t? expected\n+\tEOF\n+\n+\tgit status --porcelain=v2 --branch --ignored --untracked-files=all >actual &&\n+\ttest_cmp expected actual\n+'\n+\n+\n+test_expect_success initial_commit_2 '\n+\tgit add file_x &&\n+\tgit rm file_z &&\n+\tH0=`git rev-parse HEAD` &&\n+\n+\tcat >expected <<-EOF &&\n+\t## branch: $H0 master\n+\tc M. N... 100644 100644 100644 $SHA_X $SHA_X1 R0 file_x\n+\tc D. N... 100644 000000 000000 $SHA_Z $SHA_ZERO R0 file_z\n+\t? actual\n+\t? expected\n+\tEOF\n+\n+\tgit status --porcelain=v2 --branch --ignored --untracked-files=all >actual &&\n+\ttest_cmp expected actual\n+'\n+\n+\n+test_expect_success initial_commit_3 '\n+\tgit mv file_y renamed_y &&\n+\tH0=`git rev-parse HEAD` &&\n+\n+\tcat >expected.q <<-EOF &&\n+\t## branch: $H0 master\n+\tc M. N... 100644 100644 100644 $SHA_X $SHA_X1 R0 file_x\n+\tc D. N... 100644 000000 000000 $SHA_Z $SHA_ZERO R0 file_z\n+\tc R. N... 100644 100644 100644 $SHA_Y $SHA_Y R100 renamed_yQfile_y\n+\t? actual\n+\t? expected\n+\tEOF\n+\tq_to_tab <expected.q >expected &&\n+\trm expected.q &&\n+\n+\tgit status --porcelain=v2 --branch --ignored --untracked-files=all >actual &&\n+\ttest_cmp expected actual\n+'\n+\n+\n+##################################################################\n+## Create second commit.\n+##################################################################\n+\n+test_expect_success second_commit_0 '\n+\tgit commit -m second &&\n+\tH1=`git rev-parse HEAD` &&\n+\n+\tcat >expected <<-EOF &&\n+\t## branch: $H1 master\n+\t? actual\n+\t? expected\n+\tEOF\n+\n+\tgit status --porcelain=v2 --branch --ignored --untracked-files=all >actual &&\n+\ttest_cmp expected actual\n+'\n+\n+\n+##################################################################\n+## Ignore a file\n+##################################################################\n+\n+test_expect_success ignore_file_0 '\n+\techo x.ign >.gitignore &&\n+\techo \"ignore me\" >x.ign &&\n+\tH1=`git rev-parse HEAD` &&\n+\n+\tcat >expected <<-EOF &&\n+\t## branch: $H1 master\n+\t? .gitignore\n+\t? actual\n+\t? expected\n+\t! x.ign\n+\tEOF\n+\n+\tgit status --porcelain=v2 --branch --ignored --untracked-files=all >actual &&\n+\trm x.ign &&\n+\trm .gitignore &&\n+\ttest_cmp expected actual\n+'\n+\n+\n+##################################################################\n+## Create some conflicts.\n+##################################################################\n+\n+test_expect_success conflict_AA '\n+\tgit branch AA_A master &&\n+\tgit checkout AA_A &&\n+\techo \"Branch AA_A\" >conflict.txt &&\n+\tSHA_AA_A=`git hash-object -t blob -- conflict.txt` &&\n+\tgit add conflict.txt &&\n+\tgit commit -m \"branch aa_a\" &&\n+\n+\tgit branch AA_B master &&\n+\tgit checkout AA_B &&\n+\techo \"Branch AA_B\" >conflict.txt &&\n+\tSHA_AA_B=`git hash-object -t blob -- conflict.txt` &&\n+\tgit add conflict.txt &&\n+\tgit commit -m \"branch aa_b\" &&\n+\n+\tgit branch AA_M AA_B &&\n+\tgit checkout AA_M &&\n+\ttest_must_fail git merge AA_A &&\n+\n+\tHM=`git rev-parse HEAD` &&\n+\n+\tcat >expected <<-EOF &&\n+\t## branch: $HM AA_M\n+\tu AA N... 000000 100644 100644 100644 $SHA_ZERO $SHA_AA_B $SHA_AA_A conflict.txt\n+\t? actual\n+\t? expected\n+\tEOF\n+\n+\tgit status --porcelain=v2 --branch --ignored --untracked-files=all >actual &&\n+\tgit reset --hard &&\n+\ttest_cmp expected actual\n+'\n+\n+\n+test_expect_success conflict_UU '\n+\tgit branch UU_ANC master &&\n+\tgit checkout UU_ANC &&\n+\techo \"Ancestor\" >conflict.txt &&\n+\tSHA_UU_ANC=`git hash-object -t blob -- conflict.txt` &&\n+\tgit add conflict.txt &&\n+\tgit commit -m \"UU_ANC\" &&\n+\n+\tgit branch UU_A UU_ANC &&\n+\tgit checkout UU_A &&\n+\techo \"Branch UU_A\" >conflict.txt &&\n+\tSHA_UU_A=`git hash-object -t blob -- conflict.txt` &&\n+\tgit add conflict.txt &&\n+\tgit commit -m \"branch uu_a\" &&\n+\n+\tgit branch UU_B UU_ANC &&\n+\tgit checkout UU_B &&\n+\techo \"Branch UU_B\" >conflict.txt &&\n+\tSHA_UU_B=`git hash-object -t blob -- conflict.txt` &&\n+\tgit add conflict.txt &&\n+\tgit commit -m \"branch uu_b\" &&\n+\n+\tgit branch UU_M UU_B &&\n+\tgit checkout UU_M &&\n+\ttest_must_fail git merge UU_A &&\n+\n+\tHM=`git rev-parse HEAD` &&\n+\n+\tcat >expected <<-EOF &&\n+\t## branch: $HM UU_M\n+\tu UU N... 100644 100644 100644 100644 $SHA_UU_ANC $SHA_UU_B $SHA_UU_A conflict.txt\n+\t? actual\n+\t? expected\n+\tEOF\n+\n+\tgit status --porcelain=v2 --branch --ignored --untracked-files=all >actual &&\n+\tgit reset --hard &&\n+\ttest_cmp expected actual\n+'\n+\n+\n+##################################################################\n+## Test upstream fields in branch header\n+##################################################################\n+\n+test_expect_success 'upstream_fields_0' '\n+\tgit checkout master &&\n+\tgit clone . sub_repo &&\n+\t(\n+\t\t## Confirm local master tracks remote master.\n+\t\tcd sub_repo &&\n+\t\tHUF=`git rev-parse HEAD` &&\n+\n+\t\tcat >expected <<-EOF &&\n+\t\t## branch: $HUF master origin/master +0 -0\n+\t\t? actual\n+\t\t? expected\n+\t\tEOF\n+\n+\t\tgit status --porcelain=v2 --branch --ignored --untracked-files=all >actual &&\n+\t\ttest_cmp expected actual &&\n+\n+\t\t## Test ahead/behind.\n+\t\techo xyz >file_xyz &&\n+\t\tgit add file_xyz &&\n+\t\tgit commit -m xyz &&\n+\n+\t\tHUF=`git rev-parse HEAD` &&\n+\n+\t\tcat >expected <<-EOF &&\n+\t\t## branch: $HUF master origin/master +1 -0\n+\t\t? actual\n+\t\t? expected\n+\t\tEOF\n+\n+\t\tgit status --porcelain=v2 --branch --ignored --untracked-files=all >actual &&\n+\t\ttest_cmp expected actual &&\n+\n+\t\t## Test upstream-gone case. Fake this by pointing origin/master at\n+\t\t## a non-existing commit.\n+\t\tOLD=`git rev-parse origin/master` &&\n+\t\tNEW=$SHA_ZERO &&\n+\t\tmv .git/packed-refs .git/old-packed-refs &&\n+\t\tsed \"s/$OLD/$NEW/g\" <.git/old-packed-refs >.git/packed-refs &&\n+\n+\t\tHUF=`git rev-parse HEAD` &&\n+\n+\t\tcat >expected <<-EOF &&\n+\t\t## branch: $HUF master origin/master\n+\t\t? actual\n+\t\t? expected\n+\t\tEOF\n+\n+\t\tgit status --porcelain=v2 --branch --ignored --untracked-files=all >actual &&\n+\t\ttest_cmp expected actual\n+\t) &&\n+\trm -rf sub_repo\n+'\n+\n+\n+##################################################################\n+## Test submodule status flags.\n+##################################################################\n+\n+test_expect_success 'submodule_flags_0' '\n+\tgit checkout master &&\n+\tgit clone . sub_repo &&\n+\tgit clone . super_repo &&\n+\t(\tcd super_repo &&\n+\t\tgit submodule add ../sub_repo sub1 &&\n+\n+\t\t## Confirm stage/add of clean submodule.\n+\t\tHMOD=`git hash-object -t blob -- .gitmodules` &&\n+\t\tHSUP=`git rev-parse HEAD` &&\n+\t\tHSUB=$HSUP &&\n+\n+\t\tcat >expected <<-EOF &&\n+\t\t## branch: $HSUP master origin/master +0 -0\n+\t\tc A. N... 000000 100644 100644 $SHA_ZERO $HMOD R0 .gitmodules\n+\t\tc A. S... 000000 160000 160000 $SHA_ZERO $HSUB R0 sub1\n+\t\t? actual\n+\t\t? expected\n+\t\tEOF\n+\n+\t\tgit status --porcelain=v2 --branch --ignored --untracked-files=all >actual &&\n+\t\ttest_cmp expected actual\n+\t)\n+'\n+\n+test_expect_success 'submodule_flags_1' '\n+\t(\tcd super_repo &&\n+\t\t## Make some untracked dirt in the submodule.\n+\t\t(\tcd sub1 &&\n+\t\t\techo \"dirt\" >file_in_sub\n+\t\t) &&\n+\n+\t\tHMOD=`git hash-object -t blob -- .gitmodules` &&\n+\t\tHSUP=`git rev-parse HEAD` &&\n+\t\tHSUB=$HSUP &&\n+\n+\t\tcat >expected <<-EOF &&\n+\t\t## branch: $HSUP master origin/master +0 -0\n+\t\tc A. N... 000000 100644 100644 $SHA_ZERO $HMOD R0 .gitmodules\n+\t\tc AM S..U 000000 160000 160000 $SHA_ZERO $HSUB R0 sub1\n+\t\t? actual\n+\t\t? expected\n+\t\tEOF\n+\n+\t\tgit status --porcelain=v2 --branch --ignored --untracked-files=all >actual &&\n+\t\ttest_cmp expected actual\n+\t)\n+'\n+\n+test_expect_success 'submodule_flags_2' '\n+\t(\tcd super_repo &&\n+\t\t## Make some staged dirt in the submodule.\n+\t\t(\tcd sub1 &&\n+\t\t\tgit add file_in_sub\n+\t\t) &&\n+\n+\t\tHMOD=`git hash-object -t blob -- .gitmodules` &&\n+\t\tHSUP=`git rev-parse HEAD` &&\n+\t\tHSUB=$HSUP &&\n+\n+\t\tcat >expected <<-EOF &&\n+\t\t## branch: $HSUP master origin/master +0 -0\n+\t\tc A. N... 000000 100644 100644 $SHA_ZERO $HMOD R0 .gitmodules\n+\t\tc AM S.M. 000000 160000 160000 $SHA_ZERO $HSUB R0 sub1\n+\t\t? actual\n+\t\t? expected\n+\t\tEOF\n+\n+\t\tgit status --porcelain=v2 --branch --ignored --untracked-files=all >actual &&\n+\t\ttest_cmp expected actual\n+\t)\n+'\n+\n+test_expect_success 'submodule_flags_3' '\n+\t(\tcd super_repo &&\n+\t\t## Make some staged and unstaged dirt (on the same file) in the submodule.\n+\t\t## This does not cause us to get S.MU (because the submodule does not report\n+\t\t## a \"?\" line for the unstaged changes).\n+\t\t(\tcd sub1 &&\n+\t\t\techo \"more dirt\" >>file_in_sub\n+\t\t) &&\n+\n+\t\tHMOD=`git hash-object -t blob -- .gitmodules` &&\n+\t\tHSUP=`git rev-parse HEAD` &&\n+\t\tHSUB=$HSUP &&\n+\n+\t\tcat >expected <<-EOF &&\n+\t\t## branch: $HSUP master origin/master +0 -0\n+\t\tc A. N... 000000 100644 100644 $SHA_ZERO $HMOD R0 .gitmodules\n+\t\tc AM S.M. 000000 160000 160000 $SHA_ZERO $HSUB R0 sub1\n+\t\t? actual\n+\t\t? expected\n+\t\tEOF\n+\n+\t\tgit status --porcelain=v2 --branch --ignored --untracked-files=all >actual &&\n+\t\ttest_cmp expected actual\n+\t)\n+'\n+\n+test_expect_success 'submodule_flags_4' '\n+\t(\tcd super_repo &&\n+\t\t## Make some staged and untracked dirt (on different files) in the submodule.\n+\t\t(\tcd sub1 &&\n+\t\t\tgit add file_in_sub &&\n+\t\t\techo \"dirt\" >>another_file_in_sub\n+\t\t) &&\n+\n+\t\tHMOD=`git hash-object -t blob -- .gitmodules` &&\n+\t\tHSUP=`git rev-parse HEAD` &&\n+\t\tHSUB=$HSUP &&\n+\n+\t\tcat >expected <<-EOF &&\n+\t\t## branch: $HSUP master origin/master +0 -0\n+\t\tc A. N... 000000 100644 100644 $SHA_ZERO $HMOD R0 .gitmodules\n+\t\tc AM S.MU 000000 160000 160000 $SHA_ZERO $HSUB R0 sub1\n+\t\t? actual\n+\t\t? expected\n+\t\tEOF\n+\n+\t\tgit status --porcelain=v2 --branch --ignored --untracked-files=all >actual &&\n+\t\ttest_cmp expected actual\n+\t)\n+'\n+\n+test_expect_success 'submodule_flags_5' '\n+\t(\tcd super_repo &&\n+\t\t## Make a new commit in the submodule.\n+\t\t(\tcd sub1 &&\n+\t\t\tgit add file_in_sub &&\n+\t\t\trm -f another_file_in_sub &&\n+\t\t\tgit commit -m \"new commit\"\n+\t\t) &&\n+\n+\t\tHMOD=`git hash-object -t blob -- .gitmodules` &&\n+\t\tHSUP=`git rev-parse HEAD` &&\n+\t\tHSUB=$HSUP &&\n+\n+\t\tcat >expected <<-EOF &&\n+\t\t## branch: $HSUP master origin/master +0 -0\n+\t\tc A. N... 000000 100644 100644 $SHA_ZERO $HMOD R0 .gitmodules\n+\t\tc AM SC.. 000000 160000 160000 $SHA_ZERO $HSUB R0 sub1\n+\t\t? actual\n+\t\t? expected\n+\t\tEOF\n+\n+\t\tgit status --porcelain=v2 --branch --ignored --untracked-files=all >actual &&\n+\t\ttest_cmp expected actual\n+\t)\n+'\n+\n+test_expect_success 'submodule_flags_6' '\n+\t(\tcd super_repo &&\n+\t\t## Commit the new submodule commit in the super.\n+\t\tgit add sub1 &&\n+\t\tgit commit -m \"super commit\" &&\n+\n+\t\tHSUP=`git rev-parse HEAD` &&\n+\n+\t\tcat >expected <<-EOF &&\n+\t\t## branch: $HSUP master origin/master +1 -0\n+\t\t? actual\n+\t\t? expected\n+\t\tEOF\n+\n+\t\tgit status --porcelain=v2 --branch --ignored --untracked-files=all >actual &&\n+\t\ttest_cmp expected actual\n+\t)\n+'\n+\n+test_expect_success 'submodule_flags_7' '\n+\t(\tcd super_repo &&\n+\t\t## Make some untracked dirt in the submodule.\n+\t\t(\tcd sub1 &&\n+\t\t\techo \"yet more dirt\" >>file_in_sub\n+\t\t) &&\n+\n+\t\tHMOD=`git hash-object -t blob -- .gitmodules` &&\n+\t\tHSUP=`git rev-parse HEAD` &&\n+\t\tHSUB=`(cd sub1 && git rev-parse HEAD)` &&\n+\n+\t\tcat >expected <<-EOF &&\n+\t\t## branch: $HSUP master origin/master +1 -0\n+\t\tc .M S.M. 160000 160000 160000 $HSUB $HSUB R0 sub1\n+\t\t? actual\n+\t\t? expected\n+\t\tEOF\n+\n+\t\tgit status --porcelain=v2 --branch --ignored --untracked-files=all >actual &&\n+\t\ttest_cmp expected actual\n+\t)\n+'\n+\n+##################################################################\n+## The end.\n+##################################################################\n+\n+test_done\n-- \n2.8.0.rc4.17.gac42084.dirty\n\n"},{"id":"292128","messageId":"1469474750-49075-7-git-send-email-jeffhost@microsoft.com","threadId":"42922","inReplyTo":"1469474750-49075-1-git-send-email-jeffhost@microsoft.com","subject":"[PATCH v2 6/8] status: print branch info with --porcelain=v2 --branch","fromName":"Jeff Hostetler","fromEmail":"jeffhost@microsoft.com","sentAt":"2016-07-25T19:25:48Z","receivedAt":"2016-07-25T19:29:16Z","isPatch":true,"sender":{"key":"jeffhost@microsoft.com","avatar":"https://avatars.githubusercontent.com/u/7493832?v=4"},"body":"Expand porcelain v2 output to include branch and tracking\nbranch information.  This includes the commit SHA, the branch,\nthe upstream branch, and the ahead and behind counts.\n\nSigned-off-by: Jeff Hostetler <jeffhost@microsoft.com>\n---\n builtin/commit.c |  5 ++++\n wt-status.c      | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n wt-status.h      |  1 +\n 3 files changed, 92 insertions(+)\n\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 5b9efd2..ebb43dd 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -510,6 +510,8 @@ static int run_status(FILE *fp, const char *index_file, const char *prefix, int\n \ts->fp = fp;\n \ts->nowarn = nowarn;\n \ts->is_initial = get_sha1(s->reference, sha1) ? 1 : 0;\n+\tif (!s->is_initial)\n+\t\thashcpy(s->sha1_commit, sha1);\n \ts->status_format = status_format;\n \ts->ignore_submodule_arg = ignore_submodule_arg;\n \n@@ -1378,6 +1380,9 @@ int cmd_status(int argc, const char **argv, const char *prefix)\n \tfd = hold_locked_index(&index_lock, 0);\n \n \ts.is_initial = get_sha1(s.reference, sha1) ? 1 : 0;\n+\tif (!s.is_initial)\n+\t\thashcpy(s.sha1_commit, sha1);\n+\n \ts.ignore_submodule_arg = ignore_submodule_arg;\n \ts.status_format = status_format;\n \ts.verbose = verbose;\ndiff --git a/wt-status.c b/wt-status.c\nindex ffdfe11..39eef4b 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -1889,6 +1889,88 @@ void wt_status_print(struct wt_status *s)\n }\n \n /*\n+ * Print branch and tracking header for porcelain v2 output.\n+ * This is printed when the '--branch' parameter is given.\n+ *\n+ *    \"## branch: <commit> <head>[ <upstream>[ +<ahead> -<behind>]]<eol>\"\n+ *\n+ *              <commit> ::= the current commit hash or the the literal\n+ *                           \"(initial)\" to indicate an initialized repo\n+ *                           with no commits.\n+ *\n+ *                <head> ::= <branch_name> the current branch name or\n+ *                           \"(detached)\" literal when detached head or\n+ *                           \"(unknown)\" when something is wrong.\n+ *\n+ *            <upstream> ::= the upstream branch name, when set.\n+ *\n+ *               <ahead> ::= integer ahead value, when upstream set\n+ *                           and commit is present.\n+ *\n+ *              <behind> ::= integer behind value, when upstream set\n+ *                           and commit is present.\n+ *\n+ *\n+ * The end-of-line is defined by the -z flag.\n+ *\n+ *                 <eol> ::= NUL when -z,\n+ *                           LF when NOT -z.\n+ *\n+ */\n+static void wt_porcelain_v2_print_tracking(struct wt_status *s)\n+{\n+\tstruct branch *branch;\n+\tconst char *base;\n+\tconst char *branch_name;\n+\tstruct wt_status_state state;\n+\tint ab_info, nr_ahead, nr_behind;\n+\n+\tmemset(&state, 0, sizeof(state));\n+\twt_status_get_state(&state, s->branch && !strcmp(s->branch, \"HEAD\"));\n+\n+\tfprintf(s->fp, \"## branch:\");\n+\tfprintf(s->fp, \" %s\",\n+\t\t(s->is_initial ? \"(initial)\" : sha1_to_hex(s->sha1_commit)));\n+\n+\tif (!s->branch)\n+\t\tfprintf(s->fp, \" %s\", \"(unknown)\");\n+\telse {\n+\t\tif (!strcmp(s->branch, \"HEAD\")) {\n+\t\t\tfprintf(s->fp, \" %s\", \"(detached)\");\n+\t\t\tif (state.rebase_in_progress || state.rebase_interactive_in_progress)\n+\t\t\t\tbranch_name = state.onto;\n+\t\t\telse if (state.detached_from)\n+\t\t\t\tbranch_name = state.detached_from;\n+\t\t\telse\n+\t\t\t\tbranch_name = \"\";\n+\t\t} else {\n+\t\t\tbranch_name = NULL;\n+\t\t\tskip_prefix(s->branch, \"refs/heads/\", &branch_name);\n+\t\t\tfprintf(s->fp, \" %s\", branch_name);\n+\t\t}\n+\n+\t\t/* Lookup stats on the upstream tracking branch, if set. */\n+\t\tbranch = branch_get(branch_name);\n+\t\tbase = NULL;\n+\t\tab_info = (stat_tracking_info(branch, &nr_ahead, &nr_behind, &base) == 0);\n+\t\tif (base) {\n+\t\t\tbase = shorten_unambiguous_ref(base, 0);\n+\t\t\tfprintf(s->fp, \" %s\", base);\n+\t\t\tfree((char *)base);\n+\n+\t\t\tif (ab_info)\n+\t\t\t\tfprintf(s->fp, \" +%d -%d\", nr_ahead, nr_behind);\n+\t\t}\n+\t}\n+\n+\tfprintf(s->fp, \"%c\", (s->null_termination ? '\\0' : '\\n'));\n+\n+\tfree(state.branch);\n+\tfree(state.onto);\n+\tfree(state.detached_from);\n+}\n+\n+/*\n  * Convert various submodule status values into a\n  * string of characters in the buffer provided.\n  */\n@@ -2132,6 +2214,7 @@ static void wt_porcelain_v2_print_other(\n /*\n  * Print porcelain V2 status.\n  *\n+ * [<v2_branch>]\n  * [<v2_changed_items>]*\n  * [<v2_unmerged_items>]*\n  * [<v2_untracked_items>]*\n@@ -2144,6 +2227,9 @@ void wt_porcelain_v2_print(struct wt_status *s)\n \tstruct string_list_item *it;\n \tint i;\n \n+\tif (s->show_branch)\n+\t\twt_porcelain_v2_print_tracking(s);\n+\n \tfor (i = 0; i < s->change.nr; i++) {\n \t\tit = &(s->change.items[i]);\n \t\td = it->util;\ndiff --git a/wt-status.h b/wt-status.h\nindex f2cb65d..99f2879 100644\n--- a/wt-status.h\n+++ b/wt-status.h\n@@ -93,6 +93,7 @@ struct wt_status {\n \tint hints;\n \n \tenum wt_status_format status_format;\n+\tunsigned char sha1_commit[GIT_SHA1_RAWSZ]; /* when not Initial */\n \n \t/* These are computed during processing of the individual sections */\n \tint commitable;\n-- \n2.8.0.rc4.17.gac42084.dirty\n\n"},{"id":"292129","messageId":"1469474750-49075-5-git-send-email-jeffhost@microsoft.com","threadId":"42922","inReplyTo":"1469474750-49075-1-git-send-email-jeffhost@microsoft.com","subject":"[PATCH v2 4/8] status: per-file data collection for --porcelain=v2","fromName":"Jeff Hostetler","fromEmail":"jeffhost@microsoft.com","sentAt":"2016-07-25T19:25:46Z","receivedAt":"2016-07-25T19:29:20Z","isPatch":true,"sender":{"key":"jeffhost@microsoft.com","avatar":"https://avatars.githubusercontent.com/u/7493832?v=4"},"body":"The output of `git status --porcelain` leaves out many details\nabout the current status that clients might like to have. This\ncan force them to be less efficient as they may need to launch\nsecondary commands (and try to match the logic within git) to\naccumulate this extra information.  For example, a GUI IDE might\nneed the file mode to display the correct icon for a changed item.\n\nSigned-off-by: Jeff Hostetler <jeffhost@microsoft.com>\n---\n builtin/commit.c |   3 ++\n wt-status.c      | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-\n wt-status.h      |  17 +++++++++\n 3 files changed, 133 insertions(+), 1 deletion(-)\n\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex e6bbb12..5b9efd2 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -153,6 +153,8 @@ static int opt_parse_porcelain(const struct option *opt, const char *arg, int un\n \t\t*value = STATUS_FORMAT_PORCELAIN;\n \telse if (!strcmp(arg, \"v1\"))\n \t\t*value = STATUS_FORMAT_PORCELAIN;\n+\telse if (!strcmp(arg, \"v2\"))\n+\t\t*value = STATUS_FORMAT_PORCELAIN_V2;\n \telse\n \t\tdie(\"unsupported porcelain version\");\n \n@@ -1104,6 +1106,7 @@ static struct status_deferred_config {\n static void finalize_deferred_config(struct wt_status *s)\n {\n \tint use_deferred_config = (status_format != STATUS_FORMAT_PORCELAIN &&\n+\t\t\t\t   status_format != STATUS_FORMAT_PORCELAIN_V2 &&\n \t\t\t\t   !s->null_termination);\n \n \tif (s->null_termination) {\ndiff --git a/wt-status.c b/wt-status.c\nindex a9031e4..54aedc1 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -406,6 +406,110 @@ static void wt_longstatus_print_change_data(struct wt_status *s,\n \tstrbuf_release(&twobuf);\n }\n \n+static void aux_updated_entry_porcelain_v2(\n+\tstruct wt_status *s,\n+\tstruct wt_status_change_data *d,\n+\tstruct diff_filepair *p)\n+{\n+\tswitch (p->status) {\n+\tcase DIFF_STATUS_ADDED:\n+\t\t/* {mode,sha1}_head are zero for an add. */\n+\t\td->aux.porcelain_v2.mode_index = p->two->mode;\n+\t\toidcpy(&d->aux.porcelain_v2.oid_index, &p->two->oid);\n+\t\tbreak;\n+\n+\tcase DIFF_STATUS_DELETED:\n+\t\td->aux.porcelain_v2.mode_head = p->one->mode;\n+\t\toidcpy(&d->aux.porcelain_v2.oid_head, &p->one->oid);\n+\t\t/* {mode,oid}_index are zero for a delete. */\n+\t\tbreak;\n+\n+\tcase DIFF_STATUS_RENAMED:\n+\t\td->aux.porcelain_v2.rename_score = p->score * 100 / MAX_SCORE;\n+\tcase DIFF_STATUS_COPIED:\n+\tcase DIFF_STATUS_MODIFIED:\n+\tcase DIFF_STATUS_TYPE_CHANGED:\n+\tcase DIFF_STATUS_UNMERGED:\n+\t\td->aux.porcelain_v2.mode_head = p->one->mode;\n+\t\td->aux.porcelain_v2.mode_index = p->two->mode;\n+\t\toidcpy(&d->aux.porcelain_v2.oid_head, &p->one->oid);\n+\t\toidcpy(&d->aux.porcelain_v2.oid_index, &p->two->oid);\n+\t\tbreak;\n+\n+\tcase DIFF_STATUS_UNKNOWN:\n+\t\tdie(\"BUG: index status unknown\");\n+\t\tbreak;\n+\t}\n+}\n+\n+/* Save aux info for a head-vs-index change. */\n+static void aux_updated_entry(\n+\tstruct wt_status *s,\n+\tstruct wt_status_change_data *d,\n+\tstruct diff_filepair *p)\n+{\n+\tif (s->status_format == STATUS_FORMAT_PORCELAIN_V2)\n+\t\taux_updated_entry_porcelain_v2(s, d, p);\n+}\n+\n+static void aux_changed_entry_porcelain_v2(\n+\tstruct wt_status *s,\n+\tstruct wt_status_change_data *d,\n+\tconst struct diff_filepair *p)\n+{\n+\tswitch (p->status) {\n+\tcase DIFF_STATUS_ADDED:\n+\t\tdie(\"BUG: worktree status add???\");\n+\t\tbreak;\n+\n+\tcase DIFF_STATUS_DELETED:\n+\t\td->aux.porcelain_v2.mode_index = p->one->mode;\n+\t\toidcpy(&d->aux.porcelain_v2.oid_index, &p->one->oid);\n+\t\t/* mode_worktree is zero for a delete. */\n+\t\tbreak;\n+\n+\tcase DIFF_STATUS_MODIFIED:\n+\tcase DIFF_STATUS_TYPE_CHANGED:\n+\tcase DIFF_STATUS_UNMERGED:\n+\t\td->aux.porcelain_v2.mode_index = p->one->mode;\n+\t\td->aux.porcelain_v2.mode_worktree = p->two->mode;\n+\t\toidcpy(&d->aux.porcelain_v2.oid_index, &p->one->oid);\n+\t\tbreak;\n+\n+\tcase DIFF_STATUS_UNKNOWN:\n+\t\tdie(\"BUG: worktree status unknown???\");\n+\t\tbreak;\n+\t}\n+}\n+\n+/* Save aux info for an index-vs-worktree change. */\n+static void aux_changed_entry(\n+\tstruct wt_status *s,\n+\tstruct wt_status_change_data *d,\n+\tstruct diff_filepair *p)\n+{\n+\tif (s->status_format == STATUS_FORMAT_PORCELAIN_V2)\n+\t\taux_changed_entry_porcelain_v2(s, d, p);\n+}\n+\n+static void aux_initial_entry_porcelain_v2(\n+\tstruct wt_status *s,\n+\tstruct wt_status_change_data *d,\n+\tconst struct cache_entry *ce)\n+{\n+\td->aux.porcelain_v2.mode_index = ce->ce_mode;\n+\thashcpy(d->aux.porcelain_v2.oid_index.hash, ce->sha1);\n+}\n+\n+static void aux_initial_entry(\n+\tstruct wt_status *s,\n+\tstruct wt_status_change_data *d,\n+\tconst struct cache_entry *ce)\n+{\n+\tif (s->status_format == STATUS_FORMAT_PORCELAIN_V2)\n+\t\taux_initial_entry_porcelain_v2(s, d, ce);\n+}\n+\n static void wt_status_collect_changed_cb(struct diff_queue_struct *q,\n \t\t\t\t\t struct diff_options *options,\n \t\t\t\t\t void *data)\n@@ -434,6 +538,7 @@ static void wt_status_collect_changed_cb(struct diff_queue_struct *q,\n \t\tif (S_ISGITLINK(p->two->mode))\n \t\t\td->new_submodule_commits = !!oidcmp(&p->one->oid,\n \t\t\t\t\t\t\t    &p->two->oid);\n+\t\taux_changed_entry(s, d, p);\n \t}\n }\n \n@@ -487,6 +592,8 @@ static void wt_status_collect_updated_cb(struct diff_queue_struct *q,\n \t\t\td->stagemask = unmerged_mask(p->two->path);\n \t\t\tbreak;\n \t\t}\n+\n+\t\taux_updated_entry(s, d, p);\n \t}\n }\n \n@@ -566,8 +673,10 @@ static void wt_status_collect_changes_initial(struct wt_status *s)\n \t\t\td->index_status = DIFF_STATUS_UNMERGED;\n \t\t\td->stagemask |= (1 << (ce_stage(ce) - 1));\n \t\t}\n-\t\telse\n+\t\telse {\n \t\t\td->index_status = DIFF_STATUS_ADDED;\n+\t\t\taux_initial_entry(s, d, ce);\n+\t\t}\n \t}\n }\n \n@@ -1764,6 +1873,9 @@ void wt_status_print(struct wt_status *s)\n \tcase STATUS_FORMAT_PORCELAIN:\n \t\twt_porcelain_print(s);\n \t\tbreak;\n+\tcase STATUS_FORMAT_PORCELAIN_V2:\n+\t\t/* TODO */\n+\t\tbreak;\n \tcase STATUS_FORMAT_UNSPECIFIED:\n \t\tdie(\"BUG: finalize_deferred_config() should have been called\");\n \t\tbreak;\ndiff --git a/wt-status.h b/wt-status.h\nindex a859a12..f2cb65d 100644\n--- a/wt-status.h\n+++ b/wt-status.h\n@@ -34,6 +34,21 @@ enum commit_whence {\n \tFROM_CHERRY_PICK /* commit came from cherry-pick */\n };\n \n+/*\n+ * Additional per-file info which may vary based\n+ * upon the chosen format.\n+ */\n+struct wt_status_aux_change_data {\n+\tstruct {\n+\t\tint rename_score;\n+\t\tint mode_head;\n+\t\tint mode_index;\n+\t\tint mode_worktree;\n+\t\tstruct object_id oid_head;\n+\t\tstruct object_id oid_index;\n+\t} porcelain_v2;\n+};\n+\n struct wt_status_change_data {\n \tint worktree_status;\n \tint index_status;\n@@ -41,6 +56,7 @@ struct wt_status_change_data {\n \tchar *head_path;\n \tunsigned dirty_submodule       : 2;\n \tunsigned new_submodule_commits : 1;\n+\tstruct wt_status_aux_change_data aux;\n };\n \n  enum wt_status_format {\n@@ -48,6 +64,7 @@ struct wt_status_change_data {\n \tSTATUS_FORMAT_LONG,\n \tSTATUS_FORMAT_SHORT,\n \tSTATUS_FORMAT_PORCELAIN,\n+\tSTATUS_FORMAT_PORCELAIN_V2,\n \n \tSTATUS_FORMAT_UNSPECIFIED\n  };\n-- \n2.8.0.rc4.17.gac42084.dirty\n\n"},{"id":"292130","messageId":"57966DDF.5020301@gmail.com","threadId":"42922","inReplyTo":"1469474750-49075-4-git-send-email-jeffhost@microsoft.com","subject":"Re: [PATCH v2 3/8] status: support --porcelain[=<version>]","fromName":"Jakub Narębski","fromEmail":"jnareb@gmail.com","sentAt":"2016-07-25T19:51:59Z","receivedAt":"2016-07-25T19:52:18Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"W dniu 2016-07-25 o 21:25, Jeff Hostetler pisze:\n> --- a/builtin/commit.c\n> +++ b/builtin/commit.c\n> @@ -144,6 +144,21 @@ static struct strbuf message = STRBUF_INIT;\n>  \n>  static enum wt_status_format status_format = STATUS_FORMAT_UNSPECIFIED;\n>  \n> +static int opt_parse_porcelain(const struct option *opt, const char *arg, int unset)\n> +{\n> +\tenum wt_status_format *value = (enum wt_status_format *)opt->value;\n> +\tif (unset)\n> +\t\t*value = STATUS_FORMAT_NONE;\n> +\telse if (!arg)\n> +\t\t*value = STATUS_FORMAT_PORCELAIN;\n> +\telse if (!strcmp(arg, \"v1\"))\n> +\t\t*value = STATUS_FORMAT_PORCELAIN;\n> +\telse\n> +\t\tdie(\"unsupported porcelain version\");\n> +\n> +\treturn 0;\n> +}\n\nPresumably it is not something hard to find, but perhaps it\nwould be better to print the version that were given (for\nexample \"1\" instead of \"v1\")?\n\n-- \nJakub Narębski\n\n"},{"id":"292132","messageId":"xmqq7fc95vqa.fsf@gitster.mtv.corp.google.com","threadId":"42922","inReplyTo":"1469474750-49075-3-git-send-email-jeffhost@microsoft.com","subject":"Re: [PATCH v2 2/8] status: cleanup API to wt_status_print","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-07-25T20:05:49Z","receivedAt":"2016-07-25T20:05:56Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff Hostetler <jeffhost@microsoft.com> writes:\n\n> Refactor the API between builtin/commit.c and wt-status.[ch].\n> Hide details of the various wt_*status_print() routines inside\n> wt-status.c behind a single (new) wt_status_print() routine\n> and eliminate the switch statements from builtin/commit.c\n>\n> This will allow us to more easily add new status formats\n> and isolate that within wt-status.c\n>\n> Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>\n> ---\n\nThe division of labour between wt-status.c and cmd_status() that was\noriginally envisioned was to have status computation in the former\nand presentation in the latter, but that was broken and more output\nis made from the latter these days, so I think it may make sense to\nadmit that the original vision did not work out well, and this step\nis a good move forward to shift the boundary.\n\n"},{"id":"292134","messageId":"xmqq1t2h5vbt.fsf@gitster.mtv.corp.google.com","threadId":"42922","inReplyTo":"1469474750-49075-5-git-send-email-jeffhost@microsoft.com","subject":"Re: [PATCH v2 4/8] status: per-file data collection for --porcelain=v2","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-07-25T20:14:30Z","receivedAt":"2016-07-25T20:14:38Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff Hostetler <jeffhost@microsoft.com> writes:\n\n> +static void aux_updated_entry_porcelain_v2(\n> +\tstruct wt_status *s,\n> +\tstruct wt_status_change_data *d,\n> +\tstruct diff_filepair *p)\n> +{\n> +\tswitch (p->status) {\n> +\tcase DIFF_STATUS_ADDED:\n> +\t\t/* {mode,sha1}_head are zero for an add. */\n> +\t\td->aux.porcelain_v2.mode_index = p->two->mode;\n\nI doubt that it makes sense in the longer term to have a new \"aux\"\nfield.  Why isn't it part of the wt_status_change_data structure?\nFor that matter, why should these new functions have both \"aux\" and\n\"v2\" in their names?\n\nImagine what should happen when somebody wants to add --porcelain=v3\nformat in 6 months.  Why must \"v3\" be treated differently from \"v1\"\nand in a way close to \"v2\"?  Why shouldn't all the three be treated\nin a similar way that \"v1\" has already?\n\n> +\t\toidcpy(&d->aux.porcelain_v2.oid_index, &p->two->oid);\n> +\t\tbreak;\n> +\n> +\tcase DIFF_STATUS_DELETED:\n> +\t\td->aux.porcelain_v2.mode_head = p->one->mode;\n> +\t\toidcpy(&d->aux.porcelain_v2.oid_head, &p->one->oid);\n> +\t\t/* {mode,oid}_index are zero for a delete. */\n> +\t\tbreak;\n> +\n> +\tcase DIFF_STATUS_RENAMED:\n> +\t\td->aux.porcelain_v2.rename_score = p->score * 100 / MAX_SCORE;\n\nI have a slight aversion against losing the precision in a helper\nfunction like this that does not do the actual output, but it\nprobably is OK.\n\nDon't we have copy detection score that is computed exactly the same\nway for DIFF_STATUS_COPIED case, too?\n\nFor readability, unless a case arm is completely empty, we should\nhave\n\t\t/* fallthru */\n\ncomment where \"break;\" would go for a normal case arm.\n\n> +\tcase DIFF_STATUS_COPIED:\n> +\tcase DIFF_STATUS_MODIFIED:\n> +\tcase DIFF_STATUS_TYPE_CHANGED:\n> +\tcase DIFF_STATUS_UNMERGED:\n> +\t\td->aux.porcelain_v2.mode_head = p->one->mode;\n> +\t\td->aux.porcelain_v2.mode_index = p->two->mode;\n> +\t\toidcpy(&d->aux.porcelain_v2.oid_head, &p->one->oid);\n> +\t\toidcpy(&d->aux.porcelain_v2.oid_index, &p->two->oid);\n> +\t\tbreak;\n"},{"id":"292136","messageId":"xmqqwpk94gbu.fsf@gitster.mtv.corp.google.com","threadId":"42922","inReplyTo":"1469474750-49075-6-git-send-email-jeffhost@microsoft.com","subject":"Re: [PATCH v2 5/8] status: print per-file porcelain v2 status data","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-07-25T20:23:49Z","receivedAt":"2016-07-25T20:23:58Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff Hostetler <jeffhost@microsoft.com> writes:\n\n> +static void wt_porcelain_v2_print(struct wt_status *s);\n> +\n\nThere is no point in this forward declaration, if you just place the\nimplementation of these functions here, no?\n\n> +/*\n> + * Print porcelain v2 info for tracked entries with changes.\n> + */\n> +static void wt_porcelain_v2_print_changed_entry(\n> +\tstruct string_list_item *it,\n> +\tstruct wt_status *s)\n> +{\n> +...\n> +\tfprintf(s->fp, \"%c %s %s %06o %06o %06o %s %s R%d %s\",\n\nIt is misleading to always say R in the output when there is no\nrename, isn't it?\n\n> +\t * Note that this is a last-one-wins for each the individual\n> +\t * stage [123] columns in the event of multiple cache rows\n> +\t * for a stage.\n\nJust FYI, the usual lingo we use for that is \"multiple cache entries\nfor the same stage\", I would think.\n\n> +\t */\n> +\tmemset(stages, 0, sizeof(stages));\n> +\tsum = 0;\n> +\tpos = cache_name_pos(it->string, strlen(it->string));\n> +\tassert(pos < 0);\n> +\tpos = -pos-1;\n> +\twhile (pos < active_nr) {\n> +\t\tce = active_cache[pos++];\n> +\t\tstage = ce_stage(ce);\n> +\t\tif (strcmp(ce->name, it->string) || !stage)\n> +\t\t\tbreak;\n> +\t\tstages[stage - 1].mode = ce->ce_mode;\n> +\t\thashcpy(stages[stage - 1].oid.hash, ce->sha1);\n> +\t\tsum++;\n> +\t}\n> +\tif (!sum)\n> +\t\tdie(\"BUG: unmerged entry without any stages\");\n\nHmm, we seem to already have d->stagemask; if you call that variable\n\"sum\" anyway, perhaps its computation can be more like\n\n\tsum |= 1 << (stage - 1);\n\nso that you can compare it with d->stagemask for this sanity check?\n\n"},{"id":"292138","messageId":"xmqqshux4g0p.fsf@gitster.mtv.corp.google.com","threadId":"42922","inReplyTo":"1469474750-49075-7-git-send-email-jeffhost@microsoft.com","subject":"Re: [PATCH v2 6/8] status: print branch info with --porcelain=v2 --branch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-07-25T20:30:30Z","receivedAt":"2016-07-25T20:30:38Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff Hostetler <jeffhost@microsoft.com> writes:\n\n>  /*\n> + * Print branch and tracking header for porcelain v2 output.\n> + * This is printed when the '--branch' parameter is given.\n> + *\n> + *    \"## branch: <commit> <head>[ <upstream>[ +<ahead> -<behind>]]<eol>\"\n\nJust FYI, the only reason why the original \"short\" output gives this\ninformation on a single line with ## is because it was added as an\nafterthought to then-existing short/porcelain format that used two\nletter prefix and one-line-per-path format, and the expectation was\nthat the existing parsers for the output would ignore unknown status\nletters (namely \"##\").  Because you are inventing a new format that\nneeds to be parsed by a brand new parser _anyway_, you do not have\nto mimic that old convention which was a workaround, and use a\nnotation that mixes better with the other lines you show under\nthe --porcelain=v2 option.\n\nOf course if you like \"## branch:\" output and think it is pleasing\nto see, that is fine as well.\n"},{"id":"292162","messageId":"57969607.9080206@gmail.com","threadId":"42922","inReplyTo":"1469474750-49075-8-git-send-email-jeffhost@microsoft.com","subject":"Re: [PATCH v2 7/8] status: update git-status.txt for --porcelain=v2","fromName":"Jakub Narębski","fromEmail":"jnareb@gmail.com","sentAt":"2016-07-25T22:43:19Z","receivedAt":"2016-07-25T22:43:41Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"W dniu 2016-07-25 o 21:25, Jeff Hostetler pisze:\n\n> +Porcelain Format Version 2\n> +~~~~~~~~~~~~~~~~~~~~~~~~~~\n> +\n> +Version 2 format adds more detailed information about the state of\n> +the worktree and the changed items.\n\nI think it should be \"and changed items\", but I am not a native speaker.\n\n> +If `--branch` is given, a header line showing branch tracking information\n> +is printed.  This line begins with \"### branch: \".  Fields are separated\n> +by a single space.\n> +\n> +    Field                    Meaning\n> +    --------------------------------------------------------\n> +    <sha> | (initial)        Current commit\n> +    <branch> | (detached)    Current branch\n> +    <upstream>               Upstream branch, if set\n> +    +<ahead>                 Ahead count, if upstream present\n> +    -<behind>                Behind count, if upstream present\n> +    --------------------------------------------------------\n> +\n> +A series of lines are then displayed for the tracked entries.\n> +Ordinary changed entries have the following format; the first\n> +character is a 'c' to distinguish them from unmerged entries.\n\nIt would be nice (though not necessary) to have an example, either\nhere or at the end.\n\n> +\n> +    c <xy> <sub> <mH> <mI> <mW> <hH> <hI> R<nr> <path>[\\t<pathSrc>]\n> +\n> +    Field       Meaning\n> +    --------------------------------------------------------\n> +    <xy>        A 2 character field containing the staged and\n> +                unstaged XY values described in the short format,\n> +                with unchanged indicated by a \".\" rather than\n> +                a space.\n> +    <sub>       A 4 character field describing the submodule state.\n> +                \"N...\" when the entry is not a submodule.\n> +                \"S<c><m><u>\" when the entry is a submodule.\n> +                <c> is \"C\" if the commit changed; otherwise \".\".\n> +                <m> is \"M\" if it has tracked changes; otherwise \".\".\n> +                <u> is \"U\" if there are untracked changes; otherwise \".\".\n> +    <m*>        The 6 character octal file modes for head, index,\n> +                and worktree.\n\nI think it might be more readable to be explicit: \"for HEAD (<mH>),\nindex (<mI>), and worktree (<mW>).\"\n\n> +    <h*>        The head and index SHA1 values.\n> +    R<nr>       The rename percentage score.\n\nI assume this would be C<nr> copy detection heuristics percentage\nscore in case of copy detection, and B<br> break percentage score\nin case of breaking change into addition and deletion of file.\nOr am I confused?\n\n\n> +    <path>      The current pathname. It is C-Quoted if it contains\n> +                special control characters.\n\nI assume that \"\\t\" tab character between <path> and <pathSrc> is here\nto be able to not C-Quote sane filenames with internal whitespace,\nisn't it?\n\n> +    <pathSrc>   The original path. This is only present for staged renames.\n> +                It is C-Quoted if necessary.\n\nI assume that \"C-Quoted if necessary\" is the same as \"C-Quoted if\nit contains special control characters\"; also: '\"' quote character,\n'\\' backlash escape character and \"\\t\" horizontal tab are not control\ncharacters per se., but still need C-Quoting.  The rules are the same\nas for the rest of Git, e.g. for `git diff`, isn't it?\n\n> +    --------------------------------------------------------\n> +\n> +Unmerged entries have the following format; the first character is\n> +a \"u\" to distinguish from ordinary changed entries.\n> +\n> +    u <xy> <sub> <m1> <m2> <m3> <h1> <h2> <h3> <path>\n> +\n> +    Field       Meaning\n> +    --------------------------------------------------------\n> +    <xy>        A 2 character field describing the conflict type\n> +                as described in the short format.\n> +    <sub>       A 4 character field describing the submodule state\n> +                as described above.\n> +    <m*>        The 6 character octal file modes for the stage 1,\n> +                stage 2, stage 3, and worktree.\n\nErrr... the pattern has only _3_ character octal modes, <m1> <m2> <m3>.\nA question: what happens during octopus merge?\n\n> +                For regular entries, these are the head, index, and\n> +                worktree modes; the fourth is zero.\n\nThis is remnant of the previous version of \"v2\" format, isn't it?\n\n> +    <h*>        The stage 1, stage 2, and stage 3 SHA1 values.\n> +    <path>      The current pathname. It is C-Quoted if necessary.\n> +    --------------------------------------------------------\n> +\n> +A series of lines are then displayed for untracked and ignored entries.\n> +\n> +    <x> <path>\n> +\n> +Where <x> is \"?\" for untracked entries and \"!\" for ignored entries.\n\nI assume that here also <path> is C-Quoted if necessary.\n\n> +\n> +When the `-z` option is given, a NUL (zero) byte follows each pathname;\n> +serving as both a separator and line termination. No pathname quoting\n> +or backslash escaping is performed. All fields are output in the same\n> +order.\n> +\n>  CONFIGURATION\n>  -------------\n>  \n> \n\n"},{"id":"292203","messageId":"5797663A.5000507@jeffhostetler.com","threadId":"42922","inReplyTo":"xmqq1t2h5vbt.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v2 4/8] status: per-file data collection for --porcelain=v2","fromName":"Jeff Hostetler","fromEmail":"git@jeffhostetler.com","sentAt":"2016-07-26T13:31:38Z","receivedAt":"2016-07-26T13:34:05Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"\n\nOn 07/25/2016 04:14 PM, Junio C Hamano wrote:\n> Jeff Hostetler <jeffhost@microsoft.com> writes:\n>\n>> +static void aux_updated_entry_porcelain_v2(\n>> +\tstruct wt_status *s,\n>> +\tstruct wt_status_change_data *d,\n>> +\tstruct diff_filepair *p)\n>> +{\n>> +\tswitch (p->status) {\n>> +\tcase DIFF_STATUS_ADDED:\n>> +\t\t/* {mode,sha1}_head are zero for an add. */\n>> +\t\td->aux.porcelain_v2.mode_index = p->two->mode;\n>\n> I doubt that it makes sense in the longer term to have a new \"aux\"\n> field.  Why isn't it part of the wt_status_change_data structure?\n> For that matter, why should these new functions have both \"aux\" and\n> \"v2\" in their names?\n>\n> Imagine what should happen when somebody wants to add --porcelain=v3\n> format in 6 months.  Why must \"v3\" be treated differently from \"v1\"\n> and in a way close to \"v2\"?  Why shouldn't all the three be treated\n> in a similar way that \"v1\" has already?\n\nI wasn't sure if we wanted the v2 fields to be isolated\nand only filled in for v2 requests or whether we wanted\nthem to be common going forward.  In the case of the former,\nI could see the \"aux\" struct becoming a union and the various\naux_*() routines only populating one member in that union.\nAnd then the various per-format print routines would know\nwhich aux member to access.  That may be more complicated\nthat necessary though -- if we assume that any subsequent\nformats (and possibly any JSON formats) would always want\nto keep these fields and add more.\n\nI'll flatten the fields into the main structure.\n\n>\n>> +\t\toidcpy(&d->aux.porcelain_v2.oid_index, &p->two->oid);\n>> +\t\tbreak;\n>> +\n>> +\tcase DIFF_STATUS_DELETED:\n>> +\t\td->aux.porcelain_v2.mode_head = p->one->mode;\n>> +\t\toidcpy(&d->aux.porcelain_v2.oid_head, &p->one->oid);\n>> +\t\t/* {mode,oid}_index are zero for a delete. */\n>> +\t\tbreak;\n>> +\n>> +\tcase DIFF_STATUS_RENAMED:\n>> +\t\td->aux.porcelain_v2.rename_score = p->score * 100 / MAX_SCORE;\n>\n> I have a slight aversion against losing the precision in a helper\n> function like this that does not do the actual output, but it\n> probably is OK.\n>\n> Don't we have copy detection score that is computed exactly the same\n> way for DIFF_STATUS_COPIED case, too?\n\nYes I believe so.  I'll see about adding that.  Or rather make\nthe field apply to both.\n\n>\n> For readability, unless a case arm is completely empty, we should\n> have\n> \t\t/* fallthru */\n>\n> comment where \"break;\" would go for a normal case arm.\n\nwill do. thanks.\n"},{"id":"292207","messageId":"57976B45.9060102@jeffhostetler.com","threadId":"42922","inReplyTo":"xmqqwpk94gbu.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v2 5/8] status: print per-file porcelain v2 status data","fromName":"Jeff Hostetler","fromEmail":"git@jeffhostetler.com","sentAt":"2016-07-26T13:53:09Z","receivedAt":"2016-07-26T13:55:29Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"\n\nOn 07/25/2016 04:23 PM, Junio C Hamano wrote:\n> Jeff Hostetler <jeffhost@microsoft.com> writes:\n>\n>> +static void wt_porcelain_v2_print(struct wt_status *s);\n>> +\n>\n> There is no point in this forward declaration, if you just place the\n> implementation of these functions here, no?\n\nRight. I just did it that way to make the diffs with the previous\ncommit draw a little cleaner.  But I can take it out.\n\n\n>> +/*\n>> + * Print porcelain v2 info for tracked entries with changes.\n>> + */\n>> +static void wt_porcelain_v2_print_changed_entry(\n>> +\tstruct string_list_item *it,\n>> +\tstruct wt_status *s)\n>> +{\n>> +...\n>> +\tfprintf(s->fp, \"%c %s %s %06o %06o %06o %s %s R%d %s\",\n>\n> It is misleading to always say R in the output when there is no\n> rename, isn't it?\n\nYes, especially if we add it for copied entries too.\nI was just looking for a way to have a fixed format.\nIf we make the R%d field optional, then the first pathname\nis ambiguous.  That gets me back to an earlier draft where\nwe have rename and non-rename line types.\n\nI'll split this up into 1 pathname and 2 pathname forms,\nand only include the R%d (or the C%d) field in the latter.\n\n>\n>> +\t * Note that this is a last-one-wins for each the individual\n>> +\t * stage [123] columns in the event of multiple cache rows\n>> +\t * for a stage.\n>\n> Just FYI, the usual lingo we use for that is \"multiple cache entries\n> for the same stage\", I would think.\n\nthanks.\n\n>\n>> +\t */\n>> +\tmemset(stages, 0, sizeof(stages));\n>> +\tsum = 0;\n>> +\tpos = cache_name_pos(it->string, strlen(it->string));\n>> +\tassert(pos < 0);\n>> +\tpos = -pos-1;\n>> +\twhile (pos < active_nr) {\n>> +\t\tce = active_cache[pos++];\n>> +\t\tstage = ce_stage(ce);\n>> +\t\tif (strcmp(ce->name, it->string) || !stage)\n>> +\t\t\tbreak;\n>> +\t\tstages[stage - 1].mode = ce->ce_mode;\n>> +\t\thashcpy(stages[stage - 1].oid.hash, ce->sha1);\n>> +\t\tsum++;\n>> +\t}\n>> +\tif (!sum)\n>> +\t\tdie(\"BUG: unmerged entry without any stages\");\n>\n> Hmm, we seem to already have d->stagemask; if you call that variable\n> \"sum\" anyway, perhaps its computation can be more like\n>\n> \tsum |= 1 << (stage - 1);\n>\n> so that you can compare it with d->stagemask for this sanity check?\n\ngood point.\n\nthanks\njeff\n\n\n"},{"id":"292216","messageId":"alpine.DEB.2.20.1607261733500.14111@virtualbox","threadId":"42922","inReplyTo":"57969607.9080206@gmail.com","subject":"Re: [PATCH v2 7/8] status: update git-status.txt for --porcelain=v2","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2016-07-26T15:34:39Z","receivedAt":"2016-07-26T15:35:16Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Kuba,\n\nOn Tue, 26 Jul 2016, Jakub Narębski wrote:\n\n> W dniu 2016-07-25 o 21:25, Jeff Hostetler pisze:\n> \n> > +    Field       Meaning\n> > +    --------------------------------------------------------\n> > +    <xy>        A 2 character field describing the conflict type\n> > +                as described in the short format.\n> > +    <sub>       A 4 character field describing the submodule state\n> > +                as described above.\n> > +    <m*>        The 6 character octal file modes for the stage 1,\n> > +                stage 2, stage 3, and worktree.\n> \n> Errr... the pattern has only _3_ character octal modes, <m1> <m2> <m3>.\n> A question: what happens during octopus merge?\n\nFrom git-merge-octopus.sh:\n\n\t# We allow only last one to have a hand-resolvable\n\t# conflicts.  Last round failed and we still had\n\t# a head to merge.\n\nIn other words, octopus merges do not use higher stages than 3.\n\nCiao,\nDscho"},{"id":"292234","messageId":"alpine.DEB.2.20.1607261806590.14111@virtualbox","threadId":"42922","inReplyTo":"1469474750-49075-9-git-send-email-jeffhost@microsoft.com","subject":"Re: [PATCH v2 8/8] status: tests for --porcelain=v2","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2016-07-26T16:07:32Z","receivedAt":"2016-07-26T16:08:12Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Jeff,\n\nOn Mon, 25 Jul 2016, Jeff Hostetler wrote:\n\n> +##################################################################\n> +## Confirm VVP output prior to initial commit.\n> +##################################################################\n\ns/VVP/porcelain v2/...\n\nCiao,\nDscho\n"},{"id":"292251","messageId":"5797BD1E.2010800@jeffhostetler.com","threadId":"42922","inReplyTo":"57969607.9080206@gmail.com","subject":"Re: [PATCH v2 7/8] status: update git-status.txt for --porcelain=v2","fromName":"Jeff Hostetler","fromEmail":"git@jeffhostetler.com","sentAt":"2016-07-26T19:42:22Z","receivedAt":"2016-07-26T19:46:18Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"\n\nOn 07/25/2016 06:43 PM, Jakub Narębski wrote:\n> W dniu 2016-07-25 o 21:25, Jeff Hostetler pisze:\n>\n>> +Porcelain Format Version 2\n>> +~~~~~~~~~~~~~~~~~~~~~~~~~~\n>> +\n>> +Version 2 format adds more detailed information about the state of\n>> +the worktree and the changed items.\n>\n> I think it should be \"and changed items\", but I am not a native speaker.\n\nfixed.\n\n>> +If `--branch` is given, a header line showing branch tracking information\n>> +is printed.  This line begins with \"### branch: \".  Fields are separated\n>> +by a single space.\n>> +\n>> +    Field                    Meaning\n>> +    --------------------------------------------------------\n>> +    <sha> | (initial)        Current commit\n>> +    <branch> | (detached)    Current branch\n>> +    <upstream>               Upstream branch, if set\n>> +    +<ahead>                 Ahead count, if upstream present\n>> +    -<behind>                Behind count, if upstream present\n>> +    --------------------------------------------------------\n>> +\n>> +A series of lines are then displayed for the tracked entries.\n>> +Ordinary changed entries have the following format; the first\n>> +character is a 'c' to distinguish them from unmerged entries.\n>\n> It would be nice (though not necessary) to have an example, either\n> here or at the end.\n\nI'll try to fit that in at the bottom.\n\n>> +\n>> +    c <xy> <sub> <mH> <mI> <mW> <hH> <hI> R<nr> <path>[\\t<pathSrc>]\n>> +\n>> +    Field       Meaning\n>> +    --------------------------------------------------------\n>> +    <xy>        A 2 character field containing the staged and\n>> +                unstaged XY values described in the short format,\n>> +                with unchanged indicated by a \".\" rather than\n>> +                a space.\n>> +    <sub>       A 4 character field describing the submodule state.\n>> +                \"N...\" when the entry is not a submodule.\n>> +                \"S<c><m><u>\" when the entry is a submodule.\n>> +                <c> is \"C\" if the commit changed; otherwise \".\".\n>> +                <m> is \"M\" if it has tracked changes; otherwise \".\".\n>> +                <u> is \"U\" if there are untracked changes; otherwise \".\".\n>> +    <m*>        The 6 character octal file modes for head, index,\n>> +                and worktree.\n>\n> I think it might be more readable to be explicit: \"for HEAD (<mH>),\n> index (<mI>), and worktree (<mW>).\"\n\nI'll try to clarify that.\n\n\n>> +    <h*>        The head and index SHA1 values.\n>> +    R<nr>       The rename percentage score.\n>\n> I assume this would be C<nr> copy detection heuristics percentage\n> score in case of copy detection, and B<br> break percentage score\n> in case of breaking change into addition and deletion of file.\n> Or am I confused?\n\nI'm updating to include rename and copied scores.  I haven't seen\nanything in the code about a break percentage in this context.  I\nsee it listed with -B in the git-diff-* pages, but not in status.\n\n>\n>\n>> +    <path>      The current pathname. It is C-Quoted if it contains\n>> +                special control characters.\n>\n> I assume that \"\\t\" tab character between <path> and <pathSrc> is here\n> to be able to not C-Quote sane filenames with internal whitespace,\n> isn't it?\n\nI'm using the same quoting routines as the existing porcelain\nformat.  So yes, that looks to be the case.  It only converts\nif there are insane characters in pathnames.\n\n>\n>> +    <pathSrc>   The original path. This is only present for staged renames.\n>> +                It is C-Quoted if necessary.\n>\n> I assume that \"C-Quoted if necessary\" is the same as \"C-Quoted if\n> it contains special control characters\"; also: '\"' quote character,\n> '\\' backlash escape character and \"\\t\" horizontal tab are not control\n> characters per se., but still need C-Quoting.  The rules are the same\n> as for the rest of Git, e.g. for `git diff`, isn't it?\n\nyes, i'm using the same quoting routine.  i'll clarify.  thanks.\n\n>\n>> +    --------------------------------------------------------\n>> +\n>> +Unmerged entries have the following format; the first character is\n>> +a \"u\" to distinguish from ordinary changed entries.\n>> +\n>> +    u <xy> <sub> <m1> <m2> <m3> <h1> <h2> <h3> <path>\n>> +\n>> +    Field       Meaning\n>> +    --------------------------------------------------------\n>> +    <xy>        A 2 character field describing the conflict type\n>> +                as described in the short format.\n>> +    <sub>       A 4 character field describing the submodule state\n>> +                as described above.\n>> +    <m*>        The 6 character octal file modes for the stage 1,\n>> +                stage 2, stage 3, and worktree.\n>\n> Errr... the pattern has only _3_ character octal modes, <m1> <m2> <m3>.\n> A question: what happens during octopus merge?\n>\n>> +                For regular entries, these are the head, index, and\n>> +                worktree modes; the fourth is zero.\n>\n> This is remnant of the previous version of \"v2\" format, isn't it?\n\nyes, sorry.  I missed that one.\n\n>\n>> +    <h*>        The stage 1, stage 2, and stage 3 SHA1 values.\n>> +    <path>      The current pathname. It is C-Quoted if necessary.\n>> +    --------------------------------------------------------\n>> +\n>> +A series of lines are then displayed for untracked and ignored entries.\n>> +\n>> +    <x> <path>\n>> +\n>> +Where <x> is \"?\" for untracked entries and \"!\" for ignored entries.\n>\n> I assume that here also <path> is C-Quoted if necessary.\n\nyes.\n\n>\n>> +\n>> +When the `-z` option is given, a NUL (zero) byte follows each pathname;\n>> +serving as both a separator and line termination. No pathname quoting\n>> +or backslash escaping is performed. All fields are output in the same\n>> +order.\n>> +\n>>   CONFIGURATION\n>>   -------------\n>>\n>>\n>\n>\n"}]}