{"thread":{"id":"47471","subject":"[PATCH 0/4] Add --no-ahead-behind to status","startedAt":"2017-12-20T14:43:02Z","lastAt":"2017-12-21T17:47:18Z","messageCount":17,"participants":["Jeff Hostetler","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"335078","messageId":"20171220144245.39401-1-git@jeffhostetler.com","threadId":"47471","inReplyTo":null,"subject":"[PATCH 0/4] Add --no-ahead-behind to status","fromName":"Jeff Hostetler","fromEmail":"git@jeffhostetler.com","sentAt":"2017-12-20T14:42:41Z","receivedAt":"2017-12-20T14:43:02Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"From: Jeff Hostetler <jeffhost@microsoft.com>\n\nThis patch series adds a \"--no-ahead-behind\" option to status\nto request that it avoid a possibly expensive ahead/behind\ncomputation for the current branch.  Instead, it just prints a\nnot up to date message in place of the detailed counts.\n\nThis idea was previously discussed in [1].  Working with the\nenormous Windows repository, we found that 20+ seconds was being\nspent in the ahead/behind computation when the current branch was\n150K commits behind the upstream branch.  (Yes, this happens and\nonly took 3 weeks on the reporter's system.)\n\n\nI've only modified \"git status\" in this patch series.  A similar\nchange could be added to \"git branch -vv\" and \"git checkout\" to\navoid delays there too.  I avoided doing it here to keep this\npatch series focused.\n\n\n[1] https://public-inbox.org/git/030bf57c-7a23-3391-4fc0-93efee791543@jeffhostetler.com/T/\n\nJeff Hostetler (4):\n  status: add --no-ahead-behind to porcelain V2\n  stat_tracking_info: return +1 when branch and upstream differ\n  status: update short status to use --no-ahead-behind\n  status: support --no-ahead-behind in long status format.\n\n Documentation/config.txt     |  5 +++++\n Documentation/git-status.txt | 16 ++++++++++++++++\n builtin/checkout.c           |  2 +-\n builtin/commit.c             |  6 ++++++\n ref-filter.c                 |  4 ++--\n remote.c                     | 36 ++++++++++++++++++++++++++++--------\n remote.h                     |  4 +++-\n t/t6040-tracking-info.sh     | 42 ++++++++++++++++++++++++++++++++++++++++++\n t/t7064-wtstatus-pv2.sh      | 23 +++++++++++++++++++++++\n wt-status.c                  | 24 ++++++++++++++++++++----\n wt-status.h                  |  1 +\n 11 files changed, 147 insertions(+), 16 deletions(-)\n\n-- \n2.9.3\n\n"},{"id":"335079","messageId":"20171220144245.39401-4-git@jeffhostetler.com","threadId":"47471","inReplyTo":"20171220144245.39401-1-git@jeffhostetler.com","subject":"[PATCH 3/4] status: update short status to use --no-ahead-behind","fromName":"Jeff Hostetler","fromEmail":"git@jeffhostetler.com","sentAt":"2017-12-20T14:42:44Z","receivedAt":"2017-12-20T14:43:04Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"From: Jeff Hostetler <jeffhost@microsoft.com>\n\nTeach \"git status --short --branch\" to use \"--no-ahead-behind\"\nflag to skip computing ahead/behind counts for the branch and\nits upstream and just report '[different]'.\n\nSigned-off-by: Jeff Hostetler <jeffhost@microsoft.com>\n---\n Documentation/git-status.txt |  3 +++\n remote.c                     | 12 +++++++++---\n t/t6040-tracking-info.sh     | 13 +++++++++++++\n wt-status.c                  | 11 +++++++++--\n 4 files changed, 34 insertions(+), 5 deletions(-)\n\ndiff --git a/Documentation/git-status.txt b/Documentation/git-status.txt\nindex 6ce8cf8..ea029ad 100644\n--- a/Documentation/git-status.txt\n+++ b/Documentation/git-status.txt\n@@ -117,6 +117,9 @@ configuration variable documented in linkgit:git-config[1].\n \texpensive computation on extremely large repositories.\n +\n \tIn porcelain V2 format, the 'branch.ab' line will not be present.\n++\n+\tIn short format with --branch, '[different]' will printed rather\n+\tthan detailed ahead/behind counts.\n \n <pathspec>...::\n \tSee the 'pathspec' entry in linkgit:gitglossary[7].\ndiff --git a/remote.c b/remote.c\nindex a38b42e..0a63ac1 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -1978,9 +1978,12 @@ int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid)\n \n /*\n  * Compare a branch with its upstream, and save their differences (number\n- * of commits) in *num_ours and *num_theirs. The name of the upstream branch\n- * (or NULL if no upstream is defined) is returned via *upstream_name, if it\n- * is not itself NULL.\n+ * of commits) in *num_ours and *num_theirs.  If either num_ours or num_theirs\n+ * are NULL, we skip counting the commits and just return whether they are\n+ * different.\n+ *\n+ * The name of the upstream branch (or NULL if no upstream is defined) is\n+ * returned via *upstream_name, if it is not itself NULL.\n  *\n  * Returns -1 if num_ours and num_theirs could not be filled in (e.g., no\n  * upstream defined, or ref does not exist).\n@@ -2016,6 +2019,9 @@ int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs,\n \tif (!ours)\n \t\treturn -1;\n \n+\tif (!num_ours || !num_theirs)\n+\t\treturn theirs != ours;\n+\n \t/* are we the same? */\n \tif (theirs == ours) {\n \t\t*num_theirs = *num_ours = 0;\ndiff --git a/t/t6040-tracking-info.sh b/t/t6040-tracking-info.sh\nindex 8f17fd9..0190220 100755\n--- a/t/t6040-tracking-info.sh\n+++ b/t/t6040-tracking-info.sh\n@@ -147,6 +147,19 @@ test_expect_success 'status -s -b (diverged from upstream)' '\n '\n \n cat >expect <<\\EOF\n+## b1...origin/master [different]\n+EOF\n+\n+test_expect_success 'status -s -b --no-ahead-behind (diverged from upstream)' '\n+\t(\n+\t\tcd test &&\n+\t\tgit checkout b1 >/dev/null &&\n+\t\tgit status -s -b --no-ahead-behind | head -1\n+\t) >actual &&\n+\ttest_i18ncmp expect actual\n+'\n+\n+cat >expect <<\\EOF\n ## b5...brokenbase [gone]\n EOF\n \ndiff --git a/wt-status.c b/wt-status.c\nindex 471ba15..6b4f969 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -1767,6 +1767,7 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)\n \tconst char *branch_name;\n \tint num_ours, num_theirs;\n \tint upstream_is_gone = 0;\n+\tint sti;\n \n \tcolor_fprintf(s->fp, color(WT_STATUS_HEADER, s), \"## \");\n \n@@ -1791,7 +1792,11 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)\n \n \tcolor_fprintf(s->fp, branch_color_local, \"%s\", branch_name);\n \n-\tif (stat_tracking_info(branch, &num_ours, &num_theirs, &base) < 0) {\n+\tif (s->no_ahead_behind)\n+\t\tsti = stat_tracking_info(branch, NULL, NULL, &base);\n+\telse\n+\t\tsti = stat_tracking_info(branch, &num_ours, &num_theirs, &base);\n+\tif (sti < 0) {\n \t\tif (!base)\n \t\t\tgoto conclude;\n \n@@ -1803,12 +1808,14 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)\n \tcolor_fprintf(s->fp, branch_color_remote, \"%s\", short_base);\n \tfree(short_base);\n \n-\tif (!upstream_is_gone && !num_ours && !num_theirs)\n+\tif (!upstream_is_gone && !sti)\n \t\tgoto conclude;\n \n \tcolor_fprintf(s->fp, header_color, \" [\");\n \tif (upstream_is_gone) {\n \t\tcolor_fprintf(s->fp, header_color, LABEL(N_(\"gone\")));\n+\t} else if (s->no_ahead_behind) {\n+\t\tcolor_fprintf(s->fp, header_color, LABEL(N_(\"different\")));\n \t} else if (!num_ours) {\n \t\tcolor_fprintf(s->fp, header_color, LABEL(N_(\"behind \")));\n \t\tcolor_fprintf(s->fp, branch_color_remote, \"%d\", num_theirs);\n-- \n2.9.3\n\n"},{"id":"335080","messageId":"20171220144245.39401-3-git@jeffhostetler.com","threadId":"47471","inReplyTo":"20171220144245.39401-1-git@jeffhostetler.com","subject":"[PATCH 2/4] stat_tracking_info: return +1 when branch and upstream differ","fromName":"Jeff Hostetler","fromEmail":"git@jeffhostetler.com","sentAt":"2017-12-20T14:42:43Z","receivedAt":"2017-12-20T14:43:06Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"From: Jeff Hostetler <jeffhost@microsoft.com>\n\nExtend stat_tracking_info() to return 1 when the branch is\nnot up to date with its upstream branch and only return 0\nwhen they are equal.\n\nSigned-off-by: Jeff Hostetler <jeffhost@microsoft.com>\n---\n ref-filter.c | 4 ++--\n remote.c     | 6 ++++--\n wt-status.c  | 2 +-\n 3 files changed, 7 insertions(+), 5 deletions(-)\n\ndiff --git a/ref-filter.c b/ref-filter.c\nindex e728b15..10ab4cd 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -1239,7 +1239,7 @@ static void fill_remote_ref_details(struct used_atom *atom, const char *refname,\n \t\t*s = show_ref(&atom->u.remote_ref.refname, refname);\n \telse if (atom->u.remote_ref.option == RR_TRACK) {\n \t\tif (stat_tracking_info(branch, &num_ours,\n-\t\t\t\t       &num_theirs, NULL)) {\n+\t\t\t\t       &num_theirs, NULL) < 0) {\n \t\t\t*s = xstrdup(msgs.gone);\n \t\t} else if (!num_ours && !num_theirs)\n \t\t\t*s = \"\";\n@@ -1257,7 +1257,7 @@ static void fill_remote_ref_details(struct used_atom *atom, const char *refname,\n \t\t}\n \t} else if (atom->u.remote_ref.option == RR_TRACKSHORT) {\n \t\tif (stat_tracking_info(branch, &num_ours,\n-\t\t\t\t       &num_theirs, NULL))\n+\t\t\t\t       &num_theirs, NULL) < 0)\n \t\t\treturn;\n \n \t\tif (!num_ours && !num_theirs)\ndiff --git a/remote.c b/remote.c\nindex b220f0d..a38b42e 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -1983,7 +1983,9 @@ int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid)\n  * is not itself NULL.\n  *\n  * Returns -1 if num_ours and num_theirs could not be filled in (e.g., no\n- * upstream defined, or ref does not exist), 0 otherwise.\n+ * upstream defined, or ref does not exist).\n+ * Returns 0 if the commits are the same (the branch is up to date).\n+ * Returns 1 if the commits are different (the branch is not up to date).\n  */\n int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs,\n \t\t       const char **upstream_name)\n@@ -2051,7 +2053,7 @@ int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs,\n \tclear_commit_marks(theirs, ALL_REV_FLAGS);\n \n \targv_array_clear(&argv);\n-\treturn 0;\n+\treturn 1;\n }\n \n /*\ndiff --git a/wt-status.c b/wt-status.c\nindex 1bc53e1..471ba15 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -1935,7 +1935,7 @@ static void wt_porcelain_v2_print_tracking(struct wt_status *s)\n \t\t\tbase = branch_get_upstream(branch, NULL);\n \t\t\tab_info = 0;\n \t\t} else {\n-\t\t\tab_info = (stat_tracking_info(branch, &nr_ahead, &nr_behind, &base) == 0);\n+\t\t\tab_info = (stat_tracking_info(branch, &nr_ahead, &nr_behind, &base) >= 0);\n \t\t}\n \n \t\tif (base) {\n-- \n2.9.3\n\n"},{"id":"335081","messageId":"20171220144245.39401-2-git@jeffhostetler.com","threadId":"47471","inReplyTo":"20171220144245.39401-1-git@jeffhostetler.com","subject":"[PATCH 1/4] status: add --no-ahead-behind to porcelain V2","fromName":"Jeff Hostetler","fromEmail":"git@jeffhostetler.com","sentAt":"2017-12-20T14:42:42Z","receivedAt":"2017-12-20T14:43:08Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"From: Jeff Hostetler <jeffhost@microsoft.com>\n\nTeach \"status --porcelain=v2 --branch\" to omit \"# branch.ab x y\"\nwhen \"--no-ahead-behind\" argument is used.\n\nThis allows the user to omit the (possibly extremely expensive)\nahead/behind computation when not needed.\n\nSigned-off-by: Jeff Hostetler <jeffhost@microsoft.com>\n---\n Documentation/config.txt     |  5 +++++\n Documentation/git-status.txt | 10 ++++++++++\n builtin/commit.c             |  6 ++++++\n t/t7064-wtstatus-pv2.sh      | 23 +++++++++++++++++++++++\n wt-status.c                  | 11 ++++++++++-\n wt-status.h                  |  1 +\n 6 files changed, 55 insertions(+), 1 deletion(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 9593bfa..9ccdf2b 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -3082,6 +3082,11 @@ status.submoduleSummary::\n \tsubmodule summary' command, which shows a similar output but does\n \tnot honor these settings.\n \n+status.noaheadbehind::\n+\tDo not compute ahead/behind counts for a branch relative to its\n+\tupstream branch.  This can be used to avoid a possibly very\n+\texpensive computation on extremely large repositories.\n+\n stash.showPatch::\n \tIf this is set to true, the `git stash show` command without an\n \toption will show the stash entry in patch form.  Defaults to false.\ndiff --git a/Documentation/git-status.txt b/Documentation/git-status.txt\nindex 9f3a78a..6ce8cf8 100644\n--- a/Documentation/git-status.txt\n+++ b/Documentation/git-status.txt\n@@ -111,6 +111,13 @@ configuration variable documented in linkgit:git-config[1].\n \twithout options are equivalent to 'always' and 'never'\n \trespectively.\n \n+--no-ahead-behind::\n+\tDo not compute ahead/behind counts for the current branch relative\n+\tto the upstream branch.  This can be used to avoid a possibly very\n+\texpensive computation on extremely large repositories.\n++\n+\tIn porcelain V2 format, the 'branch.ab' line will not be present.\n+\n <pathspec>...::\n \tSee the 'pathspec' entry in linkgit:gitglossary[7].\n \n@@ -253,6 +260,9 @@ information about the current branch.\n \t\t\t\t\t     the commit is present.\n     ------------------------------------------------------------\n \n+If `--no-ahead-behind` is given or 'status.noaheadbehind' is set, the\n+'branch.ab' line will not be present.\n+\n ### Changed Tracked Entries\n \n Following the headers, a series of lines are printed for tracked\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex be370f6..99ca5cb 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -1335,6 +1335,10 @@ static int git_status_config(const char *k, const char *v, void *cb)\n \t\t\treturn error(_(\"Invalid untracked files mode '%s'\"), v);\n \t\treturn 0;\n \t}\n+\tif (!strcmp(k, \"status.noaheadbehind\")) {\n+\t\ts->no_ahead_behind = git_config_bool(k, v);\n+\t\treturn 0;\n+\t}\n \treturn git_diff_ui_config(k, v, NULL);\n }\n \n@@ -1369,6 +1373,8 @@ int cmd_status(int argc, const char **argv, const char *prefix)\n \t\t  N_(\"ignore changes to submodules, optional when: all, dirty, untracked. (Default: all)\"),\n \t\t  PARSE_OPT_OPTARG, NULL, (intptr_t)\"all\" },\n \t\tOPT_COLUMN(0, \"column\", &s.colopts, N_(\"list untracked files in columns\")),\n+\t\tOPT_BOOL(0, \"no-ahead-behind\", &s.no_ahead_behind,\n+\t\t\t N_(\"omit branch ahead/behind counts\")),\n \t\tOPT_END(),\n \t};\n \ndiff --git a/t/t7064-wtstatus-pv2.sh b/t/t7064-wtstatus-pv2.sh\nindex e319fa2..4be2b20 100755\n--- a/t/t7064-wtstatus-pv2.sh\n+++ b/t/t7064-wtstatus-pv2.sh\n@@ -390,6 +390,29 @@ test_expect_success 'verify upstream fields in branch header' '\n \t)\n '\n \n+test_expect_success 'verify --no-ahead-behind omits branch.ab' '\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\tEOF\n+\n+\t\tgit status --no-ahead-behind --porcelain=v2 --branch --untracked-files=all >actual &&\n+\t\ttest_cmp expect actual &&\n+\n+\t\tgit -c status.noaheadbehind=true status --porcelain=v2 --branch --untracked-files=all >actual &&\n+\t\ttest_cmp expect actual\n+\t)\n+'\n+\n test_expect_success 'create and add submodule, submodule appears clean (A. S...)' '\n \tgit checkout master &&\n \tgit clone . sub_repo &&\ndiff --git a/wt-status.c b/wt-status.c\nindex 94e5eba..1bc53e1 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -1889,6 +1889,8 @@ static void wt_porcelain_print(struct wt_status *s)\n  *                 <eol> ::= NUL when -z,\n  *                           LF when NOT -z.\n  *\n+ * When 'status.noaheadbehind' is true or '--no-ahead-behind'\n+ * is given on the command line, the 'branch.ab' line is omitted.\n  */\n static void wt_porcelain_v2_print_tracking(struct wt_status *s)\n {\n@@ -1928,7 +1930,14 @@ static void wt_porcelain_v2_print_tracking(struct wt_status *s)\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+\n+\t\tif (s->no_ahead_behind) {\n+\t\t\tbase = branch_get_upstream(branch, NULL);\n+\t\t\tab_info = 0;\n+\t\t} else {\n+\t\t\tab_info = (stat_tracking_info(branch, &nr_ahead, &nr_behind, &base) == 0);\n+\t\t}\n+\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);\ndiff --git a/wt-status.h b/wt-status.h\nindex 64f4d33..8708977 100644\n--- a/wt-status.h\n+++ b/wt-status.h\n@@ -80,6 +80,7 @@ struct wt_status {\n \tint show_branch;\n \tint show_stash;\n \tint hints;\n+\tint no_ahead_behind;\n \n \tenum wt_status_format status_format;\n \tunsigned char sha1_commit[GIT_MAX_RAWSZ]; /* when not Initial */\n-- \n2.9.3\n\n"},{"id":"335082","messageId":"20171220144245.39401-5-git@jeffhostetler.com","threadId":"47471","inReplyTo":"20171220144245.39401-1-git@jeffhostetler.com","subject":"[PATCH 4/4] status: support --no-ahead-behind in long status format.","fromName":"Jeff Hostetler","fromEmail":"git@jeffhostetler.com","sentAt":"2017-12-20T14:42:45Z","receivedAt":"2017-12-20T14:43:11Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"From: Jeff Hostetler <jeffhost@microsoft.com>\n\nTeach long (normal) status format to respect the --no-ahead-behind\nargument and skip the possibly expensive ahead/behind computation\nwhen printing the branch tracking information.\n\nWhen --no-ahead-behind is given or status.noaheadbehind is true,\nstatus prints \"Your branch is out of date with '<upstream>'.\"\ninstead of the various ahead/behind messages.\n\nTODO Should we have an advice hint for this case?\n\nSigned-off-by: Jeff Hostetler <jeffhost@microsoft.com>\n---\n Documentation/git-status.txt |  3 +++\n builtin/checkout.c           |  2 +-\n remote.c                     | 18 +++++++++++++++---\n remote.h                     |  4 +++-\n t/t6040-tracking-info.sh     | 29 +++++++++++++++++++++++++++++\n wt-status.c                  |  2 +-\n 6 files changed, 52 insertions(+), 6 deletions(-)\n\ndiff --git a/Documentation/git-status.txt b/Documentation/git-status.txt\nindex ea029ad..9a2f209 100644\n--- a/Documentation/git-status.txt\n+++ b/Documentation/git-status.txt\n@@ -120,6 +120,9 @@ configuration variable documented in linkgit:git-config[1].\n +\n \tIn short format with --branch, '[different]' will printed rather\n \tthan detailed ahead/behind counts.\n++\n+\tIn long (normal) format, a simple out of date message will be\n+\tprinted rather than detailed ahead/behind counts.\n \n <pathspec>...::\n \tSee the 'pathspec' entry in linkgit:gitglossary[7].\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex fc4f8fd..a3e7bde 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -605,7 +605,7 @@ static void report_tracking(struct branch_info *new)\n \tstruct strbuf sb = STRBUF_INIT;\n \tstruct branch *branch = branch_get(new->name);\n \n-\tif (!format_tracking_info(branch, &sb))\n+\tif (!format_tracking_info(branch, 0, &sb))\n \t\treturn;\n \tfputs(sb.buf, stdout);\n \tstrbuf_release(&sb);\ndiff --git a/remote.c b/remote.c\nindex 0a63ac1..b75e62f 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -2065,14 +2065,20 @@ int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs,\n /*\n  * Return true when there is anything to report, otherwise false.\n  */\n-int format_tracking_info(struct branch *branch, struct strbuf *sb)\n+int format_tracking_info(struct branch *branch, int no_ahead_behind,\n+\t\t\t struct strbuf *sb)\n {\n \tint ours, theirs;\n \tconst char *full_base;\n \tchar *base;\n \tint upstream_is_gone = 0;\n+\tint sti;\n \n-\tif (stat_tracking_info(branch, &ours, &theirs, &full_base) < 0) {\n+\tif (no_ahead_behind)\n+\t\tsti = stat_tracking_info(branch, NULL, NULL, &full_base);\n+\telse\n+\t\tsti = stat_tracking_info(branch, &ours, &theirs, &full_base);\n+\tif (sti < 0) {\n \t\tif (!full_base)\n \t\t\treturn 0;\n \t\tupstream_is_gone = 1;\n@@ -2086,10 +2092,16 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb)\n \t\tif (advice_status_hints)\n \t\t\tstrbuf_addstr(sb,\n \t\t\t\t_(\"  (use \\\"git branch --unset-upstream\\\" to fixup)\\n\"));\n-\t} else if (!ours && !theirs) {\n+\t} else if (!sti) {\n \t\tstrbuf_addf(sb,\n \t\t\t_(\"Your branch is up to date with '%s'.\\n\"),\n \t\t\tbase);\n+\t} else if (no_ahead_behind) {\n+\t\tstrbuf_addf(sb, _(\"Your branch is out of date with '%s'.\\n\"),\n+\t\t\t    base);\n+\n+\t\t/* TODO Do we need a generic hint here? */\n+\n \t} else if (!theirs) {\n \t\tstrbuf_addf(sb,\n \t\t\tQ_(\"Your branch is ahead of '%s' by %d commit.\\n\",\ndiff --git a/remote.h b/remote.h\nindex 2ecf4c8..559649d 100644\n--- a/remote.h\n+++ b/remote.h\n@@ -258,7 +258,9 @@ enum match_refs_flags {\n /* Reporting of tracking info */\n int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs,\n \t\t       const char **upstream_name);\n-int format_tracking_info(struct branch *branch, struct strbuf *sb);\n+\n+int format_tracking_info(struct branch *branch, int no_ahead_behind,\n+\t\t\t struct strbuf *sb);\n \n struct ref *get_local_heads(void);\n /*\ndiff --git a/t/t6040-tracking-info.sh b/t/t6040-tracking-info.sh\nindex 0190220..00fbd0a 100755\n--- a/t/t6040-tracking-info.sh\n+++ b/t/t6040-tracking-info.sh\n@@ -160,6 +160,35 @@ test_expect_success 'status -s -b --no-ahead-behind (diverged from upstream)' '\n '\n \n cat >expect <<\\EOF\n+On branch b1\n+Your branch and 'origin/master' have diverged,\n+and have 1 and 1 different commits each, respectively.\n+EOF\n+\n+test_expect_success 'status --long --branch' '\n+\t(\n+\t\tcd test &&\n+\t\tgit checkout b1 >/dev/null &&\n+\t\tgit status --long -b | head -3\n+\t) >actual &&\n+\ttest_i18ncmp expect actual\n+'\n+\n+cat >expect <<\\EOF\n+On branch b1\n+Your branch is out of date with 'origin/master'.\n+EOF\n+\n+test_expect_success 'status --long --branch --no-ahead-behind' '\n+\t(\n+\t\tcd test &&\n+\t\tgit checkout b1 >/dev/null &&\n+\t\tgit status --long -b --no-ahead-behind | head -2\n+\t) >actual &&\n+\ttest_i18ncmp expect actual\n+'\n+\n+cat >expect <<\\EOF\n ## b5...brokenbase [gone]\n EOF\n \ndiff --git a/wt-status.c b/wt-status.c\nindex 6b4f969..1e7cd57 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -1005,7 +1005,7 @@ static void wt_longstatus_print_tracking(struct wt_status *s)\n \tif (!skip_prefix(s->branch, \"refs/heads/\", &branch_name))\n \t\treturn;\n \tbranch = branch_get(branch_name);\n-\tif (!format_tracking_info(branch, &sb))\n+\tif (!format_tracking_info(branch, s->no_ahead_behind, &sb))\n \t\treturn;\n \n \ti = 0;\n-- \n2.9.3\n\n"},{"id":"335083","messageId":"20171220160731.GA31149@sigill.intra.peff.net","threadId":"47471","inReplyTo":"20171220144245.39401-2-git@jeffhostetler.com","subject":"Re: [PATCH 1/4] status: add --no-ahead-behind to porcelain V2","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-12-20T16:07:31Z","receivedAt":"2017-12-20T16:07:42Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Dec 20, 2017 at 02:42:42PM +0000, Jeff Hostetler wrote:\n\n> diff --git a/Documentation/git-status.txt b/Documentation/git-status.txt\n> index 9f3a78a..6ce8cf8 100644\n> --- a/Documentation/git-status.txt\n> +++ b/Documentation/git-status.txt\n> @@ -111,6 +111,13 @@ configuration variable documented in linkgit:git-config[1].\n>  \twithout options are equivalent to 'always' and 'never'\n>  \trespectively.\n>  \n> +--no-ahead-behind::\n> +\tDo not compute ahead/behind counts for the current branch relative\n> +\tto the upstream branch.  This can be used to avoid a possibly very\n> +\texpensive computation on extremely large repositories.\n> ++\n> +\tIn porcelain V2 format, the 'branch.ab' line will not be present.\n> +\n\nThis second paragraph after the \"+\" continuation shouldn't be indented\n(sadly it makes the source much uglier, but it's one of the vagaries of\nasciidoc).\n\n-Peff\n"},{"id":"335084","messageId":"20171220161407.GB31149@sigill.intra.peff.net","threadId":"47471","inReplyTo":"20171220144245.39401-3-git@jeffhostetler.com","subject":"Re: [PATCH 2/4] stat_tracking_info: return +1 when branch and upstream differ","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-12-20T16:14:07Z","receivedAt":"2017-12-20T16:14:15Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Dec 20, 2017 at 02:42:43PM +0000, Jeff Hostetler wrote:\n\n> Extend stat_tracking_info() to return 1 when the branch is\n> not up to date with its upstream branch and only return 0\n> when they are equal.\n\nThis means that callers all need to be updated, but there's no change\nthat the compiler could catch. You've updated all of the calls here, but\nany topics in flight would need to be fixed, too.\n\nI don't see any any in pu, but there are a number of long-running forks\nhanging around these days.\n\nIs it worth introducing a small change so that any other callers which\nget merged in force a human to look at them? I'm wondering if we could\njust re-order the \"upstream_name\" argument or something.\n\n> --- a/remote.c\n> +++ b/remote.c\n> @@ -1983,7 +1983,9 @@ int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid)\n>   * is not itself NULL.\n>   *\n>   * Returns -1 if num_ours and num_theirs could not be filled in (e.g., no\n> - * upstream defined, or ref does not exist), 0 otherwise.\n> + * upstream defined, or ref does not exist).\n> + * Returns 0 if the commits are the same (the branch is up to date).\n> + * Returns 1 if the commits are different (the branch is not up to date).\n\nSlightly pedantic, but we'd return 1 here also if the branch is ahead of\nits upstream, right?\n\n-Peff\n"},{"id":"335085","messageId":"20171220162637.GC31149@sigill.intra.peff.net","threadId":"47471","inReplyTo":"20171220144245.39401-4-git@jeffhostetler.com","subject":"Re: [PATCH 3/4] status: update short status to use --no-ahead-behind","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-12-20T16:26:37Z","receivedAt":"2017-12-20T16:26:43Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Dec 20, 2017 at 02:42:44PM +0000, Jeff Hostetler wrote:\n\n> From: Jeff Hostetler <jeffhost@microsoft.com>\n> \n> Teach \"git status --short --branch\" to use \"--no-ahead-behind\"\n> flag to skip computing ahead/behind counts for the branch and\n> its upstream and just report '[different]'.\n\nHow come \"--short\" and \"--long\" get this smaller bit of data, but\n\"--porcelain=v2\" just omits the line entirely?\n\nI don't have a real preference for or against the \"[different]\" message\nmyself, but if we can get the information cheaply, it seems odd not to\nprovide it in all cases.\n\n> diff --git a/Documentation/git-status.txt b/Documentation/git-status.txt\n> index 6ce8cf8..ea029ad 100644\n> --- a/Documentation/git-status.txt\n> +++ b/Documentation/git-status.txt\n> @@ -117,6 +117,9 @@ configuration variable documented in linkgit:git-config[1].\n>  \texpensive computation on extremely large repositories.\n>  +\n>  \tIn porcelain V2 format, the 'branch.ab' line will not be present.\n> ++\n> +\tIn short format with --branch, '[different]' will printed rather\n> +\tthan detailed ahead/behind counts.\n\ns/will/will be/ ?\n\n> diff --git a/remote.c b/remote.c\n> index a38b42e..0a63ac1 100644\n> --- a/remote.c\n> +++ b/remote.c\n> @@ -1978,9 +1978,12 @@ int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid)\n>  \n>  /*\n>   * Compare a branch with its upstream, and save their differences (number\n> - * of commits) in *num_ours and *num_theirs. The name of the upstream branch\n> - * (or NULL if no upstream is defined) is returned via *upstream_name, if it\n> - * is not itself NULL.\n> + * of commits) in *num_ours and *num_theirs.  If either num_ours or num_theirs\n> + * are NULL, we skip counting the commits and just return whether they are\n> + * different.\n\nOK, this makes sense. I wondered in the last one why the caller could\nnot simply check \"num_ours != num_theirs\" themselves. And this is why:\nwe want to be able to signal to stat_tracking_info() that we want the\n\"cheap\" version.\n\n> diff --git a/t/t6040-tracking-info.sh b/t/t6040-tracking-info.sh\n> index 8f17fd9..0190220 100755\n> --- a/t/t6040-tracking-info.sh\n> +++ b/t/t6040-tracking-info.sh\n> @@ -147,6 +147,19 @@ test_expect_success 'status -s -b (diverged from upstream)' '\n>  '\n>  \n>  cat >expect <<\\EOF\n> +## b1...origin/master [different]\n> +EOF\n> +\n> +test_expect_success 'status -s -b --no-ahead-behind (diverged from upstream)' '\n\nThis patch will affect \"git status --porcelain\", too. That's not\nsupposed to change in incompatible ways. I guess it's up for debate\nwhether callers are meant to handle any arbitrary string inside the []\n(we already show \"[gone]\" for some cases), since AFAICT the format of\nthe tracking info is left completely vague in the documentation.\n\n(I'd also hope that everybody is using --porcelain=v2 if they can, but\nwe should still avoid breaking v1).\n\n-Peff\n"},{"id":"335086","messageId":"20171220163301.GD31149@sigill.intra.peff.net","threadId":"47471","inReplyTo":"20171220144245.39401-5-git@jeffhostetler.com","subject":"Re: [PATCH 4/4] status: support --no-ahead-behind in long status format.","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-12-20T16:33:01Z","receivedAt":"2017-12-20T16:33:09Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Dec 20, 2017 at 02:42:45PM +0000, Jeff Hostetler wrote:\n\n> diff --git a/Documentation/git-status.txt b/Documentation/git-status.txt\n> index ea029ad..9a2f209 100644\n> --- a/Documentation/git-status.txt\n> +++ b/Documentation/git-status.txt\n> @@ -120,6 +120,9 @@ configuration variable documented in linkgit:git-config[1].\n>  +\n>  \tIn short format with --branch, '[different]' will printed rather\n>  \tthan detailed ahead/behind counts.\n> ++\n> +\tIn long (normal) format, a simple out of date message will be\n> +\tprinted rather than detailed ahead/behind counts.\n\nSame asciidoc trickery here as in the first patch (and in the --short\none, too, but I forgot to mention it).\n\n> +\t} else if (no_ahead_behind) {\n> +\t\tstrbuf_addf(sb, _(\"Your branch is out of date with '%s'.\\n\"),\n> +\t\t\t    base);\n> +\n> +\t\t/* TODO Do we need a generic hint here? */\n> +\n\nI'm not sure what we'd advise here. I'd consider:\n\n  git log --oneline --graph HEAD..@{upstream}\n\nto see the actual differences, but that's a bit verbose. Is there an\neasy way to re-enable it? I guess repeating the command with\n\"--ahead-behind\" should do so.\n\n-Peff\n"},{"id":"335087","messageId":"20171220163358.GE31149@sigill.intra.peff.net","threadId":"47471","inReplyTo":"20171220144245.39401-2-git@jeffhostetler.com","subject":"Re: [PATCH 1/4] status: add --no-ahead-behind to porcelain V2","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-12-20T16:33:58Z","receivedAt":"2017-12-20T16:34:05Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Dec 20, 2017 at 02:42:42PM +0000, Jeff Hostetler wrote:\n\n> diff --git a/Documentation/config.txt b/Documentation/config.txt\n> index 9593bfa..9ccdf2b 100644\n> --- a/Documentation/config.txt\n> +++ b/Documentation/config.txt\n> @@ -3082,6 +3082,11 @@ status.submoduleSummary::\n>  \tsubmodule summary' command, which shows a similar output but does\n>  \tnot honor these settings.\n>  \n> +status.noaheadbehind::\n> +\tDo not compute ahead/behind counts for a branch relative to its\n> +\tupstream branch.  This can be used to avoid a possibly very\n> +\texpensive computation on extremely large repositories.\n\nI got tripped up by double-negatives here while testing something out\nwith your series. Could this be \"status.aheadbehind\", and default to\ntrue?\n\n-Peff\n"},{"id":"335088","messageId":"20171220163711.GA5551@sigill.intra.peff.net","threadId":"47471","inReplyTo":"20171220161407.GB31149@sigill.intra.peff.net","subject":"Re: [PATCH 2/4] stat_tracking_info: return +1 when branch and upstream differ","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-12-20T16:37:11Z","receivedAt":"2017-12-20T16:37:35Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Dec 20, 2017 at 11:14:07AM -0500, Jeff King wrote:\n\n> On Wed, Dec 20, 2017 at 02:42:43PM +0000, Jeff Hostetler wrote:\n> \n> > Extend stat_tracking_info() to return 1 when the branch is\n> > not up to date with its upstream branch and only return 0\n> > when they are equal.\n> \n> This means that callers all need to be updated, but there's no change\n> that the compiler could catch. You've updated all of the calls here, but\n> any topics in flight would need to be fixed, too.\n> \n> I don't see any any in pu, but there are a number of long-running forks\n> hanging around these days.\n> \n> Is it worth introducing a small change so that any other callers which\n> get merged in force a human to look at them? I'm wondering if we could\n> just re-order the \"upstream_name\" argument or something.\n\nHaving seen the change in the next patch, I wonder if we should add a\nflag field to specify \"don't bother doing extra work\" rather than\npassing NULL for the ours/theirs parameters. I.e., most callers would\nbecome:\n\n  if (stat_tracking_info(branch, &ours, &theirs, &base, 0) >= 0)\n\nand the ones you touch later in the series would become:\n\n  \n  if (stat_tracking_info(branch, NULL, NULL, &base, TRACKING_QUICK) >= 0)\n\nor similar. And then any newly added calls would get flagged by the\ncompiler as missing the final parameter.\n\n-Peff\n"},{"id":"335090","messageId":"20171220164313.GA5582@sigill.intra.peff.net","threadId":"47471","inReplyTo":"20171220144245.39401-1-git@jeffhostetler.com","subject":"Re: [PATCH 0/4] Add --no-ahead-behind to status","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-12-20T16:43:13Z","receivedAt":"2017-12-20T16:43:20Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Dec 20, 2017 at 02:42:41PM +0000, Jeff Hostetler wrote:\n\n> From: Jeff Hostetler <jeffhost@microsoft.com>\n> \n> This patch series adds a \"--no-ahead-behind\" option to status\n> to request that it avoid a possibly expensive ahead/behind\n> computation for the current branch.  Instead, it just prints a\n> not up to date message in place of the detailed counts.\n> \n> This idea was previously discussed in [1].  Working with the\n> enormous Windows repository, we found that 20+ seconds was being\n> spent in the ahead/behind computation when the current branch was\n> 150K commits behind the upstream branch.  (Yes, this happens and\n> only took 3 weeks on the reporter's system.)\n\nOverall this looks cleanly done. I raised a few minor points in the\nindividual patches, but certainly nothing that would be a show-stopper\nfor the general idea.\n\n> I've only modified \"git status\" in this patch series.  A similar\n> change could be added to \"git branch -vv\" and \"git checkout\" to\n> avoid delays there too.  I avoided doing it here to keep this\n> patch series focused.\n\nI have a feeling that the same user who got annoyed by \"git status\" is\ngoing to get annoyed by \"git checkout\" sooner or later. I'm OK with\nhandling the other commands separately, but I suspect we may want at\nleast \"git checkout\" support in the near future.\n\nThere is one thing that it's worth thinking about (because it will be\nhard to take back later): config option naming. If your repository is so\nlarge that ahead/behind checks are annoying, would you want to be able\nto set a single config to tell Git that, rather than one for each\ncommand? If so, then do we want to ditch \"status.aheadbehind\" in favor\nof a more unified name?\n\n-Peff\n"},{"id":"335102","messageId":"7e2a4626-5b59-d70b-a172-4a190216b2cc@jeffhostetler.com","threadId":"47471","inReplyTo":"20171220163358.GE31149@sigill.intra.peff.net","subject":"Re: [PATCH 1/4] status: add --no-ahead-behind to porcelain V2","fromName":"Jeff Hostetler","fromEmail":"git@jeffhostetler.com","sentAt":"2017-12-20T19:44:12Z","receivedAt":"2017-12-20T19:44:30Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"\n\nOn 12/20/2017 11:33 AM, Jeff King wrote:\n> On Wed, Dec 20, 2017 at 02:42:42PM +0000, Jeff Hostetler wrote:\n> \n>> diff --git a/Documentation/config.txt b/Documentation/config.txt\n>> index 9593bfa..9ccdf2b 100644\n>> --- a/Documentation/config.txt\n>> +++ b/Documentation/config.txt\n>> @@ -3082,6 +3082,11 @@ status.submoduleSummary::\n>>   \tsubmodule summary' command, which shows a similar output but does\n>>   \tnot honor these settings.\n>>   \n>> +status.noaheadbehind::\n>> +\tDo not compute ahead/behind counts for a branch relative to its\n>> +\tupstream branch.  This can be used to avoid a possibly very\n>> +\texpensive computation on extremely large repositories.\n> \n> I got tripped up by double-negatives here while testing something out\n> with your series. Could this be \"status.aheadbehind\", and default to\n> true?\n> \n> -Peff\n> \n\nYeah, we debated internally how to name it and that was the least bad.\nI'll change it to the positive and (based on later comments) move it\nto \"core.\" so that we can pick up \"branch -vv\" in this round.\n\nThanks\nJeff\n"},{"id":"335125","messageId":"1c4d5de6-566e-5b5f-7cfc-66b2874a7d63@jeffhostetler.com","threadId":"47471","inReplyTo":"20171220161407.GB31149@sigill.intra.peff.net","subject":"Re: [PATCH 2/4] stat_tracking_info: return +1 when branch and upstream differ","fromName":"Jeff Hostetler","fromEmail":"git@jeffhostetler.com","sentAt":"2017-12-21T14:06:28Z","receivedAt":"2017-12-21T14:06:35Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"\n\nOn 12/20/2017 11:14 AM, Jeff King wrote:\n> On Wed, Dec 20, 2017 at 02:42:43PM +0000, Jeff Hostetler wrote:\n> \n>> Extend stat_tracking_info() to return 1 when the branch is\n>> not up to date with its upstream branch and only return 0\n>> when they are equal.\n> \n> This means that callers all need to be updated, but there's no change\n> that the compiler could catch. You've updated all of the calls here, but\n> any topics in flight would need to be fixed, too.\n> \n> I don't see any any in pu, but there are a number of long-running forks\n> hanging around these days.\n> \n> Is it worth introducing a small change so that any other callers which\n> get merged in force a human to look at them? I'm wondering if we could\n> just re-order the \"upstream_name\" argument or something.\n\nGood point.  I usually try to avoid signature changes to minimize the\ndisruption, but as you say that can be a good thing too.  I'll add an\nargument rather than using the null field trick.\n\n> \n>> --- a/remote.c\n>> +++ b/remote.c\n>> @@ -1983,7 +1983,9 @@ int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid)\n>>    * is not itself NULL.\n>>    *\n>>    * Returns -1 if num_ours and num_theirs could not be filled in (e.g., no\n>> - * upstream defined, or ref does not exist), 0 otherwise.\n>> + * upstream defined, or ref does not exist).\n>> + * Returns 0 if the commits are the same (the branch is up to date).\n>> + * Returns 1 if the commits are different (the branch is not up to date).\n> \n> Slightly pedantic, but we'd return 1 here also if the branch is ahead of\n> its upstream, right?\n\nYeah, poor word choice on my part.  I'll fix.\n\nThanks\nJeff\n\n"},{"id":"335126","messageId":"1c019725-7715-496e-bad6-9d47d2bae834@jeffhostetler.com","threadId":"47471","inReplyTo":"20171220162637.GC31149@sigill.intra.peff.net","subject":"Re: [PATCH 3/4] status: update short status to use --no-ahead-behind","fromName":"Jeff Hostetler","fromEmail":"git@jeffhostetler.com","sentAt":"2017-12-21T14:18:17Z","receivedAt":"2017-12-21T14:18:28Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"\n\nOn 12/20/2017 11:26 AM, Jeff King wrote:\n> On Wed, Dec 20, 2017 at 02:42:44PM +0000, Jeff Hostetler wrote:\n> \n>> From: Jeff Hostetler <jeffhost@microsoft.com>\n>>\n>> Teach \"git status --short --branch\" to use \"--no-ahead-behind\"\n>> flag to skip computing ahead/behind counts for the branch and\n>> its upstream and just report '[different]'.\n> \n> How come \"--short\" and \"--long\" get this smaller bit of data, but\n> \"--porcelain=v2\" just omits the line entirely?\n> \n> I don't have a real preference for or against the \"[different]\" message\n> myself, but if we can get the information cheaply, it seems odd not to\n> provide it in all cases.\n\nI was only thinking of VS usage.  But you're right, I can include an\nalternate line with eq|neq since we already have the data on hand.\n\n\n[...]\n>> +test_expect_success 'status -s -b --no-ahead-behind (diverged from upstream)' '\n> \n> This patch will affect \"git status --porcelain\", too. That's not\n> supposed to change in incompatible ways. I guess it's up for debate\n> whether callers are meant to handle any arbitrary string inside the []\n> (we already show \"[gone]\" for some cases), since AFAICT the format of\n> the tracking info is left completely vague in the documentation.\n> \n> (I'd also hope that everybody is using --porcelain=v2 if they can, but\n> we should still avoid breaking v1).\n\nI hadn't intended to alter V1 output.  I'll disable the new feature\nwhen V1 is selected.\n\nThanks\nJeff\n\n"},{"id":"335128","messageId":"20171221153950.GA14411@sigill.intra.peff.net","threadId":"47471","inReplyTo":"1c019725-7715-496e-bad6-9d47d2bae834@jeffhostetler.com","subject":"Re: [PATCH 3/4] status: update short status to use --no-ahead-behind","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-12-21T15:39:51Z","receivedAt":"2017-12-21T15:40:06Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Dec 21, 2017 at 09:18:17AM -0500, Jeff Hostetler wrote:\n\n> > This patch will affect \"git status --porcelain\", too. That's not\n> > supposed to change in incompatible ways. I guess it's up for debate\n> > whether callers are meant to handle any arbitrary string inside the []\n> > (we already show \"[gone]\" for some cases), since AFAICT the format of\n> > the tracking info is left completely vague in the documentation.\n> > \n> > (I'd also hope that everybody is using --porcelain=v2 if they can, but\n> > we should still avoid breaking v1).\n> \n> I hadn't intended to alter V1 output.  I'll disable the new feature\n> when V1 is selected.\n\nTo be clear, I am on the fence regarding the \"is it a breaking change\"\nline. Certainly if the caller says \"--no-ahead-behind\", I don't see any\nharm in doing what they asked.\n\nBut one further complication is that this may be triggered by config.\nAnd that goes for --porcelain=v2, as well. Even though the v2\ndocumentation specifically says \"ignore headers you don't recognize\",\nwould any callers be confused if a header is omitted due to a user's\nconfig?\n\nI guess for \"branch.ab\", the answer is \"probably not\", since it is\nalready documented to appear only if certain conditions are met. So\nprobably \"omit branch.ab\" is an OK change, as is \"add a new header\".\nBut I just wonder if it would be simpler to ignore the config entirely\nfor porcelain outputs (and require the explicit command-line option).\n\nPersonally, I am not a purist when it comes to config and plumbing, and\nI'd be fine with having the config impact v2 (it is a hint from the user\nthat they do not want to spend time on the computation, so having\nscripts respect that would be what the user wants). If you really have a\nscript that is unhappy missing \"branch.ab\", then you can either choose\nnot to set that config, or you can fix the script to use \"--ahead-behind\"\nto override the config. But I'm not sure everybody in the community\nwould necessarily agree with me.\n\n-Peff\n"},{"id":"335134","messageId":"54aad332-cb74-345d-4bed-96f0814a804f@jeffhostetler.com","threadId":"47471","inReplyTo":"20171221153950.GA14411@sigill.intra.peff.net","subject":"Re: [PATCH 3/4] status: update short status to use --no-ahead-behind","fromName":"Jeff Hostetler","fromEmail":"git@jeffhostetler.com","sentAt":"2017-12-21T17:47:11Z","receivedAt":"2017-12-21T17:47:18Z","isPatch":true,"sender":{"key":"git@jeffhostetler.com","avatar":null},"body":"\n\nOn 12/21/2017 10:39 AM, Jeff King wrote:\n> On Thu, Dec 21, 2017 at 09:18:17AM -0500, Jeff Hostetler wrote:\n> \n>>> This patch will affect \"git status --porcelain\", too. That's not\n>>> supposed to change in incompatible ways. I guess it's up for debate\n>>> whether callers are meant to handle any arbitrary string inside the []\n>>> (we already show \"[gone]\" for some cases), since AFAICT the format of\n>>> the tracking info is left completely vague in the documentation.\n>>>\n>>> (I'd also hope that everybody is using --porcelain=v2 if they can, but\n>>> we should still avoid breaking v1).\n>>\n>> I hadn't intended to alter V1 output.  I'll disable the new feature\n>> when V1 is selected.\n> \n> To be clear, I am on the fence regarding the \"is it a breaking change\"\n> line. Certainly if the caller says \"--no-ahead-behind\", I don't see any\n> harm in doing what they asked.\n> \n> But one further complication is that this may be triggered by config.\n> And that goes for --porcelain=v2, as well. Even though the v2\n> documentation specifically says \"ignore headers you don't recognize\",\n> would any callers be confused if a header is omitted due to a user's\n> config?\n> \n> I guess for \"branch.ab\", the answer is \"probably not\", since it is\n> already documented to appear only if certain conditions are met. So\n> probably \"omit branch.ab\" is an OK change, as is \"add a new header\".\n> But I just wonder if it would be simpler to ignore the config entirely\n> for porcelain outputs (and require the explicit command-line option).\n\nI like that actually.  Have the porcelain versions only use the\ncommand line option and do what is asked.  And let the short/long\nforms use both the command line option and the config setting.\nThat makes it explicit for scripts that parse the output.\n\nThanks!\n\n> \n> Personally, I am not a purist when it comes to config and plumbing, and\n> I'd be fine with having the config impact v2 (it is a hint from the user\n> that they do not want to spend time on the computation, so having\n> scripts respect that would be what the user wants). If you really have a\n> script that is unhappy missing \"branch.ab\", then you can either choose\n> not to set that config, or you can fix the script to use \"--ahead-behind\"\n> to override the config. But I'm not sure everybody in the community\n> would necessarily agree with me.\n> \n> -Peff\n> \n"}]}