Skip to contentSkip to conversation

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

PATCH In review Ingo Brückl 3 participants 5 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 git-stash.sh |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
git-stash.sh +2 -1
index f4e6f05..29702ab 100755
@@ -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

#1 lore raw

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.

---
This is the 2nd attempt, now checking for true and false.

 git-stash.sh |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
git-stash.sh +4 -1
index f4e6f05..3712a17 100755
@@ -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

#2 lore raw

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"?

#3 lore raw
Quoted 3 lines · Junio C Hamano

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").

Quoted 6 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

#4 lore raw

Jeff King wrote on Wed, 17 Aug 2011 21:26:37 -0700:

Quoted 9 lines · Junio C Hamano
Quoted 3 lines

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