From: Jeff King <peff@peff.net>
To: git@vger.kernel.org
Subject: [PATCH v2 5/6] stash: default listing to "--cc --simplify-combined-diff"
Date: Tue, 29 Jul 2014 13:57:25 -0400 [thread overview]
Message-ID: <20140729175725.GE31181@peff.net> (raw)
In-Reply-To: <20140729175300.GA21536@peff.net>
When you list stashes, you can provide arbitrary git-log
options to change the display. However, adding just "-p"
does nothing, because each stash is actually a merge commit.
This implementation detail is easy to forget, leading to
confused users who think "-p" is not working. We can make
this easier by specifying "--cc" as a default ourselves
(which does nothing if no diff format is requested by the
user).
The resulting diff would then be a combined diff between the
base commit and the stashed index state. In many cases,
though, the user did not stash anything in the index. We can
further simplify this to a normal pairwise diff by using
"--simplify-combined-diff".
Signed-off-by: Jeff King <peff@peff.net>
---
git-stash.sh | 3 ++-
t/t3903-stash.sh | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 65 insertions(+), 1 deletion(-)
diff --git a/git-stash.sh b/git-stash.sh
index bcc757b..a0246d5 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -297,7 +297,8 @@ have_stash () {
list_stash () {
have_stash || return 0
- git log --format="%gd: %gs" -g "$@" $ref_stash --
+ git log --format="%gd: %gs" -g --cc --simplify-combined-diff \
+ "$@" $ref_stash --
}
show_stash () {
diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh
index 5b79b21..465f824 100755
--- a/t/t3903-stash.sh
+++ b/t/t3903-stash.sh
@@ -685,4 +685,67 @@ test_expect_success 'handle stash specification with spaces' '
grep pig file
'
+test_expect_success 'stash list implies --cc' '
+ git stash clear &&
+ git reset --hard &&
+ echo index >file &&
+ git add file &&
+ echo working >file &&
+ git stash &&
+ git stash list -p >actual &&
+ cat >expect <<-\EOF &&
+ stash@{0}: WIP on master: b27a2bc subdir
+
+ diff --cc file
+ index 257cc56,9015a7a..d26b33d
+ --- a/file
+ +++ b/file
+ @@@ -1,1 -1,1 +1,1 @@@
+ - foo
+ -index
+ ++working
+ EOF
+ test_cmp expect actual
+'
+
+test_expect_success 'stash list implies --simplify-combined-diff' '
+ git stash clear &&
+ git reset --hard &&
+ echo working >file &&
+ git stash &&
+ git stash list -p >actual &&
+ cat >expect <<-\EOF &&
+ stash@{0}: WIP on master: b27a2bc subdir
+
+ diff --git a/file b/file
+ index 257cc56..d26b33d 100644
+ --- a/file
+ +++ b/file
+ @@ -1 +1 @@
+ -foo
+ +working
+ EOF
+ test_cmp expect actual
+'
+
+test_expect_success '--no-simplify-combined-diff overrides default' '
+ git stash clear &&
+ git reset --hard &&
+ echo working >file &&
+ git stash &&
+ git stash list -p --no-simplify-combined-diff >actual &&
+ cat >expect <<-\EOF &&
+ stash@{0}: WIP on master: b27a2bc subdir
+
+ diff --cc file
+ index 257cc56,257cc56..d26b33d
+ --- a/file
+ +++ b/file
+ @@@ -1,1 -1,1 +1,1 @@@
+ --foo
+ ++working
+ EOF
+ test_cmp expect actual
+'
+
test_done
--
2.1.0.rc0.286.g5c67d74
next prev parent reply other threads:[~2014-07-29 17:57 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-29 11:53 [PATCH 0/2] improving "git stash list -p" Jeff King
2014-07-29 12:00 ` [PATCH 1/2] add --simplify-combined-diff option Jeff King
2014-07-29 13:00 ` Jeff King
2014-07-29 12:03 ` [PATCH 2/2] stash: default listing to "--cc --simplify-combined-diff" Jeff King
2014-07-29 12:07 ` [RFC/PATCH 3/2] stash: show combined diff with "stash show" Jeff King
2014-07-29 18:13 ` Junio C Hamano
2014-07-31 0:17 ` Jeff King
2014-07-31 0:28 ` Junio C Hamano
2014-07-29 17:53 ` [PATCH v2 0/6] improving "git stash list -p" Jeff King
2014-07-29 17:53 ` [PATCH v2 1/6] revision: drop useless string offset when parsing "--pretty" Jeff King
2014-07-29 17:54 ` [PATCH v2 2/6] pretty: treat "--format=" as an empty userformat Jeff King
2014-07-29 17:56 ` [PATCH v2 3/6] pretty: make empty userformats truly empty Jeff King
2014-07-29 17:57 ` [PATCH v2 4/6] add --simplify-combined-diff option Jeff King
2014-07-29 20:02 ` Junio C Hamano
2014-07-29 17:57 ` Jeff King [this message]
2014-07-29 18:58 ` [PATCH v2 5/6] stash: default listing to "--cc --simplify-combined-diff" Junio C Hamano
2014-07-30 19:43 ` Junio C Hamano
2014-07-31 0:09 ` Jeff King
2014-08-12 23:30 ` Keller, Jacob E
2014-07-29 17:58 ` [PATCH v2 6/6] stash: show combined diff with "stash show" Jeff King
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=20140729175725.GE31181@peff.net \
--to=peff@peff.net \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.