{"thread":{"id":"43796","subject":"[PATCH v8 0/9] status: V2 porcelain status","startedAt":"2016-08-12T15:48:50Z","lastAt":"2016-08-12T22:08:42Z","messageCount":11,"participants":["Jeff Hostetler","Junio C Hamano"],"isPatch":true,"patchVersion":8,"patchTotal":9},"messages":[{"id":"298846","messageId":"1471016692-35828-1-git-send-email-git@jeffhostetler.com","threadId":"43796","inReplyTo":null,"subject":"[PATCH v8 0/9] status: V2 porcelain status","fromName":"Jeff Hostetler","fromEmail":"git@jeffhostetler.com","sentAt":"2016-08-12T15:44:43Z","receivedAt":"2016-08-12T15:48:50Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"From: Jeff Hostetler <jeffhost@microsoft.com>\n\nThis 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 v8 patch series addresses the remaining feedback\nabout the unit tests from the v6 and v7 series.\n\nThis series has been rebased onto 787fadc reference point.\n\nJeff Hostetler (9):\n  status: rename long-format print routines\n  status: cleanup API to wt_status_print\n  status: support --porcelain[=<version>]\n  status: collect per-file data for --porcelain=v2\n  status: print per-file porcelain v2 status data\n  status: print branch info with --porcelain=v2 --branch\n  git-status.txt: describe --porcelain=v2 format\n  test-lib-functions.sh: Add lf_to_nul\n  status: unit tests for --porcelain=v2\n\n Documentation/git-status.txt | 133 +++++++++-\n builtin/commit.c             |  78 +++---\n t/t7060-wtstatus.sh          |  21 ++\n t/t7064-wtstatus-pv2.sh      | 593 +++++++++++++++++++++++++++++++++++++++++++\n t/test-lib-functions.sh      |   4 +\n wt-status.c                  | 570 ++++++++++++++++++++++++++++++++++++-----\n wt-status.h                  |  19 +-\n 7 files changed, 1306 insertions(+), 112 deletions(-)\n create mode 100755 t/t7064-wtstatus-pv2.sh\n\n-- \n2.8.0.rc4.17.gac42084.dirty\n\n"},{"id":"298847","messageId":"1471016692-35828-5-git-send-email-git@jeffhostetler.com","threadId":"43796","inReplyTo":"1471016692-35828-1-git-send-email-git@jeffhostetler.com","subject":"[PATCH v8 4/9] status: collect per-file data for --porcelain=v2","fromName":"Jeff Hostetler","fromEmail":"git@jeffhostetler.com","sentAt":"2016-08-12T15:44:47Z","receivedAt":"2016-08-12T15:48:54Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"From: Jeff Hostetler <jeffhost@microsoft.com>\n\nCollect extra per-file data for porcelain V2 format.\n\nThe output of `git status --porcelain` leaves out many\ndetails about the current status that clients might like\nto have.  This can force them to be less efficient as they\nmay need to launch secondary commands (and try to match\nthe logic within git) to accumulate this extra information.\nFor example, a GUI IDE might want the file mode to display\nthe correct icon for a changed item (without having to stat\nit afterwards).\n\nSigned-off-by: Jeff Hostetler <jeffhost@microsoft.com>\n---\n builtin/commit.c |  3 +++\n wt-status.c      | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--\n wt-status.h      |  4 ++++\n 3 files changed, 69 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 185ac35..3d222d3 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\") || !strcmp(arg, \"1\"))\n \t\t*value = STATUS_FORMAT_PORCELAIN;\n+\telse if (!strcmp(arg, \"v2\") || !strcmp(arg, \"2\"))\n+\t\t*value = STATUS_FORMAT_PORCELAIN_V2;\n \telse\n \t\tdie(\"unsupported porcelain version '%s'\", arg);\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 e0dda24..dd0a1ab 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -434,6 +434,31 @@ 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+\n+\t\tswitch (p->status) {\n+\t\tcase DIFF_STATUS_ADDED:\n+\t\t\tdie(\"BUG: worktree status add???\");\n+\t\t\tbreak;\n+\n+\t\tcase DIFF_STATUS_DELETED:\n+\t\t\td->mode_index = p->one->mode;\n+\t\t\toidcpy(&d->oid_index, &p->one->oid);\n+\t\t\t/* mode_worktree is zero for a delete. */\n+\t\t\tbreak;\n+\n+\t\tcase DIFF_STATUS_MODIFIED:\n+\t\tcase DIFF_STATUS_TYPE_CHANGED:\n+\t\tcase DIFF_STATUS_UNMERGED:\n+\t\t\td->mode_index = p->one->mode;\n+\t\t\td->mode_worktree = p->two->mode;\n+\t\t\toidcpy(&d->oid_index, &p->one->oid);\n+\t\t\tbreak;\n+\n+\t\tcase DIFF_STATUS_UNKNOWN:\n+\t\t\tdie(\"BUG: worktree status unknown???\");\n+\t\t\tbreak;\n+\t\t}\n+\n \t}\n }\n \n@@ -479,12 +504,36 @@ static void wt_status_collect_updated_cb(struct diff_queue_struct *q,\n \t\tif (!d->index_status)\n \t\t\td->index_status = p->status;\n \t\tswitch (p->status) {\n+\t\tcase DIFF_STATUS_ADDED:\n+\t\t\t/* Leave {mode,oid}_head zero for an add. */\n+\t\t\td->mode_index = p->two->mode;\n+\t\t\toidcpy(&d->oid_index, &p->two->oid);\n+\t\t\tbreak;\n+\t\tcase DIFF_STATUS_DELETED:\n+\t\t\td->mode_head = p->one->mode;\n+\t\t\toidcpy(&d->oid_head, &p->one->oid);\n+\t\t\t/* Leave {mode,oid}_index zero for a delete. */\n+\t\t\tbreak;\n+\n \t\tcase DIFF_STATUS_COPIED:\n \t\tcase DIFF_STATUS_RENAMED:\n \t\t\td->head_path = xstrdup(p->one->path);\n+\t\t\td->score = p->score * 100 / MAX_SCORE;\n+\t\t\t/* fallthru */\n+\t\tcase DIFF_STATUS_MODIFIED:\n+\t\tcase DIFF_STATUS_TYPE_CHANGED:\n+\t\t\td->mode_head = p->one->mode;\n+\t\t\td->mode_index = p->two->mode;\n+\t\t\toidcpy(&d->oid_head, &p->one->oid);\n+\t\t\toidcpy(&d->oid_index, &p->two->oid);\n \t\t\tbreak;\n \t\tcase DIFF_STATUS_UNMERGED:\n \t\t\td->stagemask = unmerged_mask(p->two->path);\n+\t\t\t/*\n+\t\t\t * Don't bother setting {mode,oid}_{head,index} since the print\n+\t\t\t * code will output the stage values directly and not use the\n+\t\t\t * values in these fields.\n+\t\t\t */\n \t\t\tbreak;\n \t\t}\n \t}\n@@ -565,9 +614,17 @@ static void wt_status_collect_changes_initial(struct wt_status *s)\n \t\tif (ce_stage(ce)) {\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\t\t/*\n+\t\t\t * Don't bother setting {mode,oid}_{head,index} since the print\n+\t\t\t * code will output the stage values directly and not use the\n+\t\t\t * values in these fields.\n+\t\t\t */\n+\t\t} else {\n \t\t\td->index_status = DIFF_STATUS_ADDED;\n+\t\t\t/* Leave {mode,oid}_head zero for adds. */\n+\t\t\td->mode_index = ce->ce_mode;\n+\t\t\thashcpy(d->oid_index.hash, ce->sha1);\n+\t\t}\n \t}\n }\n \n@@ -1764,6 +1821,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 9389076..43fd3fc 100644\n--- a/wt-status.h\n+++ b/wt-status.h\n@@ -38,6 +38,9 @@ struct wt_status_change_data {\n \tint worktree_status;\n \tint index_status;\n \tint stagemask;\n+\tint score;\n+\tint mode_head, mode_index, mode_worktree;\n+\tstruct object_id oid_head, oid_index;\n \tchar *head_path;\n \tunsigned dirty_submodule       : 2;\n \tunsigned new_submodule_commits : 1;\n@@ -48,6 +51,7 @@ enum wt_status_format {\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":"298848","messageId":"1471016692-35828-2-git-send-email-git@jeffhostetler.com","threadId":"43796","inReplyTo":"1471016692-35828-1-git-send-email-git@jeffhostetler.com","subject":"[PATCH v8 1/9] status: rename long-format print routines","fromName":"Jeff Hostetler","fromEmail":"git@jeffhostetler.com","sentAt":"2016-08-12T15:44:44Z","receivedAt":"2016-08-12T15:48:58Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"From: Jeff Hostetler <jeffhost@microsoft.com>\n\nRename 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 and reduce developer confusion as other\nstatus formats 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 19cbc39..961bbc7 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":"298849","messageId":"1471016692-35828-10-git-send-email-git@jeffhostetler.com","threadId":"43796","inReplyTo":"1471016692-35828-1-git-send-email-git@jeffhostetler.com","subject":"[PATCH v8 9/9] status: unit tests for --porcelain=v2","fromName":"Jeff Hostetler","fromEmail":"git@jeffhostetler.com","sentAt":"2016-08-12T15:44:52Z","receivedAt":"2016-08-12T15:49:01Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"From: Jeff Hostetler <jeffhost@microsoft.com>\n\nTest porcelain v2 status format.\n\nSigned-off-by: Jeff Hostetler <jeffhost@microsoft.com>\n---\n t/t7064-wtstatus-pv2.sh | 593 ++++++++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 593 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..3012a4d\n--- /dev/null\n+++ b/t/t7064-wtstatus-pv2.sh\n@@ -0,0 +1,593 @@\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+\n+test_expect_success setup '\n+\ttest_tick &&\n+\tgit config 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+test_expect_success 'before initial commit, nothing added, only untracked' '\n+\tcat >expect <<-EOF &&\n+\t# branch.oid (initial)\n+\t# branch.head master\n+\t? actual\n+\t? dir1/\n+\t? expect\n+\t? file_x\n+\t? file_y\n+\t? file_z\n+\tEOF\n+\n+\tgit status --porcelain=v2 --branch --untracked-files=normal >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'before initial commit, things added' '\n+\tgit add file_x file_y file_z dir1 &&\n+\tOID_A=$(git hash-object -t blob -- dir1/file_a) &&\n+\tOID_B=$(git hash-object -t blob -- dir1/file_b) &&\n+\tOID_X=$(git hash-object -t blob -- file_x) &&\n+\tOID_Y=$(git hash-object -t blob -- file_y) &&\n+\tOID_Z=$(git hash-object -t blob -- file_z) &&\n+\n+\tcat >expect <<-EOF &&\n+\t# branch.oid (initial)\n+\t# branch.head master\n+\t1 A. N... 000000 100644 100644 $_z40 $OID_A dir1/file_a\n+\t1 A. N... 000000 100644 100644 $_z40 $OID_B dir1/file_b\n+\t1 A. N... 000000 100644 100644 $_z40 $OID_X file_x\n+\t1 A. N... 000000 100644 100644 $_z40 $OID_Y file_y\n+\t1 A. N... 000000 100644 100644 $_z40 $OID_Z file_z\n+\t? actual\n+\t? expect\n+\tEOF\n+\n+\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'before initial commit, things added (-z)' '\n+\tlf_to_nul >expect <<-EOF &&\n+\t# branch.oid (initial)\n+\t# branch.head master\n+\t1 A. N... 000000 100644 100644 $_z40 $OID_A dir1/file_a\n+\t1 A. N... 000000 100644 100644 $_z40 $OID_B dir1/file_b\n+\t1 A. N... 000000 100644 100644 $_z40 $OID_X file_x\n+\t1 A. N... 000000 100644 100644 $_z40 $OID_Y file_y\n+\t1 A. N... 000000 100644 100644 $_z40 $OID_Z file_z\n+\t? actual\n+\t? expect\n+\tEOF\n+\n+\tgit status -z --porcelain=v2 --branch --untracked-files=all >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'make first commit, comfirm HEAD oid and branch' '\n+\tgit commit -m initial &&\n+\tH0=$(git rev-parse HEAD) &&\n+\tcat >expect <<-EOF &&\n+\t# branch.oid $H0\n+\t# branch.head master\n+\t? actual\n+\t? expect\n+\tEOF\n+\n+\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'after first commit, create unstaged changes' '\n+\techo x >>file_x &&\n+\tOID_X1=$(git hash-object -t blob -- file_x) &&\n+\trm file_z &&\n+\tH0=$(git rev-parse HEAD) &&\n+\n+\tcat >expect <<-EOF &&\n+\t# branch.oid $H0\n+\t# branch.head master\n+\t1 .M N... 100644 100644 100644 $OID_X $OID_X file_x\n+\t1 .D N... 100644 100644 000000 $OID_Z $OID_Z file_z\n+\t? actual\n+\t? expect\n+\tEOF\n+\n+\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'after first commit but omit untracked files and branch' '\n+\tcat >expect <<-EOF &&\n+\t1 .M N... 100644 100644 100644 $OID_X $OID_X file_x\n+\t1 .D N... 100644 100644 000000 $OID_Z $OID_Z file_z\n+\tEOF\n+\n+\tgit status --porcelain=v2 --untracked-files=no >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'after first commit, stage existing changes' '\n+\tgit add file_x &&\n+\tgit rm file_z &&\n+\tH0=$(git rev-parse HEAD) &&\n+\n+\tcat >expect <<-EOF &&\n+\t# branch.oid $H0\n+\t# branch.head master\n+\t1 M. N... 100644 100644 100644 $OID_X $OID_X1 file_x\n+\t1 D. N... 100644 000000 000000 $OID_Z $_z40 file_z\n+\t? actual\n+\t? expect\n+\tEOF\n+\n+\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'rename causes 2 path lines' '\n+\tgit mv file_y renamed_y &&\n+\tH0=$(git rev-parse HEAD) &&\n+\n+\tq_to_tab >expect <<-EOF &&\n+\t# branch.oid $H0\n+\t# branch.head master\n+\t1 M. N... 100644 100644 100644 $OID_X $OID_X1 file_x\n+\t1 D. N... 100644 000000 000000 $OID_Z $_z40 file_z\n+\t2 R. N... 100644 100644 100644 $OID_Y $OID_Y R100 renamed_yQfile_y\n+\t? actual\n+\t? expect\n+\tEOF\n+\n+\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'rename causes 2 path lines (-z)' '\n+\tH0=$(git rev-parse HEAD) &&\n+\n+\t## Lines use NUL path separator and line terminator, so double transform here.\n+\tq_to_nul <<-EOF | lf_to_nul >expect &&\n+\t# branch.oid $H0\n+\t# branch.head master\n+\t1 M. N... 100644 100644 100644 $OID_X $OID_X1 file_x\n+\t1 D. N... 100644 000000 000000 $OID_Z $_z40 file_z\n+\t2 R. N... 100644 100644 100644 $OID_Y $OID_Y R100 renamed_yQfile_y\n+\t? actual\n+\t? expect\n+\tEOF\n+\n+\tgit status --porcelain=v2 --branch --untracked-files=all -z >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'make second commit, confirm clean and new HEAD oid' '\n+\tgit commit -m second &&\n+\tH1=$(git rev-parse HEAD) &&\n+\n+\tcat >expect <<-EOF &&\n+\t# branch.oid $H1\n+\t# branch.head master\n+\t? actual\n+\t? expect\n+\tEOF\n+\n+\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'confirm ignored files are not printed' '\n+\ttest_when_finished \"rm -f x.ign .gitignore\" &&\n+\techo x.ign >.gitignore &&\n+\techo \"ignore me\" >x.ign &&\n+\n+\tcat >expect <<-EOF &&\n+\t? .gitignore\n+\t? actual\n+\t? expect\n+\tEOF\n+\n+\tgit status --porcelain=v2 --untracked-files=all >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'ignored files are printed with --ignored' '\n+\ttest_when_finished \"rm -f x.ign .gitignore\" &&\n+\techo x.ign >.gitignore &&\n+\techo \"ignore me\" >x.ign &&\n+\n+\tcat >expect <<-EOF &&\n+\t? .gitignore\n+\t? actual\n+\t? expect\n+\t! x.ign\n+\tEOF\n+\n+\tgit status --porcelain=v2 --ignored --untracked-files=all >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'create and commit permanent ignore file' '\n+\tcat >.gitignore <<-EOF &&\n+\tactual*\n+\texpect*\n+\tEOF\n+\n+\tgit add .gitignore &&\n+\tgit commit -m ignore_trash &&\n+\tH1=$(git rev-parse HEAD) &&\n+\n+\tcat >expect <<-EOF &&\n+\t# branch.oid $H1\n+\t# branch.head master\n+\tEOF\n+\n+\tgit status --porcelain=v2 --branch >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'verify --intent-to-add output' '\n+\ttest_when_finished \"git rm -f intent1.add intent2.add\" &&\n+\ttouch intent1.add &&\n+\techo test >intent2.add &&\n+\n+\tgit add --intent-to-add intent1.add intent2.add &&\n+\n+\tcat >expect <<-EOF &&\n+\t1 AM N... 000000 100644 100644 $_z40 $EMPTY_BLOB intent1.add\n+\t1 AM N... 000000 100644 100644 $_z40 $EMPTY_BLOB intent2.add\n+\tEOF\n+\n+\tgit status --porcelain=v2 >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'verify AA (add-add) conflict' '\n+\ttest_when_finished \"git reset --hard\" &&\n+\n+\tgit branch AA_A master &&\n+\tgit checkout AA_A &&\n+\techo \"Branch AA_A\" >conflict.txt &&\n+\tOID_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+\tOID_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 >expect <<-EOF &&\n+\t# branch.oid $HM\n+\t# branch.head AA_M\n+\tu AA N... 000000 100644 100644 100644 $_z40 $OID_AA_B $OID_AA_A conflict.txt\n+\tEOF\n+\n+\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'verify UU (edit-edit) conflict' '\n+\ttest_when_finished \"git reset --hard\" &&\n+\n+\tgit branch UU_ANC master &&\n+\tgit checkout UU_ANC &&\n+\techo \"Ancestor\" >conflict.txt &&\n+\tOID_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+\tOID_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+\tOID_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 >expect <<-EOF &&\n+\t# branch.oid $HM\n+\t# branch.head UU_M\n+\tu UU N... 100644 100644 100644 100644 $OID_UU_ANC $OID_UU_B $OID_UU_A conflict.txt\n+\tEOF\n+\n+\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'verify upstream fields in branch header' '\n+\tgit checkout master &&\n+\ttest_when_finished \"rm -rf sub_repo\" &&\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 >expect <<-EOF &&\n+\t\t# branch.oid $HUF\n+\t\t# branch.head master\n+\t\t# branch.upstream origin/master\n+\t\t# branch.ab +0 -0\n+\t\tEOF\n+\n+\t\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n+\t\ttest_cmp expect 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 >expect <<-EOF &&\n+\t\t# branch.oid $HUF\n+\t\t# branch.head master\n+\t\t# branch.upstream origin/master\n+\t\t# branch.ab +1 -0\n+\t\tEOF\n+\n+\t\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n+\t\ttest_cmp expect actual &&\n+\n+\t\t## Repeat the above but without --branch.\n+\t\tcat >expect <<-EOF &&\n+\t\tEOF\n+\n+\t\tgit status --porcelain=v2 --untracked-files=all >actual &&\n+\t\ttest_cmp expect 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=$_z40 &&\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 >expect <<-EOF &&\n+\t\t# branch.oid $HUF\n+\t\t# branch.head master\n+\t\t# branch.upstream origin/master\n+\t\tEOF\n+\n+\t\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n+\t\ttest_cmp expect actual\n+\t)\n+'\n+\n+test_expect_success 'create and add submodule, submodule appears clean (A. S...)' '\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 >expect <<-EOF &&\n+\t\t# branch.oid $HSUP\n+\t\t# branch.head master\n+\t\t# branch.upstream origin/master\n+\t\t# branch.ab +0 -0\n+\t\t1 A. N... 000000 100644 100644 $_z40 $HMOD .gitmodules\n+\t\t1 A. S... 000000 160000 160000 $_z40 $HSUB sub1\n+\t\tEOF\n+\n+\t\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n+\t\ttest_cmp expect actual\n+\t)\n+'\n+\n+test_expect_success 'untracked changes in added submodule (AM S..U)' '\n+\t(\tcd super_repo &&\n+\t\t## create untracked file in the submodule.\n+\t\t(\tcd sub1 &&\n+\t\t\techo \"xxxx\" >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 >expect <<-EOF &&\n+\t\t# branch.oid $HSUP\n+\t\t# branch.head master\n+\t\t# branch.upstream origin/master\n+\t\t# branch.ab +0 -0\n+\t\t1 A. N... 000000 100644 100644 $_z40 $HMOD .gitmodules\n+\t\t1 AM S..U 000000 160000 160000 $_z40 $HSUB sub1\n+\t\tEOF\n+\n+\t\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n+\t\ttest_cmp expect actual\n+\t)\n+'\n+\n+test_expect_success 'staged changes in added submodule (AM S.M.)' '\n+\t(\tcd super_repo &&\n+\t\t## stage the changes 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 >expect <<-EOF &&\n+\t\t# branch.oid $HSUP\n+\t\t# branch.head master\n+\t\t# branch.upstream origin/master\n+\t\t# branch.ab +0 -0\n+\t\t1 A. N... 000000 100644 100644 $_z40 $HMOD .gitmodules\n+\t\t1 AM S.M. 000000 160000 160000 $_z40 $HSUB sub1\n+\t\tEOF\n+\n+\t\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n+\t\ttest_cmp expect actual\n+\t)\n+'\n+\n+test_expect_success 'staged and unstaged changes in added (AM S.M.)' '\n+\t(\tcd super_repo &&\n+\t\t(\tcd sub1 &&\n+\t\t\t## make additional unstaged changes (on the same file) in the submodule.\n+\t\t\t## This does not cause us to get S.MU (because the submodule does not report\n+\t\t\t## a \"?\" line for the unstaged changes).\n+\t\t\techo \"more changes\" >>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 >expect <<-EOF &&\n+\t\t# branch.oid $HSUP\n+\t\t# branch.head master\n+\t\t# branch.upstream origin/master\n+\t\t# branch.ab +0 -0\n+\t\t1 A. N... 000000 100644 100644 $_z40 $HMOD .gitmodules\n+\t\t1 AM S.M. 000000 160000 160000 $_z40 $HSUB sub1\n+\t\tEOF\n+\n+\t\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n+\t\ttest_cmp expect actual\n+\t)\n+'\n+\n+test_expect_success 'staged and untracked changes in added submodule (AM S.MU)' '\n+\t(\tcd super_repo &&\n+\t\t(\tcd sub1 &&\n+\t\t\t## stage new changes in tracked file.\n+\t\t\tgit add file_in_sub &&\n+\t\t\t## create new untracked file.\n+\t\t\techo \"yyyy\" >>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 >expect <<-EOF &&\n+\t\t# branch.oid $HSUP\n+\t\t# branch.head master\n+\t\t# branch.upstream origin/master\n+\t\t# branch.ab +0 -0\n+\t\t1 A. N... 000000 100644 100644 $_z40 $HMOD .gitmodules\n+\t\t1 AM S.MU 000000 160000 160000 $_z40 $HSUB sub1\n+\t\tEOF\n+\n+\t\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n+\t\ttest_cmp expect actual\n+\t)\n+'\n+\n+test_expect_success 'commit within the submodule appears as new commit in super (AM SC..)' '\n+\t(\tcd super_repo &&\n+\t\t(\tcd sub1 &&\n+\t\t\t## Make a new commit in the submodule.\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 >expect <<-EOF &&\n+\t\t# branch.oid $HSUP\n+\t\t# branch.head master\n+\t\t# branch.upstream origin/master\n+\t\t# branch.ab +0 -0\n+\t\t1 A. N... 000000 100644 100644 $_z40 $HMOD .gitmodules\n+\t\t1 AM SC.. 000000 160000 160000 $_z40 $HSUB sub1\n+\t\tEOF\n+\n+\t\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n+\t\ttest_cmp expect actual\n+\t)\n+'\n+\n+test_expect_success 'stage submodule in super and commit' '\n+\t(\tcd super_repo &&\n+\t\t## Stage the new submodule commit in the super.\n+\t\tgit add sub1 &&\n+\t\t## Commit the super so that the sub no longer appears as added.\n+\t\tgit commit -m \"super commit\" &&\n+\n+\t\tHSUP=$(git rev-parse HEAD) &&\n+\n+\t\tcat >expect <<-EOF &&\n+\t\t# branch.oid $HSUP\n+\t\t# branch.head master\n+\t\t# branch.upstream origin/master\n+\t\t# branch.ab +1 -0\n+\t\tEOF\n+\n+\t\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n+\t\ttest_cmp expect actual\n+\t)\n+'\n+\n+test_expect_success 'make unstaged changes in existing submodule (.M S.M.)' '\n+\t(\tcd super_repo &&\n+\t\t(\tcd sub1 &&\n+\t\t\techo \"zzzz\" >>file_in_sub\n+\t\t) &&\n+\n+\t\tHSUP=$(git rev-parse HEAD) &&\n+\t\tHSUB=$(cd sub1 && git rev-parse HEAD) &&\n+\n+\t\tcat >expect <<-EOF &&\n+\t\t# branch.oid $HSUP\n+\t\t# branch.head master\n+\t\t# branch.upstream origin/master\n+\t\t# branch.ab +1 -0\n+\t\t1 .M S.M. 160000 160000 160000 $HSUB $HSUB sub1\n+\t\tEOF\n+\n+\t\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n+\t\ttest_cmp expect actual\n+\t)\n+'\n+\n+test_done\n-- \n2.8.0.rc4.17.gac42084.dirty\n\n"},{"id":"298850","messageId":"1471016692-35828-3-git-send-email-git@jeffhostetler.com","threadId":"43796","inReplyTo":"1471016692-35828-1-git-send-email-git@jeffhostetler.com","subject":"[PATCH v8 2/9] status: cleanup API to wt_status_print","fromName":"Jeff Hostetler","fromEmail":"git@jeffhostetler.com","sentAt":"2016-08-12T15:44:45Z","receivedAt":"2016-08-12T15:49:02Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"From: Jeff Hostetler <jeffhost@microsoft.com>\n\nRefactor the API between builtin/commit.c and wt-status.[ch].\n\nHide the details of the various wt_*status_print() routines inside\nwt-status.c behind a single (new) wt_status_print() routine.\nEliminate the switch statements from builtin/commit.c.\nAllow details of new status formats to be isolated 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 961bbc7..e0dda24 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..9389076 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":"298851","messageId":"1471016692-35828-8-git-send-email-git@jeffhostetler.com","threadId":"43796","inReplyTo":"1471016692-35828-1-git-send-email-git@jeffhostetler.com","subject":"[PATCH v8 7/9] git-status.txt: describe --porcelain=v2 format","fromName":"Jeff Hostetler","fromEmail":"git@jeffhostetler.com","sentAt":"2016-08-12T15:44:50Z","receivedAt":"2016-08-12T15:49:05Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"From: Jeff Hostetler <jeffhost@microsoft.com>\n\nUpdate status manpage to include information about\nporcelain v2 format.\n\nSigned-off-by: Jeff Hostetler <jeffhost@microsoft.com>\n---\n Documentation/git-status.txt | 126 +++++++++++++++++++++++++++++++++++++++++--\n 1 file changed, 122 insertions(+), 4 deletions(-)\n\ndiff --git a/Documentation/git-status.txt b/Documentation/git-status.txt\nindex 6b1454b..a58973b 100644\n--- a/Documentation/git-status.txt\n+++ b/Documentation/git-status.txt\n@@ -183,12 +183,12 @@ in which case `XY` are `!!`.\n \n If -b is used the short-format status is preceded by a line\n \n-## branchname tracking info\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,124 @@ 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 changed items.  Version 2 also defines an extensible\n+set of easy to parse optional headers.\n+\n+Header lines start with \"#\" and are added in response to specific\n+command line arguments.  Parsers should ignore headers they\n+don't recognize.\n+\n+### Branch Headers\n+\n+If `--branch` is given, a series of header lines are printed with\n+information about the current branch.\n+\n+    Line                                     Notes\n+    ------------------------------------------------------------\n+    # branch.oid <commit> | (initial)        Current commit.\n+    # branch.head <branch> | (detached)      Current branch.\n+    # branch.upstream <upstream_branch>      If upstream is set.\n+    # branch.ab +<ahead> -<behind>           If upstream is set and\n+                                             the commit is present.\n+    ------------------------------------------------------------\n+\n+### Changed Tracked Entries\n+\n+Following the headers, a series of lines are printed for tracked\n+entries.  One of three different line formats may be used to describe\n+an entry depending on the type of change.  Tracked entries are printed\n+in an undefined order; parsers should allow for a mixture of the 3\n+line types in any order.\n+\n+Ordinary changed entries have the following format:\n+\n+    1 <XY> <sub> <mH> <mI> <mW> <hH> <hI> <path>\n+\n+Renamed or copied entries have the following format:\n+\n+    2 <XY> <sub> <mH> <mI> <mW> <hH> <hI> <X><score> <path><sep><origPath>\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+    <mH>        The octal file mode in HEAD.\n+    <mI>        The octal file mode in the index.\n+    <mW>        The octal file mode in the worktree.\n+    <hH>        The object name in HEAD.\n+    <hI>        The object name in the index.\n+    <X><score>  The rename or copy score (denoting the percentage\n+                of similarity between the source and target of the\n+                move or copy). For example \"R100\" or \"C75\".\n+    <path>      The pathname.  In a renamed/copied entry, this\n+                is the path in the index and in the working tree.\n+    <sep>       When the `-z` option is used, the 2 pathnames are separated\n+                with a NUL (ASCII 0x00) byte; otherwise, a tab (ASCII 0x09)\n+                byte separates them.\n+    <origPath>  The pathname in the commit at HEAD.  This is only\n+                present in a renamed/copied entry, and tells\n+                where the renamed/copied contents came from.\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> <mW> <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+    <m1>        The octal file mode in stage 1.\n+    <m2>        The octal file mode in stage 2.\n+    <m3>        The octal file mode in stage 3.\n+    <mW>        The octal file mode in the worktree.\n+    <h1>        The object name in stage 1.\n+    <h2>        The object name in stage 2.\n+    <h3>        The object name in stage 3.\n+    <path>      The pathname.\n+    --------------------------------------------------------\n+\n+### Other Items\n+\n+Following the tracked entries (and if requested), a series of\n+lines will be printed for untracked and then ignored items\n+found in the worktree.\n+\n+Untracked items have the following format:\n+\n+    ? <path>\n+\n+Ignored items have the following format:\n+\n+    ! <path>\n+\n+### Pathname Format Notes and -z\n+\n+When the `-z` option is given, pathnames are printed as is and\n+without any quoting and lines are terminated with a NUL (ASCII 0x00)\n+byte.\n+\n+Otherwise, all pathnames will be \"C-quoted\" if they contain any tab,\n+linefeed, double quote, or backslash characters. In C-quoting, these\n+characters will be replaced with the corresponding C-style escape\n+sequences and the resulting pathname will be double quoted.\n+\n+\n CONFIGURATION\n -------------\n \n-- \n2.8.0.rc4.17.gac42084.dirty\n\n"},{"id":"298852","messageId":"1471016692-35828-4-git-send-email-git@jeffhostetler.com","threadId":"43796","inReplyTo":"1471016692-35828-1-git-send-email-git@jeffhostetler.com","subject":"[PATCH v8 3/9] status: support --porcelain[=<version>]","fromName":"Jeff Hostetler","fromEmail":"git@jeffhostetler.com","sentAt":"2016-08-12T15:44:46Z","receivedAt":"2016-08-12T15:49:07Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"From: Jeff Hostetler <jeffhost@microsoft.com>\n\nUpdate --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.  (The token \"1\" is an alias for that.)\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..185ac35 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\") || !strcmp(arg, \"1\"))\n+\t\t*value = STATUS_FORMAT_PORCELAIN;\n+\telse\n+\t\tdie(\"unsupported porcelain version '%s'\", arg);\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":"298853","messageId":"1471016692-35828-9-git-send-email-git@jeffhostetler.com","threadId":"43796","inReplyTo":"1471016692-35828-1-git-send-email-git@jeffhostetler.com","subject":"[PATCH v8 8/9] test-lib-functions.sh: Add lf_to_nul","fromName":"Jeff Hostetler","fromEmail":"git@jeffhostetler.com","sentAt":"2016-08-12T15:44:51Z","receivedAt":"2016-08-12T15:49:09Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"From: Jeff Hostetler <jeffhost@microsoft.com>\n\nAdd lf_to_nul() function to test-lib-functions.\n\nSigned-off-by: Jeff Hostetler <jeffhost@microsoft.com>\n---\n t/test-lib-functions.sh | 4 ++++\n 1 file changed, 4 insertions(+)\n\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex 4f7eadb..fdaeb3a 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -81,6 +81,10 @@ test_decode_color () {\n \t'\n }\n \n+lf_to_nul () {\n+\tperl -pe 'y/\\012/\\000/'\n+}\n+\n nul_to_q () {\n \tperl -pe 'y/\\000/Q/'\n }\n-- \n2.8.0.rc4.17.gac42084.dirty\n\n"},{"id":"298854","messageId":"1471016692-35828-6-git-send-email-git@jeffhostetler.com","threadId":"43796","inReplyTo":"1471016692-35828-1-git-send-email-git@jeffhostetler.com","subject":"[PATCH v8 5/9] status: print per-file porcelain v2 status data","fromName":"Jeff Hostetler","fromEmail":"git@jeffhostetler.com","sentAt":"2016-08-12T15:44:48Z","receivedAt":"2016-08-12T15:49:12Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"From: Jeff Hostetler <jeffhost@microsoft.com>\n\nPrint 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 dd0a1ab..bd9075b 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -1812,6 +1812,289 @@ static void wt_porcelain_print(struct wt_status *s)\n \twt_shortstatus_print(s);\n }\n \n+/*\n+ * Convert various submodule status values into a\n+ * fixed-length 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->mode_head) ||\n+\t\tS_ISGITLINK(d->mode_index) ||\n+\t\tS_ISGITLINK(d->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->mode_head == 0);\n+\t\td->mode_head = d->mode_index;\n+\t\toidcpy(&d->oid_head, &d->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->mode_worktree == 0);\n+\t\td->mode_worktree = d->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_index = STRBUF_INIT;\n+\tstruct strbuf buf_head = STRBUF_INIT;\n+\tconst char *path_index = NULL;\n+\tconst char *path_head = NULL;\n+\tchar key[3];\n+\tchar submodule_token[5];\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_index = it->string;\n+\t\tpath_head = 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 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_index = quote_path(it->string, s->prefix, &buf_index);\n+\t\tif (d->head_path)\n+\t\t\tpath_head = quote_path(d->head_path, s->prefix, &buf_head);\n+\t}\n+\n+\tif (path_head)\n+\t\tfprintf(s->fp, \"2 %s %s %06o %06o %06o %s %s %c%d %s%c%s%c\",\n+\t\t\t\tkey, submodule_token,\n+\t\t\t\td->mode_head, d->mode_index, d->mode_worktree,\n+\t\t\t\toid_to_hex(&d->oid_head), oid_to_hex(&d->oid_index),\n+\t\t\t\tkey[0], d->score,\n+\t\t\t\tpath_index, sep_char, path_head, eol_char);\n+\telse\n+\t\tfprintf(s->fp, \"1 %s %s %06o %06o %06o %s %s %s%c\",\n+\t\t\t\tkey, submodule_token,\n+\t\t\t\td->mode_head, d->mode_index, d->mode_worktree,\n+\t\t\t\toid_to_hex(&d->oid_head), oid_to_hex(&d->oid_index),\n+\t\t\t\tpath_index, eol_char);\n+\n+\tstrbuf_release(&buf_index);\n+\tstrbuf_release(&buf_head);\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_index = STRBUF_INIT;\n+\tconst char *path_index = 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+\tdefault:\n+\t\tdie(\"BUG: unhandled unmerged status %x\", d->stagemask);\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 entries\n+\t * for same 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 |= (1 << (stage - 1));\n+\t}\n+\tif (sum != d->stagemask)\n+\t\tdie(\"BUG: observed stagemask 0x%x != expected stagemask 0x%x\", sum, d->stagemask);\n+\n+\tif (s->null_termination)\n+\t\tpath_index = it->string;\n+\telse\n+\t\tpath_index = quote_path(it->string, s->prefix, &buf_index);\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->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_index,\n+\t\t\teol_char);\n+\n+\tstrbuf_release(&buf_index);\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+static 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+\n void wt_status_print(struct wt_status *s)\n {\n \tswitch (s->status_format) {\n@@ -1822,7 +2105,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-- \n2.8.0.rc4.17.gac42084.dirty\n\n"},{"id":"298855","messageId":"1471016692-35828-7-git-send-email-git@jeffhostetler.com","threadId":"43796","inReplyTo":"1471016692-35828-1-git-send-email-git@jeffhostetler.com","subject":"[PATCH v8 6/9] status: print branch info with --porcelain=v2 --branch","fromName":"Jeff Hostetler","fromEmail":"git@jeffhostetler.com","sentAt":"2016-08-12T15:44:49Z","receivedAt":"2016-08-12T15:49:13Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"From: Jeff Hostetler <jeffhost@microsoft.com>\n\nExpand porcelain v2 output to include branch and tracking\nbranch information. This includes the commit id, 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      | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n wt-status.h      |  1 +\n 3 files changed, 96 insertions(+)\n\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 3d222d3..5504afe 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 bd9075b..ebe4a1e 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -1813,6 +1813,92 @@ static void wt_porcelain_print(struct wt_status *s)\n }\n \n /*\n+ * Print branch information for porcelain v2 output.  These lines\n+ * are printed when the '--branch' parameter is given.\n+ *\n+ *    # branch.oid <commit><eol>\n+ *    # branch.head <head><eol>\n+ *   [# branch.upstream <upstream><eol>\n+ *   [# branch.ab +<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 the commit is present (not gone).\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+\tchar eol = s->null_termination ? '\\0' : '\\n';\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.oid %s%c\",\n+\t\t\t(s->is_initial ? \"(initial)\" : sha1_to_hex(s->sha1_commit)),\n+\t\t\teol);\n+\n+\tif (!s->branch)\n+\t\tfprintf(s->fp, \"# branch.head %s%c\", \"(unknown)\", eol);\n+\telse {\n+\t\tif (!strcmp(s->branch, \"HEAD\")) {\n+\t\t\tfprintf(s->fp, \"# branch.head %s%c\", \"(detached)\", eol);\n+\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+\n+\t\t\tfprintf(s->fp, \"# branch.head %s%c\", branch_name, eol);\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, \"# branch.upstream %s%c\", base, eol);\n+\t\t\tfree((char *)base);\n+\n+\t\t\tif (ab_info)\n+\t\t\t\tfprintf(s->fp, \"# branch.ab +%d -%d%c\", nr_ahead, nr_behind, eol);\n+\t\t}\n+\t}\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  * fixed-length string of characters in the buffer provided.\n  */\n@@ -2058,6 +2144,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@@ -2070,6 +2157,9 @@ static 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 43fd3fc..e401837 100644\n--- a/wt-status.h\n+++ b/wt-status.h\n@@ -80,6 +80,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":"298927","messageId":"xmqqfuq9vdwd.fsf@gitster.mtv.corp.google.com","threadId":"43796","inReplyTo":"1471016692-35828-1-git-send-email-git@jeffhostetler.com","subject":"Re: [PATCH v8 0/9] status: V2 porcelain status","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-08-12T22:08:34Z","receivedAt":"2016-08-12T22:08:42Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff Hostetler <git@jeffhostetler.com> writes:\n\n> This v8 patch series addresses the remaining feedback\n> about the unit tests from the v6 and v7 series.\n\nThanks, will re-queue.\n\nI didn't spot anything glaringly wrong in the last patch, and all\nthe ealier steps looked good in the previous round, so I think we\nare getting there.\n"}]}