{"thread":{"id":"52182","subject":"[PATCH] status: teach \"status --short\" to respect \"--show-stash\"","startedAt":"2019-11-04T10:03:43Z","lastAt":"2019-11-08T03:24:07Z","messageCount":5,"participants":["Eric N. Vander Weele","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"385375","messageId":"20191104100334.60537-1-ericvw@gmail.com","threadId":"52182","inReplyTo":null,"subject":"[PATCH] status: teach \"status --short\" to respect \"--show-stash\"","fromName":"Eric N. Vander Weele","fromEmail":"ericvw@gmail.com","sentAt":"2019-11-04T10:03:34Z","receivedAt":"2019-11-04T10:03:43Z","isPatch":true,"sender":{"key":"ericvw@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1284017?v=4"},"body":"Enable printing the entries currently stashed away in the short format.\nThis prints the stash information after the path status to be symmetric\nwith \"status --long --show-stash\".\n\nSigned-off-by: Eric N. Vander Weele <ericvw@gmail.com>\n---\n Documentation/git-status.txt |  4 ++++\n wt-status.c                  | 17 +++++++++++++++++\n 2 files changed, 21 insertions(+)\n\ndiff --git a/Documentation/git-status.txt b/Documentation/git-status.txt\nindex 7731b45f07..c1afc3282c 100644\n--- a/Documentation/git-status.txt\n+++ b/Documentation/git-status.txt\n@@ -244,6 +244,10 @@ If -b is used the short-format status is preceded by a line\n \n     ## branchname tracking info\n \n+If --show-stash is used the short-format status is followed by a line\n+\n+    ## stash: <n> (entry|entries)\n+\n Porcelain Format Version 1\n ~~~~~~~~~~~~~~~~~~~~~~~~~~\n \ndiff --git a/wt-status.c b/wt-status.c\nindex cc6f94504d..c6d112081b 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -1956,6 +1956,20 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)\n \tfputc(s->null_termination ? '\\0' : '\\n', s->fp);\n }\n \n+static void wt_shortstatus_print_stash(struct wt_status *s)\n+{\n+\tint stash_count = 0;\n+\n+\tfor_each_reflog_ent(\"refs/stash\", stash_count_refs, &stash_count);\n+\tif (stash_count > 0) {\n+\t\tcolor_fprintf(s->fp, color(WT_STATUS_HEADER, s), \"## \");\n+\t\tstatus_printf_ln(s, GIT_COLOR_NORMAL,\n+\t\t\t\t Q_(\"stash: %d entry\",\n+\t\t\t\t    \"stash: %d entries\", stash_count),\n+\t\t\t\t stash_count);\n+\t}\n+}\n+\n static void wt_shortstatus_print(struct wt_status *s)\n {\n \tstruct string_list_item *it;\n@@ -1976,6 +1990,9 @@ static void wt_shortstatus_print(struct wt_status *s)\n \n \tfor_each_string_list_item(it, &s->ignored)\n \t\twt_shortstatus_other(it, s, \"!!\");\n+\n+\tif (s->show_stash)\n+\t\twt_shortstatus_print_stash(s);\n }\n \n static void wt_porcelain_print(struct wt_status *s)\n-- \n2.24.0\n\n"},{"id":"385517","messageId":"xmqq36f1wx6h.fsf@gitster-ct.c.googlers.com","threadId":"52182","inReplyTo":"20191104100334.60537-1-ericvw@gmail.com","subject":"Re: [PATCH] status: teach \"status --short\" to respect \"--show-stash\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-11-06T02:33:42Z","receivedAt":"2019-11-06T02:33:47Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Eric N. Vander Weele\" <ericvw@gmail.com> writes:\n\n> Enable printing the entries currently stashed away in the short format.\n> This prints the stash information after the path status to be symmetric\n> with \"status --long --show-stash\".\n>\n> Signed-off-by: Eric N. Vander Weele <ericvw@gmail.com>\n> ---\n>  Documentation/git-status.txt |  4 ++++\n>  wt-status.c                  | 17 +++++++++++++++++\n>  2 files changed, 21 insertions(+)\n>\n> diff --git a/Documentation/git-status.txt b/Documentation/git-status.txt\n> index 7731b45f07..c1afc3282c 100644\n> --- a/Documentation/git-status.txt\n> +++ b/Documentation/git-status.txt\n> @@ -244,6 +244,10 @@ If -b is used the short-format status is preceded by a line\n>  \n>      ## branchname tracking info\n>  \n> +If --show-stash is used the short-format status is followed by a line\n> +\n> +    ## stash: <n> (entry|entries)\n> +\n\nHmmmm.  Would readers misinterpret we are talking about a branch\nwhose name is stash something?  I am not suggesting to change ##\nintroducer to some random letters, which would break scripts even\nworse.\n\nDoesn't the Porcelain Format v1 call the same codepath as\nshortstatus?  We promise that its output never changes to support\nexisting scripts, but now they will start seeing \"## stash:\" that\nthey do not understand and barf?\n\nIsn't this information available to scripts that want to read from\nporcelain v2 output format (which is meant to be extensible by\nallowing easy-to-parse optional headers, which this stash thing\nexactly is).\n\nThanks.\n"},{"id":"385693","messageId":"20191107103141.GA87008@helium","threadId":"52182","inReplyTo":"xmqq36f1wx6h.fsf@gitster-ct.c.googlers.com","subject":"Re: [PATCH] status: teach \"status --short\" to respect \"--show-stash\"","fromName":"Eric N. Vander Weele","fromEmail":"ericvw@gmail.com","sentAt":"2019-11-07T10:31:41Z","receivedAt":"2019-11-07T10:31:48Z","isPatch":true,"sender":{"key":"ericvw@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1284017?v=4"},"body":"On Wed, Nov 06, 2019 at 11:33:42AM +0900, Junio C Hamano wrote:\n> \"Eric N. Vander Weele\" <ericvw@gmail.com> writes:\n> \n> > Enable printing the entries currently stashed away in the short format.\n> > This prints the stash information after the path status to be symmetric\n> > with \"status --long --show-stash\".\n> >\n> > Signed-off-by: Eric N. Vander Weele <ericvw@gmail.com>\n> > ---\n> >  Documentation/git-status.txt |  4 ++++\n> >  wt-status.c                  | 17 +++++++++++++++++\n> >  2 files changed, 21 insertions(+)\n> >\n> > diff --git a/Documentation/git-status.txt b/Documentation/git-status.txt\n> > index 7731b45f07..c1afc3282c 100644\n> > --- a/Documentation/git-status.txt\n> > +++ b/Documentation/git-status.txt\n> > @@ -244,6 +244,10 @@ If -b is used the short-format status is preceded by a line\n> >  \n> >      ## branchname tracking info\n> >  \n> > +If --show-stash is used the short-format status is followed by a line\n> > +\n> > +    ## stash: <n> (entry|entries)\n> > +\n> \n> Hmmmm.  Would readers misinterpret we are talking about a branch\n> whose name is stash something?  I am not suggesting to change ##\n> introducer to some random letters, which would break scripts even\n> worse.\n\nI could see where readers may misinterpret this as a branch name.  I\nstruggled coming up with something short while not being confusing and\nthought the presence ':' followed by a space would be clear enough.\n\n> Doesn't the Porcelain Format v1 call the same codepath as\n> shortstatus?  We promise that its output never changes to support\n> existing scripts, but now they will start seeing \"## stash:\" that\n> they do not understand and barf?\n\nI wasn't aware of the Porcelain formats in detail when originally\ncreating the patch - oops!  Naively I was following the same behavior as\n'--branch' in the shortstatus code path.\n\nDiving into this further, the Porcelain Format v1 does call the same\ncode path as shortstatus.  I see there is some handling in\nbuiltin/commit.c for tweaking the behavior of the branch being showed.\n\nThe documentation indicates that the behavior never changes between Git\nversions or based on user configuration.  'git status --porcelain=1'\nwill react to '--branch' but not when 'status.branch' is set to 'true',\nwhich is congruent with the documentation.\n\n> Isn't this information available to scripts that want to read from\n> porcelain v2 output format (which is meant to be extensible by\n> allowing easy-to-parse optional headers, which this stash thing\n> exactly is).\n\nIt is not available in Porcelain Format v2... yet :).\n\n\nI'm happy making '--show-stash' congruent with '--branch' in v1', which\nis would be in line with documented behavior, displaying something in\nv2 only, or both.  Let me know how you would like to proceed and I'll\nrework the patch accordingly.\n"},{"id":"385697","messageId":"xmqqimnwoscx.fsf@gitster-ct.c.googlers.com","threadId":"52182","inReplyTo":"20191107103141.GA87008@helium","subject":"Re: [PATCH] status: teach \"status --short\" to respect \"--show-stash\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-11-07T11:09:34Z","receivedAt":"2019-11-07T11:09:43Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Eric N. Vander Weele\" <ericvw@gmail.com> writes:\n\n>> Isn't this information available to scripts that want to read from\n>> porcelain v2 output format (which is meant to be extensible by\n>> allowing easy-to-parse optional headers, which this stash thing\n>> exactly is).\n>\n> It is not available in Porcelain Format v2... yet :).\n>\n>\n> I'm happy making '--show-stash' congruent with '--branch' in v1', which\n> is would be in line with documented behavior, displaying something in\n> v2 only, or both.  Let me know how you would like to proceed and I'll\n> rework the patch accordingly.\n\nQuite honestly, you do not want to ask _me_.  If you left it to\nme, I may say that, among the possible next step you listed, the\nbest one is to do nothing, as I do not want to see the stash info in\nthe \"status --short\" output ;-)\n\nIt probably is the safest to make it available first only in v2\nformat.  I do not know if that makes its utility too limited for the\npurpose of the application you have in mind.\n\n"},{"id":"385750","messageId":"20191108032401.GA1465@helium","threadId":"52182","inReplyTo":"xmqqimnwoscx.fsf@gitster-ct.c.googlers.com","subject":"Re: [PATCH] status: teach \"status --short\" to respect \"--show-stash\"","fromName":"Eric N. Vander Weele","fromEmail":"ericvw@gmail.com","sentAt":"2019-11-08T03:24:01Z","receivedAt":"2019-11-08T03:24:07Z","isPatch":true,"sender":{"key":"ericvw@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1284017?v=4"},"body":"On Thu, Nov 07, 2019 at 08:09:34PM +0900, Junio C Hamano wrote:\n> \"Eric N. Vander Weele\" <ericvw@gmail.com> writes:\n>\n> >> Isn't this information available to scripts that want to read from\n> >> porcelain v2 output format (which is meant to be extensible by\n> >> allowing easy-to-parse optional headers, which this stash thing\n> >> exactly is).\n> >\n> > It is not available in Porcelain Format v2... yet :).\n> >\n> >\n> > I'm happy making '--show-stash' congruent with '--branch' in v1',\n> > which is would be in line with documented behavior, displaying\n> > something in v2 only, or both.  Let me know how you would like to\n> > proceed and I'll rework the patch accordingly.\n>\n> Quite honestly, you do not want to ask _me_.  If you left it to\n> me, I may say that, among the possible next step you listed, the\n> best one is to do nothing, as I do not want to see the stash info in\n> the \"status --short\" output ;-)\n>\n> It probably is the safest to make it available first only in v2\n> format.  I do not know if that makes its utility too limited for the\n> purpose of the application you have in mind.\n\nThe application I had in mind was to remind me of potentially stray\nstashes I may have forgotten about when working on a project.  I was\nhoping to add \"--show-stash\" to my alias for \"status --short --branch\".\n\nThe v2 format is a bit too verbose for what I need and having color\noutput is a nice bonus when using \"--short\".  I don't feel strongly for\npushing this through, but I am happy with what I have learned through\nthe process of trying :).\n"}]}