{"thread":{"id":"43019","subject":"[PATCH v5 0/9] status: V2 porcelain status","startedAt":"2016-08-05T22:03:17Z","lastAt":"2016-08-10T23:27:12Z","messageCount":19,"participants":["Jeff Hostetler","Junio C Hamano","Johannes Schindelin","Eric Wong"],"isPatch":true,"patchVersion":5,"patchTotal":9},"messages":[{"id":"293261","messageId":"1470434434-64283-1-git-send-email-git@jeffhostetler.com","threadId":"43019","inReplyTo":null,"subject":"[PATCH v5 0/9] status: V2 porcelain status","fromName":"Jeff Hostetler","fromEmail":"git@jeffhostetler.com","sentAt":"2016-08-05T22:00:25Z","receivedAt":"2016-08-05T22:03:17Z","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 v5 patch series addresses all comments received\ntoday about the v4 patch series. It includes updates\nto the manpage and the unit tests and minor cleanup.\n\nNew in this series is a change to test-lib-functions.sh\nto add lf_to_nul().\n\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      | 597 +++++++++++++++++++++++++++++++++++++++++++\n t/test-lib-functions.sh      |   4 +\n wt-status.c                  | 569 ++++++++++++++++++++++++++++++++++++-----\n wt-status.h                  |  19 +-\n 7 files changed, 1310 insertions(+), 111 deletions(-)\n create mode 100755 t/t7064-wtstatus-pv2.sh\n\n-- \n2.8.0.rc4.17.gac42084.dirty\n\n"},{"id":"293262","messageId":"1470434434-64283-3-git-send-email-git@jeffhostetler.com","threadId":"43019","inReplyTo":"1470434434-64283-1-git-send-email-git@jeffhostetler.com","subject":"[PATCH v5 2/9] status: cleanup API to wt_status_print","fromName":"Jeff Hostetler","fromEmail":"git@jeffhostetler.com","sentAt":"2016-08-05T22:00:27Z","receivedAt":"2016-08-05T22:03:29Z","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 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..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":"293263","messageId":"1470434434-64283-9-git-send-email-git@jeffhostetler.com","threadId":"43019","inReplyTo":"1470434434-64283-1-git-send-email-git@jeffhostetler.com","subject":"[PATCH v5 8/9] test-lib-functions.sh: Add lf_to_nul","fromName":"Jeff Hostetler","fromEmail":"git@jeffhostetler.com","sentAt":"2016-08-05T22:00:33Z","receivedAt":"2016-08-05T22:03:39Z","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":"293264","messageId":"1470434434-64283-7-git-send-email-git@jeffhostetler.com","threadId":"43019","inReplyTo":"1470434434-64283-1-git-send-email-git@jeffhostetler.com","subject":"[PATCH v5 6/9] status: print branch info with --porcelain=v2 --branch","fromName":"Jeff Hostetler","fromEmail":"git@jeffhostetler.com","sentAt":"2016-08-05T22:00:31Z","receivedAt":"2016-08-05T22:03:47Z","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 4b6a090..51405d2 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -1814,6 +1814,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@@ -2059,6 +2145,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@@ -2071,6 +2158,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":"293265","messageId":"1470434434-64283-10-git-send-email-git@jeffhostetler.com","threadId":"43019","inReplyTo":"1470434434-64283-1-git-send-email-git@jeffhostetler.com","subject":"[PATCH v5 9/9] status: unit tests for --porcelain=v2","fromName":"Jeff Hostetler","fromEmail":"git@jeffhostetler.com","sentAt":"2016-08-05T22:00:34Z","receivedAt":"2016-08-05T22:03:59Z","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 | 597 ++++++++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 597 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..edc65ce4\n--- /dev/null\n+++ b/t/t7064-wtstatus-pv2.sh\n@@ -0,0 +1,597 @@\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 output prior to initial commit.\n+##################################################################\n+\n+test_expect_success pre_initial_commit_0 '\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+\n+test_expect_success pre_initial_commit_1 '\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+## Try -z on the above\n+test_expect_success pre_initial_commit_2 '\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+##################################################################\n+## Create first commit. Confirm commit oid 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 >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+\n+test_expect_success initial_commit_1 '\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+\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 >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+\n+test_expect_success initial_commit_3 '\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+\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 >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+\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+\t## ignored file SHOULD NOT appear in output when --ignored is not used.\n+\tcat >expect <<-EOF &&\n+\t# branch.oid $H1\n+\t# branch.head master\n+\t? .gitignore\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+\t## ignored file SHOULD appear in output when --ignored is used.\n+\tcat >expect <<-EOF &&\n+\t# branch.oid $H1\n+\t# branch.head master\n+\t? .gitignore\n+\t? actual\n+\t? expect\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 expect actual\n+'\n+\n+##################################################################\n+## Create a permanent .gitignore file so we can stop worrying\n+## about test trash in subsequent tests.\n+##################################################################\n+\n+test_expect_success ignore_trash '\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+##################################################################\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+\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+\tgit reset --hard &&\n+\ttest_cmp expect 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+\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+\tgit reset --hard &&\n+\ttest_cmp expect 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+\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+\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 >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 '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 >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 '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 >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 '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 >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 '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 >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 '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 >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 '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 >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 '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 >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+##################################################################\n+## The end.\n+##################################################################\n+\n+test_done\n-- \n2.8.0.rc4.17.gac42084.dirty\n\n"},{"id":"293266","messageId":"1470434434-64283-8-git-send-email-git@jeffhostetler.com","threadId":"43019","inReplyTo":"1470434434-64283-1-git-send-email-git@jeffhostetler.com","subject":"[PATCH v5 7/9] git-status.txt: describe --porcelain=v2 format","fromName":"Jeff Hostetler","fromEmail":"git@jeffhostetler.com","sentAt":"2016-08-05T22:00:32Z","receivedAt":"2016-08-05T22:04:23Z","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":"293267","messageId":"1470434434-64283-4-git-send-email-git@jeffhostetler.com","threadId":"43019","inReplyTo":"1470434434-64283-1-git-send-email-git@jeffhostetler.com","subject":"[PATCH v5 3/9] status: support --porcelain[=<version>]","fromName":"Jeff Hostetler","fromEmail":"git@jeffhostetler.com","sentAt":"2016-08-05T22:00:28Z","receivedAt":"2016-08-05T22:04:30Z","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":"293268","messageId":"1470434434-64283-2-git-send-email-git@jeffhostetler.com","threadId":"43019","inReplyTo":"1470434434-64283-1-git-send-email-git@jeffhostetler.com","subject":"[PATCH v5 1/9] status: rename long-format print routines","fromName":"Jeff Hostetler","fromEmail":"git@jeffhostetler.com","sentAt":"2016-08-05T22:00:26Z","receivedAt":"2016-08-05T22:04:36Z","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 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":"293269","messageId":"1470434434-64283-5-git-send-email-git@jeffhostetler.com","threadId":"43019","inReplyTo":"1470434434-64283-1-git-send-email-git@jeffhostetler.com","subject":"[PATCH v5 4/9] status: collect per-file data for --porcelain=v2","fromName":"Jeff Hostetler","fromEmail":"git@jeffhostetler.com","sentAt":"2016-08-05T22:00:29Z","receivedAt":"2016-08-05T22:04: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      | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-\n wt-status.h      |  4 ++++\n 3 files changed, 69 insertions(+), 1 deletion(-)\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 a9031e4..ca8023e 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,18 @@ 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\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}\n-\t\telse\n+\t\telse {\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 +1822,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":"293270","messageId":"1470434434-64283-6-git-send-email-git@jeffhostetler.com","threadId":"43019","inReplyTo":"1470434434-64283-1-git-send-email-git@jeffhostetler.com","subject":"[PATCH v5 5/9] status: print per-file porcelain v2 status data","fromName":"Jeff Hostetler","fromEmail":"git@jeffhostetler.com","sentAt":"2016-08-05T22:00:30Z","receivedAt":"2016-08-05T22:04:58Z","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 ca8023e..4b6a090 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -1813,6 +1813,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@@ -1823,7 +2106,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":"293275","messageId":"xmqqbn16vnlf.fsf@gitster.mtv.corp.google.com","threadId":"43019","inReplyTo":"1470434434-64283-5-git-send-email-git@jeffhostetler.com","subject":"Re: [PATCH v5 4/9] status: collect per-file data for --porcelain=v2","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-08-05T22:48:44Z","receivedAt":"2016-08-06T20:05:21Z","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>  \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\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}\n> -\t\telse\n> +\t\telse {\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\nNot a big deal (no need to resend for this one alone), but let's\nmake the above properly formatted, i.e.\n\n\t\tif (ce_stage(ce)) {\n                \t...\n\t\t} else {\n                \t...\n\t\t}                        \n\nThanks.\n"},{"id":"293280","messageId":"xmqq7fbuvng7.fsf@gitster.mtv.corp.google.com","threadId":"43019","inReplyTo":"1470434434-64283-6-git-send-email-git@jeffhostetler.com","subject":"Re: [PATCH v5 5/9] status: print per-file porcelain v2 status data","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-08-05T22:51:52Z","receivedAt":"2016-08-06T20:10:28Z","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> From: Jeff Hostetler <jeffhost@microsoft.com>\n>\n> Print per-file information in porcelain v2 format.\n>\n> Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>\n> ---\n\nRelative to the previous version, the renaming of variables\n(current, src)->(index, head) made it much easier to understand, at\nleast to me.  All other changes look sensible.\n\nThanks.\n"},{"id":"293314","messageId":"alpine.DEB.2.20.1608071026120.5786@virtualbox","threadId":"43019","inReplyTo":"xmqqbn16vnlf.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v5 4/9] status: collect per-file data for --porcelain=v2","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2016-08-07T08:34:13Z","receivedAt":"2016-08-07T08:34:40Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Junio,\n\nOn Fri, 5 Aug 2016, Junio C Hamano wrote:\n\n> Jeff Hostetler <git@jeffhostetler.com> writes:\n> \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\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}\n> > -\t\telse\n> > +\t\telse {\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> \n> Not a big deal (no need to resend for this one alone), but let's\n> make the above properly formatted, i.e.\n> \n> \t\tif (ce_stage(ce)) {\n>                 \t...\n> \t\t} else {\n>                 \t...\n> \t\t}                        \n\nDo I understand correctly that your objections is against having the curly\nbrace before the \"else\" on its own line?\n\nIf so, when did our coding style change? I vividly remember that we\nstrongly favored putting the \"else\" on a new line after a closing brace,\nto make diffs nicer in case the braces were removed or added.\n\nBTW your suggestion has 24 extra spaces after the final closing brace ;-)\n\nCiao,\nDscho\n"},{"id":"293328","messageId":"20160807222903.GA462@starla","threadId":"43019","inReplyTo":"alpine.DEB.2.20.1608071026120.5786@virtualbox","subject":"Re: [PATCH v5 4/9] status: collect per-file data for --porcelain=v2","fromName":"Eric Wong","fromEmail":"e@80x24.org","sentAt":"2016-08-07T22:29:03Z","receivedAt":"2016-08-07T22:29:16Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n> On Fri, 5 Aug 2016, Junio C Hamano wrote:\n> > Jeff Hostetler <git@jeffhostetler.com> writes:\n> > >  \t\t}\n> > > -\t\telse\n> > > +\t\telse {\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> > \n> > Not a big deal (no need to resend for this one alone), but let's\n> > make the above properly formatted, i.e.\n> > \n> > \t\tif (ce_stage(ce)) {\n> >                 \t...\n> > \t\t} else {\n> >                 \t...\n> > \t\t}                        \n> \n> Do I understand correctly that your objections is against having the curly\n> brace before the \"else\" on its own line?\n> \n> If so, when did our coding style change? I vividly remember that we\n> strongly favored putting the \"else\" on a new line after a closing brace,\n> to make diffs nicer in case the braces were removed or added.\n\nAFAIK, Linux kernel CodingStyle has always been what Junio\nsuggested (just w/o the trailing spaces :),\nand we inherit from that.\n\nhttps://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/plain/Documentation/CodingStyle\n\n> BTW your suggestion has 24 extra spaces after the final closing brace ;-)\n"},{"id":"293332","messageId":"xmqqy448ggyv.fsf@gitster.mtv.corp.google.com","threadId":"43019","inReplyTo":"20160807222903.GA462@starla","subject":"Re: [PATCH v5 4/9] status: collect per-file data for --porcelain=v2","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-08-08T01:57:44Z","receivedAt":"2016-08-08T01:58:29Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Eric Wong <e@80x24.org> writes:\n\n>> > Not a big deal (no need to resend for this one alone), but let's\n>> > make the above properly formatted, i.e.\n>> > \n>> > \t\tif (ce_stage(ce)) {\n>> >                 \t...\n>> > \t\t} else {\n>> >                 \t...\n>> > \t\t}                        \n>> \n>> Do I understand correctly that your objections is against having the curly\n>> brace before the \"else\" on its own line?\n>> \n>> If so, when did our coding style change? I vividly remember that we\n>> strongly favored putting the \"else\" on a new line after a closing brace,\n>> to make diffs nicer in case the braces were removed or added.\n>\n> AFAIK, Linux kernel CodingStyle has always been what Junio\n> suggested (just w/o the trailing spaces :),\n> and we inherit from that.\n\nWhat Eric said.\n\nWhile I admit that I sometimes break line between \"}\" and \"else {\"\nby inertia when I am being careless and get caught by checkpatch.pl\nmyself, I do not recall trying to justify it; you probably may\nremember somebody else saying that, but I don't recall anybody\nmaking that argument on the list, and more importantly I don't\nrecall us making that our style based on that argument.\n\nThe only two and half kinds of warnings we knowingly ignore from\nscripts/checkpatch.pl in the Linux kernel source tree are:\n\n * \"Avoid typedefs.\"  We do avoid making graduitous use of typedef to\n   hide a structure behind a type and pretty much limit ourselves to\n   use it for (callback) function types, though.\n\n * \"We've never heard of Helped-by/Mentored-by footers\"; well,\n   kernel folks may not, but we have ;-)\n\n * \"No spaces for bitfield width\".  This may not be justifyable, but\n   the majority of our bitfield widths are defined in the way not\n   blessed by checkpatch.pl checker.\n"},{"id":"293365","messageId":"xmqq4m6vgpf9.fsf@gitster.mtv.corp.google.com","threadId":"43019","inReplyTo":"1470434434-64283-10-git-send-email-git@jeffhostetler.com","subject":"Re: [PATCH v5 9/9] status: unit tests for --porcelain=v2","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-08-08T17:07:22Z","receivedAt":"2016-08-08T17:07:31Z","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> +test_expect_success pre_initial_commit_0 '\n> +\t...\n> +\tgit status --porcelain=v2 --branch --untracked-files=normal >actual &&\n> +\ttest_cmp expect actual\n> +'\n> +\n> +\n> +test_expect_success pre_initial_commit_1 '\n> +\tgit add file_x file_y file_z dir1 &&\n> +\t...\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> +\t...\n\nThis makes one wonder what would/should be shown on the \"A.\" column\nif one of these files are added with \"-N\" (intent-to-add).  I do not\nsee any test for such entries in this patch, but I think it should.\n\n> +\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n> +\ttest_cmp expect actual\n> +'\n\n> +## Try -z on the above\n> +test_expect_success pre_initial_commit_2 '\n> +\tlf_to_nul >expect <<-EOF &&\n> +\t...\n> +\tgit status -z --porcelain=v2 --branch --untracked-files=all >actual &&\n> +\ttest_cmp expect actual\n> +'\n\n\"Try -z on the above\" can and should be in the test title to help\nthose who are watching the test run.  Instead of trying to clarify\ncode with comments, clarify them by letting the code speak for\nthemselves.  I would have named the above three perhaps like this:\n\n\ttest_expect_success 'before first commit, nothing added'\n        test_expect_success 'before first commit, some files added'\n        test_expect_success 'before first commit, some files added (-z)'\n\n\"pre-initial-commit-$number\" is not very interesting; it does not\nconvey a more interesting aspect of these tests, like (a) _0 is\ndistinct (nothing added) among the three, (b) _1 and _2 are about\nthe same state, just expressed differently, and (c) _1 is LF\nterminated, _2 is NUL terminated.  The same comment applies to the\nremainder of the test.  For example:\n\n> +##################################################################\n> +## Create second commit.\n> +##################################################################\n> +\n> +test_expect_success second_commit_0 '\n\nThis \"_0\" does not tell us anything, but you are testing \"When fully\ncommitted, we only see untracked files (if we ask) and branch info\n(if we ask).\n\nHaving said all that, it is OK to fix their titles after the current\n9-patch series lands on 'next'; incremental refinements are easier\non reviewers than having to review too many rerolls.\n\nThis is probably a good place to see what happens to these untracked\nfiles and branch info if we do not ask the command to show them.\nOtherwise, it tests exactly the same as \"initial_commit_0\" and is\nnot all that interesting, no?\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> +\t## ignored file SHOULD NOT appear in output when --ignored is not used.\n> + ...\n> +\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n> +\ttest_cmp expect actual &&\n> + ...\n> +\tgit status --porcelain=v2 --branch --ignored --untracked-files=all >actual &&\n> +\trm x.ign &&\n> +\trm .gitignore &&\n\nArrange these files to be cleaned before you create them by having\n\n\ttest_when_finished \"rm -f x.ign .gitignore\" &&\n\nat the very beginning of this test before they are created.\nOtherwise, if any step before these removal fail, later test that\nassume they are gone will be affected.  You already do so correctly\nin the upstream_fields_0 test below.\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> +\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\nThis is a small point, but doesn't the lowercase 'u' somehow look\nugly, especially because the status letters that immediately follow\nit are all uppercase?\n\n> +\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n> +\tgit reset --hard &&\n\nThis \"reset\" also may be a candidate for test_when_finished clean-up\n(I won't repeat the comment but there probably are many others).\n\n> +test_expect_success 'upstream_fields_0' '\n> +\tgit checkout master &&\n> +\ttest_when_finished rm -rf sub_repo &&\n\nThe \"when-finished\" argument are usually quoted like this, I think:\n\n\ttest_when_finished \"rm -rf sub_repo\" &&\n\n"},{"id":"293655","messageId":"57AB9C61.5060409@jeffhostetler.com","threadId":"43019","inReplyTo":"xmqq4m6vgpf9.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v5 9/9] status: unit tests for --porcelain=v2","fromName":"Jeff Hostetler","fromEmail":"git@jeffhostetler.com","sentAt":"2016-08-10T21:28:01Z","receivedAt":"2016-08-10T21:30:14Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"\n\nOn 08/08/2016 01:07 PM, Junio C Hamano wrote:\n> Jeff Hostetler <git@jeffhostetler.com> writes:\n>\n>> +test_expect_success pre_initial_commit_0 '\n>> +\t...\n>> +\tgit status --porcelain=v2 --branch --untracked-files=normal >actual &&\n>> +\ttest_cmp expect actual\n>> +'\n>> +\n>> +\n>> +test_expect_success pre_initial_commit_1 '\n>> +\tgit add file_x file_y file_z dir1 &&\n>> +\t...\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>> +\t...\n>\n> This makes one wonder what would/should be shown on the \"A.\" column\n> if one of these files are added with \"-N\" (intent-to-add).  I do not\n> see any test for such entries in this patch, but I think it should.\n\nI must admit that I don't use -N, so I'm open to recommendations here.\nIn my brief testing, the existing porcelain status reports it as \"AM\"\n(for both a file with content and an empty file).\n\nThe V2 code outputs the following:\n1 AM N... 000000 100644 100644 0000000000000000000000000000000000000000 \ne69de29bb2d1d6434b8b29ae775ad8c2e48c5391 intent.add\n\nWhich I think makes sense.  I'll add a test to exercise that.\n\n\n> \"Try -z on the above\" can and should be in the test title to help\n> ...\n> Having said all that, it is OK to fix their titles after the current\n> 9-patch series lands on 'next'; incremental refinements are easier\n> on reviewers than having to review too many rerolls.\n\nI'll change the test titles to have all that info.\n\n\n> This is probably a good place to see what happens to these untracked\n> files and branch info if we do not ask the command to show them.\n\nI'll add some cases to cycle thru the options and confirm\nthere's no output when not requested.\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>> +\t## ignored file SHOULD NOT appear in output when --ignored is not used.\n>> + ...\n>> +\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n>> +\ttest_cmp expect actual &&\n>> + ...\n>> +\tgit status --porcelain=v2 --branch --ignored --untracked-files=all >actual &&\n>> +\trm x.ign &&\n>> +\trm .gitignore &&\n>\n> Arrange these files to be cleaned before you create them by having\n>\n> \ttest_when_finished \"rm -f x.ign .gitignore\" &&\n>\n> at the very beginning of this test before they are created.\n> Otherwise, if any step before these removal fail, later test that\n> assume they are gone will be affected.  You already do so correctly\n> in the upstream_fields_0 test below.\n\nMissed a few.  Got it.  Thanks!\n\n\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> This is a small point, but doesn't the lowercase 'u' somehow look\n> ugly, especially because the status letters that immediately follow\n> it are all uppercase?\n>\n\nSince we are inventing a new format and my column 1 is completely new\nI didn't think it mattered.  And I used a lowercase 'u' to distinguish \nit from the \"U\" in the X and Y columns since they mean different things.\n\nBut we can change it if you'd prefer.\n\n\n>> +\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n>> +\tgit reset --hard &&\n>\n> This \"reset\" also may be a candidate for test_when_finished clean-up\n> (I won't repeat the comment but there probably are many others).\n\nGot it. And I hopefully caught the rest.\n\n\n>> +test_expect_success 'upstream_fields_0' '\n>> +\tgit checkout master &&\n>> +\ttest_when_finished rm -rf sub_repo &&\n>\n> The \"when-finished\" argument are usually quoted like this, I think:\n>\n> \ttest_when_finished \"rm -rf sub_repo\" &&\n\nGot it. Thanks.\n\n\nI have the test changes ready.  As suggested, I'll send a single commit\npatch after my 9-patch series lands on 'next'.\n\nThanks,\nJeff\n\n\n\n\n"},{"id":"293673","messageId":"xmqqvaz82qn6.fsf@gitster.mtv.corp.google.com","threadId":"43019","inReplyTo":"57AB9C61.5060409@jeffhostetler.com","subject":"Re: [PATCH v5 9/9] status: unit tests for --porcelain=v2","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-08-10T22:41:33Z","receivedAt":"2016-08-10T22:41:41Z","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> In my brief testing, the existing porcelain status reports it as \"AM\"\n> (for both a file with content and an empty file).\n>\n> The V2 code outputs the following:\n> 1 AM N... 000000 100644 100644\n\nOK, so they are consistent, which is good.\n\n>> Having said all that, it is OK to fix their titles after the current\n>> 9-patch series lands on 'next'; incremental refinements are easier\n>> on reviewers than having to review too many rerolls.\n>\n> I'll change the test titles to have all that info.\n\nOK.  As I said, if the retitling is the only change, then doing so\nas a follow-up to the existing 9-patch series would be easier to\nreview.  If there are other changes needed, a reroll of the full set\nis probably better.\n\n>> This is a small point, but doesn't the lowercase 'u' somehow look\n>> ugly, especially because the status letters that immediately follow\n>> it are all uppercase?\n>>\n>\n> Since we are inventing a new format and my column 1 is completely new\n> I didn't think it mattered.\n\nWrong assumption ;-)  We want the resulting code to be consistent.\n\n> And I used a lowercase 'u' to distinguish\n> it from the \"U\" in the X and Y columns since they mean different\n> things.\n\nI thought they both mean \"Unmerged\"; that is why I thought seeing a\nlowercase there was very strange.\n\nThanks.\n"},{"id":"293683","messageId":"57ABB788.5020305@jeffhostetler.com","threadId":"43019","inReplyTo":"xmqqvaz82qn6.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v5 9/9] status: unit tests for --porcelain=v2","fromName":"Jeff Hostetler","fromEmail":"git@jeffhostetler.com","sentAt":"2016-08-10T23:23:52Z","receivedAt":"2016-08-10T23:27:12Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"\n\nOn 08/10/2016 06:41 PM, Junio C Hamano wrote:\n> Jeff Hostetler <git@jeffhostetler.com> writes:\n>>> Having said all that, it is OK to fix their titles after the current\n>>> 9-patch series lands on 'next'; incremental refinements are easier\n>>> on reviewers than having to review too many rerolls.\n>>\n>> I'll change the test titles to have all that info.\n>\n> OK.  As I said, if the retitling is the only change, then doing so\n> as a follow-up to the existing 9-patch series would be easier to\n> review.  If there are other changes needed, a reroll of the full set\n> is probably better.\n\nI've changed the titles and added 5 or 6 more tests to\ncover your previous questions/comments, but no code changes.\n\n\n>>> This is a small point, but doesn't the lowercase 'u' somehow look\n>>> ugly, especially because the status letters that immediately follow\n>>> it are all uppercase?\n>>>\n>>\n>> Since we are inventing a new format and my column 1 is completely new\n>> I didn't think it mattered.\n>\n> Wrong assumption ;-)  We want the resulting code to be consistent.\n>\n>> And I used a lowercase 'u' to distinguish\n>> it from the \"U\" in the X and Y columns since they mean different\n>> things.\n>\n> I thought they both mean \"Unmerged\"; that is why I thought seeing a\n> lowercase there was very strange.\n\nFor unmerged items, the X & Y columns in the original porcelain\nformat, can have various combinations of \"A\", \"D\", and \"U\" values.\nThe implication being that \"U\" means modified/edited in some way.\nYes, it is labeled \"unmerged\", but in a \"DU\" or \"UD\" conflict, it\nmeans that one side deleted it and one side modified it in some way.\nA \"UU\" conflict means both sides edited it and auto-merge failed.\n\nAll I wanted the lowercase 'u' to indicate was that the file was\nin an unmerged state (without specifying why).  That is, we would\nhave (the 7 valid combinations of) \"u [ADU][ADU]\" and it would be\nclear(er?) that the little 'u' was different from the other 2.\n\nI know it is a subtle point and we can change it if you want, but\nthat was the rationale.\n\n\nThanks,\nJeff\n\n"}]}