Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Junio C Hamano committed Oct 5, 2015
2 parents 88bad58 + 3086c06 commit 5e9a74b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
10 changes: 10 additions & 0 deletions Documentation/config.txt
Expand Up @@ -2587,6 +2587,16 @@ status.submoduleSummary::
submodule summary' command, which shows a similar output but does
not honor these settings.

stash.showPatch::
If this is set to true, the `git stash show` command without an
option will show the stash in patch form. Defaults to false.
See description of 'show' command in linkgit:git-stash[1].

stash.showStat::
If this is set to true, the `git stash show` command without an
option will show diffstat of the stash. Defaults to true.
See description of 'show' command in linkgit:git-stash[1].

submodule.<name>.path::
submodule.<name>.url::
The path within this project and URL for a submodule. These
Expand Down
2 changes: 2 additions & 0 deletions Documentation/git-stash.txt
Expand Up @@ -95,6 +95,8 @@ show [<stash>]::
shows the latest one. By default, the command shows the diffstat, but
it will accept any format known to 'git diff' (e.g., `git stash show
-p stash@{1}` to view the second most recent stash in patch form).
You can use stash.showStat and/or stash.showPatch config variables
to change the default behavior.

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

Expand Down
20 changes: 19 additions & 1 deletion git-stash.sh
Expand Up @@ -305,7 +305,25 @@ show_stash () {
ALLOW_UNKNOWN_FLAGS=t
assert_stash_like "$@"

git diff ${FLAGS:---stat} $b_commit $w_commit
if test -z "$FLAGS"
then
if test "$(git config --bool stash.showStat || echo true)" = "true"
then
FLAGS=--stat
fi

if test "$(git config --bool stash.showPatch || echo false)" = "true"
then
FLAGS=${FLAGS}${FLAGS:+ }-p
fi

if test -z "$FLAGS"
then
return 0
fi
fi

git diff ${FLAGS} $b_commit $w_commit
}

show_help () {
Expand Down

0 comments on commit 5e9a74b

Please sign in to comment.