git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jon Seymour <jon.seymour@gmail.com>
To: git@vger.kernel.org
Cc: tla@land.ru, tom@dbservice.com, gitster@pobox.com,
	Jon Seymour <jon.seymour@gmail.com>
Subject: [PATCH 2/2] stash: fix git stash branch regression when branch creation fails
Date: Tue, 28 Sep 2010 23:19:52 +1000	[thread overview]
Message-ID: <1285679992-7638-3-git-send-email-jon.seymour@gmail.com> (raw)
In-Reply-To: <1285673120-43354-1-git-send-email-tom@dbservice.com>

Tomas Carnecky reported a regression in the behaviour
of git stash branch, when the branch creation fails.

This patch fixes that regression by restoring the
pre-condition for dropping that previously existed.

This patch assumes Tomas Carnecky's patch has already been applied.

Signed-off-by: Jon Seymour <jon.seymour@gmail.com>
---
 git-stash.sh     |    6 +++---
 t/t3903-stash.sh |    2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/git-stash.sh b/git-stash.sh
index 23a9ab5..5fb1245 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -432,9 +432,9 @@ apply_to_branch () {
 	assert_stash_like "$@"
 
 	git checkout -b $branch $REV^ &&
-	apply_stash "$@"
-
-	test -z "$IS_STASH_REF" || drop_stash "$@"
+	apply_stash "$@" && {
+		test -z "$IS_STASH_REF" || drop_stash "$@"
+	}
 }
 
 PARSE_CACHE='--not-parsed'
diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh
index 0f6b2e4..336e244 100755
--- a/t/t3903-stash.sh
+++ b/t/t3903-stash.sh
@@ -545,7 +545,7 @@ test_expect_success 'invalid ref of the form stash@{n}, n >= N' '
 	git stash drop
 '
 
-test_expect_failure 'stash branch should not drop the stash if the branch exists' '
+test_expect_success 'stash branch should not drop the stash if the branch exists' '
 	git stash clear &&
 	echo foo > file &&
 	git add file &&
-- 
1.7.3.4.g787b.dirty

      parent reply	other threads:[~2010-09-28 13:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-28 11:25 [PATCH] stash drops the stash even if creating the branch fails because it already exists Tomas Carnecky
2010-09-28 13:19 ` [PATCH 0/2] stash: test and fix git stash branch regression Jon Seymour
2010-09-28 13:19 ` [PATCH 1/2] stash drops the stash even if creating the branch fails because it already exists Jon Seymour
2010-09-28 13:21   ` Tomas Carnecky
2010-09-29 13:53     ` Jon Seymour
2010-09-28 13:19 ` Jon Seymour [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=1285679992-7638-3-git-send-email-jon.seymour@gmail.com \
    --to=jon.seymour@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=tla@land.ru \
    --cc=tom@dbservice.com \
    /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).