All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Utilize config variable pager.stash in stash list command
@ 2011-08-14 14:31 Ingo Brückl
  2011-08-15 23:47 ` Jeff King
  0 siblings, 1 reply; 5+ messages in thread
From: Ingo Brückl @ 2011-08-14 14:31 UTC (permalink / raw)
  To: git

Signed-off-by: Ingo Brückl <ib@wupperonline.de>
---
 By now stash list ignores it.

 git-stash.sh |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/git-stash.sh b/git-stash.sh
index f4e6f05..7bb0856 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -264,7 +264,8 @@ have_stash () {

 list_stash () {
 	have_stash || return 0
-	git log --format="%gd: %gs" -g "$@" $ref_stash --
+	test "$(git config --get pager.stash)" = "false" && no_pager=--no-pager
+	git $no_pager log --format="%gd: %gs" -g "$@" $ref_stash --
 }

 show_stash () {
--
1.7.6

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

* Re: [PATCH] Utilize config variable pager.stash in stash list command
  2011-08-14 14:31 [PATCH] Utilize config variable pager.stash in stash list command Ingo Brückl
@ 2011-08-15 23:47 ` Jeff King
  2011-08-16 10:10   ` Ingo Brückl
  0 siblings, 1 reply; 5+ messages in thread
From: Jeff King @ 2011-08-15 23:47 UTC (permalink / raw)
  To: Ingo Brückl; +Cc: git

On Sun, Aug 14, 2011 at 04:31:49PM +0200, Ingo Brückl wrote:

> Signed-off-by: Ingo Brückl <ib@wupperonline.de>
> ---
>  By now stash list ignores it.
> 
>  git-stash.sh |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/git-stash.sh b/git-stash.sh
> index f4e6f05..7bb0856 100755
> --- a/git-stash.sh
> +++ b/git-stash.sh
> @@ -264,7 +264,8 @@ have_stash () {
> 
>  list_stash () {
>  	have_stash || return 0
> -	git log --format="%gd: %gs" -g "$@" $ref_stash --
> +	test "$(git config --get pager.stash)" = "false" && no_pager=--no-pager
> +	git $no_pager log --format="%gd: %gs" -g "$@" $ref_stash --
>  }

It's not quite as simple as this these days. The pager.* variables can
also point to a program to run as a pager for this specific command.

This stuff is supposed to be handled by the "git" wrapper itself, which
will either run the pager (if the config is boolean true, or a specific
command), or will set an environment variable to avoid running one for
any subcommand (if it's boolean false).

However, we don't respect pager.* config for external commands there at
all. I think this was due to some initialization-order bugs that made it
hard for us to look at config before exec'ing external commands. But
perhaps they are gone, as the patch below[1] seems to work OK for me.

---
 git.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/git.c b/git.c
index 8828c18..47a6d3d 100644
--- a/git.c
+++ b/git.c
@@ -459,6 +459,8 @@ static void execv_dashed_external(const char **argv)
 	const char *tmp;
 	int status;
 
+	if (use_pager == -1)
+		use_pager = check_pager_config(argv[0]);
 	commit_pager_choice();
 
 	strbuf_addf(&cmd, "git-%s", argv[0]);

-Peff

[1] I posted this in a similar discussion several months ago:

    http://thread.gmane.org/gmane.comp.version-control.git/161756/focus=161771

I think what it really needs is more testing to see if looking at the
config then has any unintended side effects.

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

* Re: [PATCH] Utilize config variable pager.stash in stash list command
  2011-08-15 23:47 ` Jeff King
@ 2011-08-16 10:10   ` Ingo Brückl
  2011-08-16 11:24     ` Ingo Brückl
  2011-08-16 22:56     ` Jeff King
  0 siblings, 2 replies; 5+ messages in thread
From: Ingo Brückl @ 2011-08-16 10:10 UTC (permalink / raw)
  To: git

Jeff King wrote on Mon, 15 Aug 2011 16:47:14 -0700:

> On Sun, Aug 14, 2011 at 04:31:49PM +0200, Ingo Brückl wrote:

>> Signed-off-by: Ingo Brückl <ib@wupperonline.de>
>> ---
>>  By now stash list ignores it.
>>
>>  git-stash.sh |    3 ++-
>>  1 files changed, 2 insertions(+), 1 deletions(-)
>>
>> diff --git a/git-stash.sh b/git-stash.sh
>> index f4e6f05..7bb0856 100755
>> --- a/git-stash.sh
>> +++ b/git-stash.sh
>> @@ -264,7 +264,8 @@ have_stash () {
>>
>>  list_stash () {
>>       have_stash || return 0
>> -     git log --format="%gd: %gs" -g "$@" $ref_stash --
>> +     test "$(git config --get pager.stash)" = "false" && no_pager=--no-pager
>> +     git $no_pager log --format="%gd: %gs" -g "$@" $ref_stash --
>>  }

> It's not quite as simple as this these days. The pager.* variables can
> also point to a program to run as a pager for this specific command.

> This stuff is supposed to be handled by the "git" wrapper itself, which
> will either run the pager (if the config is boolean true, or a specific
> command), or will set an environment variable to avoid running one for
> any subcommand (if it's boolean false).

> However, we don't respect pager.* config for external commands there at
> all. I think this was due to some initialization-order bugs that made it
> hard for us to look at config before exec'ing external commands. But
> perhaps they are gone, as the patch below[1] seems to work OK for me.

>  git.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)

> diff --git a/git.c b/git.c
> index 8828c18..47a6d3d 100644
> +++ b/git.c
> @@ -459,6 +459,8 @@ static void execv_dashed_external(const char **argv)
>         const char *tmp;
>         int status;
>
> +       if (use_pager == -1)
> +               use_pager = check_pager_config(argv[0]);
>         commit_pager_choice();
>
>         strbuf_addf(&cmd, "git-%s", argv[0]);

> -Peff

> [1] I posted this in a similar discussion several months ago:


> http://thread.gmane.org/gmane.comp.version-control.git/161756/focus=161771

Actually, I only wanted to change the stash list behavior (but better should
have used $(git config --get pager.stash.list) for that). Unfortunately, it
is impossible then to force the pager with --paginate again.

> I think what it really needs is more testing to see if looking at the
> config then has any unintended side effects.

Yours surely is a far better approach, although it only can handle the main
command (stash), not the sub-command (list), but this is totally in
accordance with everything else in git.

With "pager.stash false" (which would then require --paginate for a lot of
stash commands), I found that a paginated output of 'git -p stash show -p'
loses the diff colors, but that seems unrelated to your patch. It still is
strange though.

Ingo

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

* Re: [PATCH] Utilize config variable pager.stash in stash list command
  2011-08-16 10:10   ` Ingo Brückl
@ 2011-08-16 11:24     ` Ingo Brückl
  2011-08-16 22:56     ` Jeff King
  1 sibling, 0 replies; 5+ messages in thread
From: Ingo Brückl @ 2011-08-16 11:24 UTC (permalink / raw)
  To: git

I wrote on Tue, 16 Aug 2011 12:10:45 +0200:

> Actually, I only wanted to change the stash list behavior (but better
> should have used $(git config --get pager.stash.list) for that).
> Unfortunately, it is impossible then to force the pager with --paginate
> again.

Actually, it *is* possible to force the pager with --paginate again, so this
is exactly what I was trying to achieve (only using pager.stash.list now).

Ingo

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

* Re: [PATCH] Utilize config variable pager.stash in stash list command
  2011-08-16 10:10   ` Ingo Brückl
  2011-08-16 11:24     ` Ingo Brückl
@ 2011-08-16 22:56     ` Jeff King
  1 sibling, 0 replies; 5+ messages in thread
From: Jeff King @ 2011-08-16 22:56 UTC (permalink / raw)
  To: Ingo Brückl; +Cc: git

On Tue, Aug 16, 2011 at 12:10:45PM +0200, Ingo Brückl wrote:

> > http://thread.gmane.org/gmane.comp.version-control.git/161756/focus=161771
> 
> Actually, I only wanted to change the stash list behavior (but better should
> have used $(git config --get pager.stash.list) for that). Unfortunately, it
> is impossible then to force the pager with --paginate again.
> 
> > I think what it really needs is more testing to see if looking at the
> > config then has any unintended side effects.
> 
> Yours surely is a far better approach, although it only can handle the main
> command (stash), not the sub-command (list), but this is totally in
> accordance with everything else in git.

Yeah, that is a general problem with git's pager handling. We only have
one context: a single git command. But some commands may have multiple
subcommands, and a pager only makes sense for some of them.

You've run into it for "stash show", but it is no different than
something like "git branch". You might want the list of branches to go
through a pager, but almost certainly not branch creation or deletion
operations.

I think something like pager.stash.list is the right way forward. But
your patch by itself isn't enough. It only handles the negative case.
Setting "pager.stash.list" to "true" would do nothing.

> With "pager.stash false" (which would then require --paginate for a lot of
> stash commands), I found that a paginated output of 'git -p stash show -p'
> loses the diff colors, but that seems unrelated to your patch. It still is
> strange though.

We auto-detect whether to use colors based on whether we are outputting
to a terminal or not. If we start the pager ourselves, we will also
output colors (unless color.pager is false). I suspect the "pager in
use" flag is not making it to the external command.

-Peff

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

end of thread, other threads:[~2011-08-16 22:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-14 14:31 [PATCH] Utilize config variable pager.stash in stash list command Ingo Brückl
2011-08-15 23:47 ` Jeff King
2011-08-16 10:10   ` Ingo Brückl
2011-08-16 11:24     ` Ingo Brückl
2011-08-16 22:56     ` Jeff King

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.