threads / patch / 28121

patchstash: Utilize config variable pager.stash.list in stash list command

Subject: [PATCH] stash: Utilize config variable pager.stash.list in stash list command

## tl;dr

5 messages between Aug 16, 2011 and Aug 18, 2011. Diffs are folded; open one to read it.

replies: 4people: 3as markdown or json

Ingo Brückl· Aug 16, 2011, 11:47 UTC · lore

Usually it is annoying that the pager is used for stash list output, so the config variable pager.stash.list will be utilized now and is a way to control stash list's behavior.

Signed-off-by: Ingo Brückl <ib@wupperonline.de>
---
 git-stash.sh |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
Show changes to git-stash.sh +2 −2
diff --git a/git-stash.sh b/git-stash.sh
index f4e6f05..29702ab 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.list)" = "false" && no_pager=--no-pager
+	git $no_pager log --format="%gd: %gs" -g "$@" $ref_stash --
 }

 show_stash () {
--
1.7.6
Ingo Brückl· Aug 17, 2011, 09:04 UTC · re: Ingo Brückl · lore

Re: [PATCH] stash: Utilize config variable pager.stash.list in stash list command

Usually it is annoying that the pager is used for stash list output, so the config variable pager.stash.list will be utilized now and is a way to control stash list's behavior.

Signed-off-by: Ingo Brückl <ib@wupperonline.de>
---
 This is the 2nd attempt, now checking for true and false.
 git-stash.sh |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
Show changes to git-stash.sh +4 −2
diff --git a/git-stash.sh b/git-stash.sh
index f4e6f05..3712a17 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -264,7 +264,10 @@ have_stash () {

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

 show_stash () {
--
1.7.6
Junio C Hamano· Aug 17, 2011, 18:44 UTC · re: Ingo Brückl · lore

Re: [PATCH] stash: Utilize config variable pager.stash.list in stash list command

At least "pager.stash.list" should be spelled as "pager.stashList" or something. It is not like there are multitude of arbigrary choices that may match "pager.*.list" pattern.

Also a variable can be set to false by setting it to 0, no, etc., so you need to inspect it with "git config --bool" to get the canonical version of its value.

What's so difficult to say "git stash list | less" or even "git -p stash list"?
Jeff King· Aug 18, 2011, 04:26 UTC · re: Junio C Hamano · lore

Re: [PATCH] stash: Utilize config variable pager.stash.list in stash list command

On Wed, Aug 17, 2011 at 11:44:32AM -0700, Junio C Hamano wrote:
> At least "pager.stash.list" should be spelled as "pager.stashList" or
> something. It is not like there are multitude of arbigrary choices that
> may match "pager.*.list" pattern.

The pager code would then assume that was for a command "stashlist". It probably doesn't matter in practice, but I think it's a little nicer to keep the namespace properly separated unless there is a good reason not to.

There are other places where something like this might be handy, too. For example, auto-pagination of "git branch" or "git tag -l" (but you wouldn't want to paginate "git branch foo").

Show 6 quoted lines
> Also a variable can be set to false by setting it to 0, no, etc., so
> you need to inspect it with "git config --bool" to get the canonical
> version of its value.
> 
> What's so difficult to say "git stash list | less" or even "git -p
> stash list"?
Couldn't one make the same argument about git's entire use of the pager?

Anyway, I think his problem is not "I want a pager but I am too lazy to type it", but rather that "git stash list" will auto-paginate by default, because it is chaining to "log", which auto-paginates. You can turn it off with "--no-pager", but pager.stash seems to have no effect.

-Peff
Ingo Brückl· Aug 18, 2011, 07:55 UTC · re: Jeff King · lore

Re: [PATCH] stash: Utilize config variable pager.stash.list in stash list command

Jeff King wrote on Wed, 17 Aug 2011 21:26:37 -0700:
> On Wed, Aug 17, 2011 at 11:44:32AM -0700, Junio C Hamano wrote:
>> What's so difficult to say "git stash list | less" or even "git -p
>> stash list"?
> Anyway, I think his problem is not "I want a pager but I am too lazy to
> type it", but rather that "git stash list" will auto-paginate by
> default, because it is chaining to "log", which auto-paginates. You can
> turn it off with "--no-pager", but pager.stash seems to have no effect.

I'd like to mention that in this particular case it is ok that stash auto-paginates, it only is annoying that "stash list" does. And, Junio, it is totally ok to say "git -p stash list" then, because this is exactely what I'd do.

Ingo

← back to recent threads