{"thread":{"id":"25271","subject":"[PATCH] stash drops the stash even if creating the branch fails because it already exists","startedAt":"2010-09-28T11:25:20Z","lastAt":"2010-09-29T13:53:32Z","messageCount":6,"participants":["Tomas Carnecky","Jon Seymour"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"151898","messageId":"1285673120-43354-1-git-send-email-tom@dbservice.com","threadId":"25271","inReplyTo":null,"subject":"[PATCH] stash drops the stash even if creating the branch fails because it already exists","fromName":"Tomas Carnecky","fromEmail":"tom@dbservice.com","sentAt":"2010-09-28T11:25:20Z","receivedAt":"2010-09-28T11:25:20Z","isPatch":true,"sender":{"key":"tom@dbservice.com","avatar":"https://gravatar.com/avatar/900a300bdd1a8bbe086008ad78210bbee2ad2803b7d50a5cba04c1e9404bd6d2?d=mp&s=160"},"body":"This bug was disovered by someone on IRC when he tried to 'git stash branch <branch> <stash>'\nwhile <branch> already existed. In that case the stash is dropped even though it isn't\napplied on any branch, so the stash is effectively lost. I think that shouldn't happen,\nso here is a test.\n\n---\n t/t3903-stash.sh |   11 +++++++++++\n 1 files changed, 11 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t3903-stash.sh b/t/t3903-stash.sh\nindex 9ed2396..0f6b2e4 100755\n--- a/t/t3903-stash.sh\n+++ b/t/t3903-stash.sh\n@@ -545,4 +545,15 @@ test_expect_success 'invalid ref of the form stash@{n}, n >= N' '\n \tgit stash drop\n '\n \n+test_expect_failure 'stash branch should not drop the stash if the branch exists' '\n+\tgit stash clear &&\n+\techo foo > file &&\n+\tgit add file &&\n+\tgit commit -m initial &&\n+\techo bar > file &&\n+\tgit stash &&\n+\ttest_must_fail git stash branch master stash@{0} &&\n+\tgit rev-parse stash@{0} --\n+'\n+\n test_done\n-- \n1.7.3.3.gd2416\n"},{"id":"151907","messageId":"1285679992-7638-1-git-send-email-jon.seymour@gmail.com","threadId":"25271","inReplyTo":"1285673120-43354-1-git-send-email-tom@dbservice.com","subject":"[PATCH 0/2] stash: test and fix git stash branch regression","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2010-09-28T13:19:50Z","receivedAt":"2010-09-28T13:19:50Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"This series fixes another (sorry!) regression I introduced with my detached-stash series.\n\nI have included Tomas' test, so that my tweak to the test script applies cleanly.\n\nJon Seymour (1):\n  stash: fix git stash branch regression when branch creation fails\n\nTomas Carnecky (1):\n  stash drops the stash even if creating the branch fails because it\n    already exists\n\n git-stash.sh     |    6 +++---\n t/t3903-stash.sh |   11 +++++++++++\n 2 files changed, 14 insertions(+), 3 deletions(-)\n\n-- \n1.7.3.4.g787b.dirty\n"},{"id":"151908","messageId":"1285679992-7638-2-git-send-email-jon.seymour@gmail.com","threadId":"25271","inReplyTo":"1285673120-43354-1-git-send-email-tom@dbservice.com","subject":"[PATCH 1/2] stash drops the stash even if creating the branch fails because it already exists","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2010-09-28T13:19:51Z","receivedAt":"2010-09-28T13:19:51Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"From: Tomas Carnecky <tom@dbservice.com>\n\nThis bug was disovered by someone on IRC when he tried to 'git stash branch <branch> <stash>'\nwhile <branch> already existed. In that case the stash is dropped even though it isn't\napplied on any branch, so the stash is effectively lost. I think that shouldn't happen,\nso here is a test.\n---\n t/t3903-stash.sh |   11 +++++++++++\n 1 files changed, 11 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t3903-stash.sh b/t/t3903-stash.sh\nindex 9ed2396..0f6b2e4 100755\n--- a/t/t3903-stash.sh\n+++ b/t/t3903-stash.sh\n@@ -545,4 +545,15 @@ test_expect_success 'invalid ref of the form stash@{n}, n >= N' '\n \tgit stash drop\n '\n \n+test_expect_failure 'stash branch should not drop the stash if the branch exists' '\n+\tgit stash clear &&\n+\techo foo > file &&\n+\tgit add file &&\n+\tgit commit -m initial &&\n+\techo bar > file &&\n+\tgit stash &&\n+\ttest_must_fail git stash branch master stash@{0} &&\n+\tgit rev-parse stash@{0} --\n+'\n+\n test_done\n-- \n1.7.3.4.g787b.dirty\n"},{"id":"151909","messageId":"1285679992-7638-3-git-send-email-jon.seymour@gmail.com","threadId":"25271","inReplyTo":"1285673120-43354-1-git-send-email-tom@dbservice.com","subject":"[PATCH 2/2] stash: fix git stash branch regression when branch creation fails","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2010-09-28T13:19:52Z","receivedAt":"2010-09-28T13:19:52Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"Tomas Carnecky reported a regression in the behaviour\nof git stash branch, when the branch creation fails.\n\nThis patch fixes that regression by restoring the\npre-condition for dropping that previously existed.\n\nThis patch assumes Tomas Carnecky's patch has already been applied.\n\nSigned-off-by: Jon Seymour <jon.seymour@gmail.com>\n---\n git-stash.sh     |    6 +++---\n t/t3903-stash.sh |    2 +-\n 2 files changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/git-stash.sh b/git-stash.sh\nindex 23a9ab5..5fb1245 100755\n--- a/git-stash.sh\n+++ b/git-stash.sh\n@@ -432,9 +432,9 @@ apply_to_branch () {\n \tassert_stash_like \"$@\"\n \n \tgit checkout -b $branch $REV^ &&\n-\tapply_stash \"$@\"\n-\n-\ttest -z \"$IS_STASH_REF\" || drop_stash \"$@\"\n+\tapply_stash \"$@\" && {\n+\t\ttest -z \"$IS_STASH_REF\" || drop_stash \"$@\"\n+\t}\n }\n \n PARSE_CACHE='--not-parsed'\ndiff --git a/t/t3903-stash.sh b/t/t3903-stash.sh\nindex 0f6b2e4..336e244 100755\n--- a/t/t3903-stash.sh\n+++ b/t/t3903-stash.sh\n@@ -545,7 +545,7 @@ test_expect_success 'invalid ref of the form stash@{n}, n >= N' '\n \tgit stash drop\n '\n \n-test_expect_failure 'stash branch should not drop the stash if the branch exists' '\n+test_expect_success 'stash branch should not drop the stash if the branch exists' '\n \tgit stash clear &&\n \techo foo > file &&\n \tgit add file &&\n-- \n1.7.3.4.g787b.dirty\n"},{"id":"151910","messageId":"4CA1EBF3.7090701@dbservice.com","threadId":"25271","inReplyTo":"1285679992-7638-2-git-send-email-jon.seymour@gmail.com","subject":"Re: [PATCH 1/2] stash drops the stash even if creating the branch fails because it already exists","fromName":"Tomas Carnecky","fromEmail":"tom@dbservice.com","sentAt":"2010-09-28T13:21:55Z","receivedAt":"2010-09-28T13:21:55Z","isPatch":true,"sender":{"key":"tom@dbservice.com","avatar":"https://gravatar.com/avatar/900a300bdd1a8bbe086008ad78210bbee2ad2803b7d50a5cba04c1e9404bd6d2?d=mp&s=160"},"body":"On 9/28/10 3:19 PM, Jon Seymour wrote:\n> From: Tomas Carnecky <tom@dbservice.com>\n> \n> This bug was disovered by someone on IRC when he tried to 'git stash branch <branch> <stash>'\n> while <branch> already existed. In that case the stash is dropped even though it isn't\n> applied on any branch, so the stash is effectively lost. I think that shouldn't happen,\n> so here is a test.\n\nThis line was missing from my original patch, sorry about that:\nSigned-off-by: Tomas Carnecky <tom@dbservice.com>\n\n> ---\n>  t/t3903-stash.sh |   11 +++++++++++\n>  1 files changed, 11 insertions(+), 0 deletions(-)\n> \n> diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh\n> index 9ed2396..0f6b2e4 100755\n> --- a/t/t3903-stash.sh\n> +++ b/t/t3903-stash.sh\n> @@ -545,4 +545,15 @@ test_expect_success 'invalid ref of the form stash@{n}, n >= N' '\n>  \tgit stash drop\n>  '\n>  \n> +test_expect_failure 'stash branch should not drop the stash if the branch exists' '\n> +\tgit stash clear &&\n> +\techo foo > file &&\n> +\tgit add file &&\n> +\tgit commit -m initial &&\n> +\techo bar > file &&\n> +\tgit stash &&\n> +\ttest_must_fail git stash branch master stash@{0} &&\n> +\tgit rev-parse stash@{0} --\n> +'\n> +\n>  test_done\n"},{"id":"152057","messageId":"AANLkTim4f75meriCZpvi58WspVTf0LEVQSYh2dxppYB9@mail.gmail.com","threadId":"25271","inReplyTo":"4CA1EBF3.7090701@dbservice.com","subject":"Re: [PATCH 1/2] stash drops the stash even if creating the branch fails because it already exists","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2010-09-29T13:53:32Z","receivedAt":"2010-09-29T13:53:32Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"Junio,\n\nLet me know if you want me to re-roll this series with Tomas'\nsign-off. I can also add my simplification of the Brian's fix and\nanother fix I have made to have git stash save/create fail early in\ncase the index contains merge conflicts.\n\njon.\n\nOn Tue, Sep 28, 2010 at 11:21 PM, Tomas Carnecky <tom@dbservice.com> wrote:\n> On 9/28/10 3:19 PM, Jon Seymour wrote:\n>> From: Tomas Carnecky <tom@dbservice.com>\n>>\n>> This bug was disovered by someone on IRC when he tried to 'git stash branch <branch> <stash>'\n>> while <branch> already existed. In that case the stash is dropped even though it isn't\n>> applied on any branch, so the stash is effectively lost. I think that shouldn't happen,\n>> so here is a test.\n>\n> This line was missing from my original patch, sorry about that:\n> Signed-off-by: Tomas Carnecky <tom@dbservice.com>\n>\n>> ---\n>>  t/t3903-stash.sh |   11 +++++++++++\n>>  1 files changed, 11 insertions(+), 0 deletions(-)\n>>\n>> diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh\n>> index 9ed2396..0f6b2e4 100755\n>> --- a/t/t3903-stash.sh\n>> +++ b/t/t3903-stash.sh\n>> @@ -545,4 +545,15 @@ test_expect_success 'invalid ref of the form stash@{n}, n >= N' '\n>>       git stash drop\n>>  '\n>>\n>> +test_expect_failure 'stash branch should not drop the stash if the branch exists' '\n>> +     git stash clear &&\n>> +     echo foo > file &&\n>> +     git add file &&\n>> +     git commit -m initial &&\n>> +     echo bar > file &&\n>> +     git stash &&\n>> +     test_must_fail git stash branch master stash@{0} &&\n>> +     git rev-parse stash@{0} --\n>> +'\n>> +\n>>  test_done\n>\n>\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n>\n"}]}