diff --git a/Documentation/config.txt b/Documentation/config.txt index 0cc87a6f6..e935cbdc0 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -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..path:: submodule..url:: The path within this project and URL for a submodule. These diff --git a/Documentation/git-stash.txt b/Documentation/git-stash.txt index 375213fe4..92df596e5 100644 --- a/Documentation/git-stash.txt +++ b/Documentation/git-stash.txt @@ -95,6 +95,8 @@ show []:: 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] []:: diff --git a/git-stash.sh b/git-stash.sh index 1d5ba7a4f..c7c65e25f 100755 --- a/git-stash.sh +++ b/git-stash.sh @@ -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 () {