git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Joel Teichroeb <joel@teichroeb.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: "Git Mailing List" <git@vger.kernel.org>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	"Johannes Schindelin" <Johannes.Schindelin@gmx.de>,
	"Jeff King" <peff@peff.net>,
	"Christian Couder" <christian.couder@gmail.com>
Subject: Re: [PATCH v4 2/5] stash: Add a test for when apply fails during stash branch
Date: Tue, 13 Jun 2017 12:54:37 -0700	[thread overview]
Message-ID: <CA+CzEk8QiSu4heMDsx7XC729UEPNm6hdZfs9W5uwoJBvuLWr+w@mail.gmail.com> (raw)
In-Reply-To: <xmqqefun65h0.fsf@gitster.mtv.corp.google.com>

On Tue, Jun 13, 2017 at 12:40 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Joel Teichroeb <joel@teichroeb.net> writes:
>
>> If the return value of merge recurisve is not checked, the stash could end
>> up being dropped even though it was not applied properly
>
> s/recurisve/recursive/
>
>> Signed-off-by: Joel Teichroeb <joel@teichroeb.net>
>> ---
>>  t/t3903-stash.sh | 14 ++++++++++++++
>>  1 file changed, 14 insertions(+)
>>
>> diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh
>> index cc923e6335..5399fb05ca 100755
>> --- a/t/t3903-stash.sh
>> +++ b/t/t3903-stash.sh
>> @@ -656,6 +656,20 @@ test_expect_success 'stash branch should not drop the stash if the branch exists
>>       git rev-parse stash@{0} --
>>  '
>>
>> +test_expect_success 'stash branch should not drop the stash if the apply fails' '
>> +     git stash clear &&
>> +     git reset HEAD~1 --hard &&
>> +     echo foo >file &&
>> +     git add file &&
>> +     git commit -m initial &&
>
> It's not quite intuitive to call a non-root commit "initial" ;-)
>
>> +     echo bar >file &&
>> +     git stash &&
>> +     echo baz >file &&
>
> OK, so 'file' has 'foo' in HEAD, 'bar' in the stash@{0}.
>
>> +     test_when_finished "git checkout master" &&
>> +     test_must_fail git stash branch new_branch stash@{0} &&
>
> Hmph.  Do we blindly checkout new_branch out of stash@{0}^1 and
> unstash, but because 'file' in the working tree is dirty, we fail to
> apply the stash and stop?
>
> This sounds like a bug to me.  Shouldn't we be staying on 'master',
> and fail without even creating 'new_branch', when this happens?

Good point. The existing behavior is to create new_branch and check it
out. I'm not sure what the correct state should be then. Create
new_branch, checkout new_branch, fail to apply, checkout master?
Should it then delete new_branch? Is there a way instead to test
applying the stash before creating the branch without actually
applying it? Something like putting merge_recursive into some kind of
dry-run mode?

>
> In any case we should be testing what branch we are on after this
> step.  What branch should we be on after "git stash branch" fails?
>
>> +     git rev-parse stash@{0} --
>> +'
>> +
>>  test_expect_success 'stash apply shows status same as git status (relative to current directory)' '
>>       git stash clear &&
>>       echo 1 >subdir/subfile1 &&

  reply	other threads:[~2017-06-13 19:55 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-08  0:55 [PATCH v4 0/5] Implement git stash as a builtin command Joel Teichroeb
2017-06-08  0:55 ` [PATCH v4 1/5] stash: add test for stash create with no files Joel Teichroeb
2017-06-13 19:31   ` Junio C Hamano
2017-06-08  0:55 ` [PATCH v4 2/5] stash: Add a test for when apply fails during stash branch Joel Teichroeb
2017-06-13 19:40   ` Junio C Hamano
2017-06-13 19:54     ` Joel Teichroeb [this message]
2017-06-08  0:55 ` [PATCH v4 3/5] stash: add test for stashing in a detached state Joel Teichroeb
2017-06-13 19:45   ` Junio C Hamano
2017-06-13 19:48     ` Joel Teichroeb
2017-06-13 20:58       ` Junio C Hamano
2017-06-08  0:55 ` [PATCH v4 4/5] merge: close the index lock when not writing the new index Joel Teichroeb
2017-06-13 19:47   ` Junio C Hamano
2017-06-08  0:55 ` [PATCH v4 5/5] stash: implement builtin stash Joel Teichroeb
2017-06-11 21:27   ` Thomas Gummerer
2017-06-20  2:37     ` Joel Teichroeb
2017-06-25 21:09       ` Thomas Gummerer
2017-06-26  7:53         ` Matthieu Moy
2017-06-27 14:53           ` Thomas Gummerer
2017-06-16 16:15   ` Junio C Hamano
2017-06-16 22:47   ` Junio C Hamano
2017-06-19 13:16     ` Johannes Schindelin
2017-06-19 13:20       ` Jeff King
2017-06-20  2:12     ` Joel Teichroeb
2017-06-22 17:23       ` Junio C Hamano
2017-06-22 17:07   ` Junio C Hamano
2017-06-11 17:40 ` [PATCH v4 0/5] Implement git stash as a builtin command Joel Teichroeb

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CA+CzEk8QiSu4heMDsx7XC729UEPNm6hdZfs9W5uwoJBvuLWr+w@mail.gmail.com \
    --to=joel@teichroeb.net \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=avarab@gmail.com \
    --cc=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).