From: Junio C Hamano <gitster@pobox•com>
To: Jeff King <peff@peff•net>
Cc: git@vger•kernel.org
Subject: Re: [PATCH] stash: default listing to working-tree diff
Date: Thu, 07 Aug 2014 14:39:02 -0700 [thread overview]
Message-ID: <xmqqk36kj7yh.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <20140806183525.GA21254@peff.net> (Jeff King's message of "Wed, 6 Aug 2014 14:35:25 -0400")
Jeff King <peff@peff•net> writes:
> See the patch below, which I think could replace the top three from
> jk/stash-list-p (or really, could replace the whole series, and the
> bottom three could go into their own topic).
Sounds sensible. Let's split those three changes into a separate
topic (jk/pretty-empty-format) and queue this independently.
Thanks.
> -- >8 --
> Subject: stash: default listing to working-tree diff
>
> 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 defaulting to "--first-parent -m", which will
> show the diff against the working tree. This omits the
> index portion of the stash entirely, but it's simple and it
> matches what "git stash show" provides.
>
> People who are more clueful about stash's true form can use
> "--cc" to override the "-m", and the "--first-parent" will
> then do nothing. For diffs, it only affects non-combined
> diffs, so "--cc" overrides it. And for the traversal, we are
> walking the linear reflog anyway, so we do not even care
> about the parents.
>
> Signed-off-by: Jeff King <peff@peff•net>
> ---
> git-stash.sh | 2 +-
> t/t3903-stash.sh | 42 ++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 43 insertions(+), 1 deletion(-)
>
> diff --git a/git-stash.sh b/git-stash.sh
> index bcc757b..9c1ba8e 100755
> --- a/git-stash.sh
> +++ b/git-stash.sh
> @@ -297,7 +297,7 @@ have_stash () {
>
> list_stash () {
> have_stash || return 0
> - git log --format="%gd: %gs" -g "$@" $ref_stash --
> + git log --format="%gd: %gs" -g --first-parent -m "$@" $ref_stash --
> }
>
> show_stash () {
> diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh
> index 5b79b21..1e29962 100755
> --- a/t/t3903-stash.sh
> +++ b/t/t3903-stash.sh
> @@ -685,4 +685,46 @@ test_expect_success 'handle stash specification with spaces' '
> grep pig file
> '
>
> +test_expect_success 'setup stash with index and worktree changes' '
> + git stash clear &&
> + git reset --hard &&
> + echo index >file &&
> + git add file &&
> + echo working >file &&
> + git stash
> +'
> +
> +test_expect_success 'stash list implies --first-parent -m' '
> + 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
> + git stash list -p >actual &&
> + test_cmp expect actual
> +'
> +
> +test_expect_success 'stash list --cc shows combined diff' '
> + 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
> + git stash list -p --cc >actual &&
> + test_cmp expect actual
> +'
> +
> test_done
prev parent reply other threads:[~2014-08-07 21:39 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-01 22:01 What's cooking in git.git (Aug 2014, #01; Fri, 1) Junio C Hamano
2014-08-06 8:11 ` Jeff King
2014-08-06 17:12 ` Junio C Hamano
2014-08-06 18:35 ` [PATCH] stash: default listing to working-tree diff Jeff King
2014-08-07 21:39 ` Junio C Hamano [this message]
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=xmqqk36kj7yh.fsf@gitster.dls.corp.google.com \
--to=gitster@pobox$(echo .)com \
--cc=git@vger$(echo .)kernel.org \
--cc=peff@peff$(echo .)net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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