git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] status: teach "status --short" to respect "--show-stash"
@ 2019-11-04 10:03 Eric N. Vander Weele
  2019-11-06  2:33 ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Eric N. Vander Weele @ 2019-11-04 10:03 UTC (permalink / raw)
  To: git; +Cc: Eric N. Vander Weele

Enable printing the entries currently stashed away in the short format.
This prints the stash information after the path status to be symmetric
with "status --long --show-stash".

Signed-off-by: Eric N. Vander Weele <ericvw@gmail.com>
---
 Documentation/git-status.txt |  4 ++++
 wt-status.c                  | 17 +++++++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/Documentation/git-status.txt b/Documentation/git-status.txt
index 7731b45f07..c1afc3282c 100644
--- a/Documentation/git-status.txt
+++ b/Documentation/git-status.txt
@@ -244,6 +244,10 @@ If -b is used the short-format status is preceded by a line
 
     ## branchname tracking info
 
+If --show-stash is used the short-format status is followed by a line
+
+    ## stash: <n> (entry|entries)
+
 Porcelain Format Version 1
 ~~~~~~~~~~~~~~~~~~~~~~~~~~
 
diff --git a/wt-status.c b/wt-status.c
index cc6f94504d..c6d112081b 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -1956,6 +1956,20 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)
 	fputc(s->null_termination ? '\0' : '\n', s->fp);
 }
 
+static void wt_shortstatus_print_stash(struct wt_status *s)
+{
+	int stash_count = 0;
+
+	for_each_reflog_ent("refs/stash", stash_count_refs, &stash_count);
+	if (stash_count > 0) {
+		color_fprintf(s->fp, color(WT_STATUS_HEADER, s), "## ");
+		status_printf_ln(s, GIT_COLOR_NORMAL,
+				 Q_("stash: %d entry",
+				    "stash: %d entries", stash_count),
+				 stash_count);
+	}
+}
+
 static void wt_shortstatus_print(struct wt_status *s)
 {
 	struct string_list_item *it;
@@ -1976,6 +1990,9 @@ static void wt_shortstatus_print(struct wt_status *s)
 
 	for_each_string_list_item(it, &s->ignored)
 		wt_shortstatus_other(it, s, "!!");
+
+	if (s->show_stash)
+		wt_shortstatus_print_stash(s);
 }
 
 static void wt_porcelain_print(struct wt_status *s)
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] status: teach "status --short" to respect "--show-stash"
  2019-11-04 10:03 [PATCH] status: teach "status --short" to respect "--show-stash" Eric N. Vander Weele
@ 2019-11-06  2:33 ` Junio C Hamano
  2019-11-07 10:31   ` Eric N. Vander Weele
  0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2019-11-06  2:33 UTC (permalink / raw)
  To: Eric N. Vander Weele; +Cc: git

"Eric N. Vander Weele" <ericvw@gmail.com> writes:

> Enable printing the entries currently stashed away in the short format.
> This prints the stash information after the path status to be symmetric
> with "status --long --show-stash".
>
> Signed-off-by: Eric N. Vander Weele <ericvw@gmail.com>
> ---
>  Documentation/git-status.txt |  4 ++++
>  wt-status.c                  | 17 +++++++++++++++++
>  2 files changed, 21 insertions(+)
>
> diff --git a/Documentation/git-status.txt b/Documentation/git-status.txt
> index 7731b45f07..c1afc3282c 100644
> --- a/Documentation/git-status.txt
> +++ b/Documentation/git-status.txt
> @@ -244,6 +244,10 @@ If -b is used the short-format status is preceded by a line
>  
>      ## branchname tracking info
>  
> +If --show-stash is used the short-format status is followed by a line
> +
> +    ## stash: <n> (entry|entries)
> +

Hmmmm.  Would readers misinterpret we are talking about a branch
whose name is stash something?  I am not suggesting to change ##
introducer to some random letters, which would break scripts even
worse.

Doesn't the Porcelain Format v1 call the same codepath as
shortstatus?  We promise that its output never changes to support
existing scripts, but now they will start seeing "## stash:" that
they do not understand and barf?

Isn't this information available to scripts that want to read from
porcelain v2 output format (which is meant to be extensible by
allowing easy-to-parse optional headers, which this stash thing
exactly is).

Thanks.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] status: teach "status --short" to respect "--show-stash"
  2019-11-06  2:33 ` Junio C Hamano
@ 2019-11-07 10:31   ` Eric N. Vander Weele
  2019-11-07 11:09     ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Eric N. Vander Weele @ 2019-11-07 10:31 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On Wed, Nov 06, 2019 at 11:33:42AM +0900, Junio C Hamano wrote:
> "Eric N. Vander Weele" <ericvw@gmail.com> writes:
> 
> > Enable printing the entries currently stashed away in the short format.
> > This prints the stash information after the path status to be symmetric
> > with "status --long --show-stash".
> >
> > Signed-off-by: Eric N. Vander Weele <ericvw@gmail.com>
> > ---
> >  Documentation/git-status.txt |  4 ++++
> >  wt-status.c                  | 17 +++++++++++++++++
> >  2 files changed, 21 insertions(+)
> >
> > diff --git a/Documentation/git-status.txt b/Documentation/git-status.txt
> > index 7731b45f07..c1afc3282c 100644
> > --- a/Documentation/git-status.txt
> > +++ b/Documentation/git-status.txt
> > @@ -244,6 +244,10 @@ If -b is used the short-format status is preceded by a line
> >  
> >      ## branchname tracking info
> >  
> > +If --show-stash is used the short-format status is followed by a line
> > +
> > +    ## stash: <n> (entry|entries)
> > +
> 
> Hmmmm.  Would readers misinterpret we are talking about a branch
> whose name is stash something?  I am not suggesting to change ##
> introducer to some random letters, which would break scripts even
> worse.

I could see where readers may misinterpret this as a branch name.  I
struggled coming up with something short while not being confusing and
thought the presence ':' followed by a space would be clear enough.

> Doesn't the Porcelain Format v1 call the same codepath as
> shortstatus?  We promise that its output never changes to support
> existing scripts, but now they will start seeing "## stash:" that
> they do not understand and barf?

I wasn't aware of the Porcelain formats in detail when originally
creating the patch - oops!  Naively I was following the same behavior as
'--branch' in the shortstatus code path.

Diving into this further, the Porcelain Format v1 does call the same
code path as shortstatus.  I see there is some handling in
builtin/commit.c for tweaking the behavior of the branch being showed.

The documentation indicates that the behavior never changes between Git
versions or based on user configuration.  'git status --porcelain=1'
will react to '--branch' but not when 'status.branch' is set to 'true',
which is congruent with the documentation.

> Isn't this information available to scripts that want to read from
> porcelain v2 output format (which is meant to be extensible by
> allowing easy-to-parse optional headers, which this stash thing
> exactly is).

It is not available in Porcelain Format v2... yet :).


I'm happy making '--show-stash' congruent with '--branch' in v1', which
is would be in line with documented behavior, displaying something in
v2 only, or both.  Let me know how you would like to proceed and I'll
rework the patch accordingly.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] status: teach "status --short" to respect "--show-stash"
  2019-11-07 10:31   ` Eric N. Vander Weele
@ 2019-11-07 11:09     ` Junio C Hamano
  2019-11-08  3:24       ` Eric N. Vander Weele
  0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2019-11-07 11:09 UTC (permalink / raw)
  To: Eric N. Vander Weele; +Cc: git

"Eric N. Vander Weele" <ericvw@gmail.com> writes:

>> Isn't this information available to scripts that want to read from
>> porcelain v2 output format (which is meant to be extensible by
>> allowing easy-to-parse optional headers, which this stash thing
>> exactly is).
>
> It is not available in Porcelain Format v2... yet :).
>
>
> I'm happy making '--show-stash' congruent with '--branch' in v1', which
> is would be in line with documented behavior, displaying something in
> v2 only, or both.  Let me know how you would like to proceed and I'll
> rework the patch accordingly.

Quite honestly, you do not want to ask _me_.  If you left it to
me, I may say that, among the possible next step you listed, the
best one is to do nothing, as I do not want to see the stash info in
the "status --short" output ;-)

It probably is the safest to make it available first only in v2
format.  I do not know if that makes its utility too limited for the
purpose of the application you have in mind.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] status: teach "status --short" to respect "--show-stash"
  2019-11-07 11:09     ` Junio C Hamano
@ 2019-11-08  3:24       ` Eric N. Vander Weele
  0 siblings, 0 replies; 5+ messages in thread
From: Eric N. Vander Weele @ 2019-11-08  3:24 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On Thu, Nov 07, 2019 at 08:09:34PM +0900, Junio C Hamano wrote:
> "Eric N. Vander Weele" <ericvw@gmail.com> writes:
>
> >> Isn't this information available to scripts that want to read from
> >> porcelain v2 output format (which is meant to be extensible by
> >> allowing easy-to-parse optional headers, which this stash thing
> >> exactly is).
> >
> > It is not available in Porcelain Format v2... yet :).
> >
> >
> > I'm happy making '--show-stash' congruent with '--branch' in v1',
> > which is would be in line with documented behavior, displaying
> > something in v2 only, or both.  Let me know how you would like to
> > proceed and I'll rework the patch accordingly.
>
> Quite honestly, you do not want to ask _me_.  If you left it to
> me, I may say that, among the possible next step you listed, the
> best one is to do nothing, as I do not want to see the stash info in
> the "status --short" output ;-)
>
> It probably is the safest to make it available first only in v2
> format.  I do not know if that makes its utility too limited for the
> purpose of the application you have in mind.

The application I had in mind was to remind me of potentially stray
stashes I may have forgotten about when working on a project.  I was
hoping to add "--show-stash" to my alias for "status --short --branch".

The v2 format is a bit too verbose for what I need and having color
output is a nice bonus when using "--short".  I don't feel strongly for
pushing this through, but I am happy with what I have learned through
the process of trying :).

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-11-08  3:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-04 10:03 [PATCH] status: teach "status --short" to respect "--show-stash" Eric N. Vander Weele
2019-11-06  2:33 ` Junio C Hamano
2019-11-07 10:31   ` Eric N. Vander Weele
2019-11-07 11:09     ` Junio C Hamano
2019-11-08  3:24       ` Eric N. Vander Weele

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).