{"thread":{"id":"40217","subject":"[PATCH v3] stash: Add two config variables for stash show","startedAt":"2015-08-29T15:25:57Z","lastAt":"2015-08-29T15:25:57Z","messageCount":1,"participants":["Namhyung Kim"],"isPatch":true,"patchVersion":3,"patchTotal":null},"messages":[{"id":"268906","messageId":"1440861957-26413-1-git-send-email-namhyung@gmail.com","threadId":"40217","inReplyTo":null,"subject":"[PATCH v3] stash: Add two config variables for stash show","fromName":"Namhyung Kim","fromEmail":"namhyung@gmail.com","sentAt":"2015-08-29T15:25:57Z","receivedAt":"2015-08-29T15:25:57Z","isPatch":true,"sender":{"key":"namhyung@gmail.com","avatar":"https://avatars.githubusercontent.com/u/48503?v=4"},"body":"Some users might want to see diff (patch) output always rather than\ndiffstat when [s]he runs 'git stash show'.  Although this can be done\nwith adding -p option, it'd be better to provide a config option to\ncontrol this behavior IMHO.\n\nThis patch adds two variables which control to show diffstat and patch\noutput respectively.  The stash.showStat is for diffstat and default is\ntrue.  The stat.showPatch is for the patch output and default is false.\n\nSigned-off-by: Namhyung Kim <namhyung@gmail.com>\n---\n Documentation/config.txt    | 10 ++++++++++\n Documentation/git-stash.txt |  2 ++\n git-stash.sh                | 20 +++++++++++++++++++-\n 3 files changed, 31 insertions(+), 1 deletion(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex f5d15ff..b4c8ee1 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -2567,6 +2567,16 @@ status.submoduleSummary::\n \tsubmodule summary' command, which shows a similar output but does\n \tnot honor these settings.\n \n+stash.showPatch::\n+\tIf this is set to true, the `git stash show` command without an\n+\toption will show the stash in patch form.  Defaults to false.\n+\tSee description of 'show' command in linkgit:git-stash[1].\n+\n+stash.showStat::\n+\tIf this is set to true, the `git stash show` command without an\n+\toption will show diffstat of the stash.  Defaults to true.\n+\tSee description of 'show' command in linkgit:git-stash[1].\n+\n submodule.<name>.path::\n submodule.<name>.url::\n \tThe path within this project and URL for a submodule. These\ndiff --git a/Documentation/git-stash.txt b/Documentation/git-stash.txt\nindex 375213f..92df596 100644\n--- a/Documentation/git-stash.txt\n+++ b/Documentation/git-stash.txt\n@@ -95,6 +95,8 @@ show [<stash>]::\n \tshows the latest one. By default, the command shows the diffstat, but\n \tit will accept any format known to 'git diff' (e.g., `git stash show\n \t-p stash@{1}` to view the second most recent stash in patch form).\n+\tYou can use stash.showStat and/or stash.showPatch config variables\n+\tto change the default behavior.\n \n pop [--index] [-q|--quiet] [<stash>]::\n \ndiff --git a/git-stash.sh b/git-stash.sh\nindex 1d5ba7a..c7c65e2 100755\n--- a/git-stash.sh\n+++ b/git-stash.sh\n@@ -305,7 +305,25 @@ show_stash () {\n \tALLOW_UNKNOWN_FLAGS=t\n \tassert_stash_like \"$@\"\n \n-\tgit diff ${FLAGS:---stat} $b_commit $w_commit\n+\tif test -z \"$FLAGS\"\n+\tthen\n+\t\tif test \"$(git config --bool stash.showStat || echo true)\" = \"true\"\n+\t\tthen\n+\t\t\tFLAGS=--stat\n+\t\tfi\n+\n+\t\tif test \"$(git config --bool stash.showPatch || echo false)\" = \"true\"\n+\t\tthen\n+\t\t\tFLAGS=${FLAGS}${FLAGS:+ }-p\n+\t\tfi\n+\n+\t\tif test -z \"$FLAGS\"\n+\t\tthen\n+\t\t\treturn 0\n+\t\tfi\n+\tfi\n+\n+\tgit diff ${FLAGS} $b_commit $w_commit\n }\n \n show_help () {\n-- \n2.5.0\n"}]}