From: Namhyung Kim <namhyung@gmail.com>
To: git@vger.kernel.org
Subject: [PATCH v3] stash: Add two config variables for stash show
Date: Sun, 30 Aug 2015 00:25:57 +0900 [thread overview]
Message-ID: <1440861957-26413-1-git-send-email-namhyung@gmail.com> (raw)
Some users might want to see diff (patch) output always rather than
diffstat when [s]he runs 'git stash show'. Although this can be done
with adding -p option, it'd be better to provide a config option to
control this behavior IMHO.
This patch adds two variables which control to show diffstat and patch
output respectively. The stash.showStat is for diffstat and default is
true. The stat.showPatch is for the patch output and default is false.
Signed-off-by: Namhyung Kim <namhyung@gmail.com>
---
Documentation/config.txt | 10 ++++++++++
Documentation/git-stash.txt | 2 ++
git-stash.sh | 20 +++++++++++++++++++-
3 files changed, 31 insertions(+), 1 deletion(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index f5d15ff..b4c8ee1 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -2567,6 +2567,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
diff --git a/Documentation/git-stash.txt b/Documentation/git-stash.txt
index 375213f..92df596 100644
--- a/Documentation/git-stash.txt
+++ b/Documentation/git-stash.txt
@@ -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>]::
diff --git a/git-stash.sh b/git-stash.sh
index 1d5ba7a..c7c65e2 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 () {
--
2.5.0
reply other threads:[~2015-08-29 15:29 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1440861957-26413-1-git-send-email-namhyung@gmail.com \
--to=namhyung@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).