Skip to content

Commit 5e9a74b

Browse files
committed
Merge branch 'nk/stash-show-config'
Users who are too busy to type three extra keystrokes to ask for "git stash show -p" can now set stash.showPatch configuration varible to true to always see the actual patch, not just the list of paths affected with feel for the extent of damage via diffstat. * nk/stash-show-config: stash: allow "stash show" diff output configurable
2 parents 88bad58 + 3086c06 commit 5e9a74b

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

Documentation/config.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2587,6 +2587,16 @@ status.submoduleSummary::
25872587
submodule summary' command, which shows a similar output but does
25882588
not honor these settings.
25892589

2590+
stash.showPatch::
2591+
If this is set to true, the `git stash show` command without an
2592+
option will show the stash in patch form. Defaults to false.
2593+
See description of 'show' command in linkgit:git-stash[1].
2594+
2595+
stash.showStat::
2596+
If this is set to true, the `git stash show` command without an
2597+
option will show diffstat of the stash. Defaults to true.
2598+
See description of 'show' command in linkgit:git-stash[1].
2599+
25902600
submodule.<name>.path::
25912601
submodule.<name>.url::
25922602
The path within this project and URL for a submodule. These

Documentation/git-stash.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ show [<stash>]::
9595
shows the latest one. By default, the command shows the diffstat, but
9696
it will accept any format known to 'git diff' (e.g., `git stash show
9797
-p stash@{1}` to view the second most recent stash in patch form).
98+
You can use stash.showStat and/or stash.showPatch config variables
99+
to change the default behavior.
98100

99101
pop [--index] [-q|--quiet] [<stash>]::
100102

git-stash.sh

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,25 @@ show_stash () {
305305
ALLOW_UNKNOWN_FLAGS=t
306306
assert_stash_like "$@"
307307

308-
git diff ${FLAGS:---stat} $b_commit $w_commit
308+
if test -z "$FLAGS"
309+
then
310+
if test "$(git config --bool stash.showStat || echo true)" = "true"
311+
then
312+
FLAGS=--stat
313+
fi
314+
315+
if test "$(git config --bool stash.showPatch || echo false)" = "true"
316+
then
317+
FLAGS=${FLAGS}${FLAGS:+ }-p
318+
fi
319+
320+
if test -z "$FLAGS"
321+
then
322+
return 0
323+
fi
324+
fi
325+
326+
git diff ${FLAGS} $b_commit $w_commit
309327
}
310328

311329
show_help () {

0 commit comments

Comments
 (0)