{"thread":{"id":"30969","subject":"[PATCH 0/2] git-stash: clear rerere state on conflict","startedAt":"2012-07-06T16:22:50Z","lastAt":"2012-07-06T16:22:52Z","messageCount":3,"participants":["Phil Hord"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"194729","messageId":"1341591772-26251-1-git-send-email-hordp@cisco.com","threadId":"30969","inReplyTo":null,"subject":"[PATCH 0/2] git-stash: clear rerere state on conflict","fromName":"Phil Hord","fromEmail":"hordp@cisco.com","sentAt":"2012-07-06T16:22:50Z","receivedAt":"2012-07-06T16:22:50Z","isPatch":true,"sender":{"key":"phil.hord@gmail.com","avatar":"https://avatars.githubusercontent.com/u/123908?v=4"},"body":"This patch series adds a failing test and then a fix for the condition\ndiscussed in these threads:\n\nhttp://article.gmane.org/gmane.comp.version-control.git/177224\nhttp://article.gmane.org/gmane.comp.version-control.git/201045\nhttp://article.gmane.org/gmane.comp.version-control.git/200178/match=merge_rr\n\nI previously floated this wrong-headed test after the same problem:\nhttp://article.gmane.org/gmane.comp.version-control.git/177231\n\n[PATCH 1/2] test: mergetool ignores rerere in git-stash\n[PATCH 2/2] Clear rerere status during stash conflict\n"},{"id":"194730","messageId":"1341591772-26251-2-git-send-email-hordp@cisco.com","threadId":"30969","inReplyTo":"1341591772-26251-1-git-send-email-hordp@cisco.com","subject":"[PATCH 1/2] test: mergetool ignores rerere in git-stash","fromName":"Phil Hord","fromEmail":"hordp@cisco.com","sentAt":"2012-07-06T16:22:51Z","receivedAt":"2012-07-06T16:22:51Z","isPatch":true,"sender":{"key":"phil.hord@gmail.com","avatar":"https://avatars.githubusercontent.com/u/123908?v=4"},"body":"Add a failing test to confirm the leftover rerere\nstate files interfere with git-mergetool during a\nconflicted stash apply.\n\nSigned-off-by: Phil Hord <hordp@cisco.com>\n---\n t/t7610-mergetool.sh | 28 ++++++++++++++++++++++++++++\n 1 file changed, 28 insertions(+)\n\ndiff --git a/t/t7610-mergetool.sh b/t/t7610-mergetool.sh\nindex f5e16fc..2796c53 100755\n--- a/t/t7610-mergetool.sh\n+++ b/t/t7610-mergetool.sh\n@@ -55,6 +55,16 @@ test_expect_success 'setup' '\n     git rm file12 &&\n     git commit -m \"branch1 changes\" &&\n \n+    git checkout -b stash1 master &&\n+    echo stash1 change file11 >file11 &&\n+    git add file11 &&\n+    git commit -m \"stash1 changes\" &&\n+\n+    git checkout -b stash2 master &&\n+    echo stash2 change file11 >file11 &&\n+    git add file11 &&\n+    git commit -m \"stash2 changes\" &&\n+\n     git checkout master &&\n     git submodule update -N &&\n     echo master updated >file1 &&\n@@ -193,7 +203,25 @@ test_expect_success 'mergetool skips resolved paths when rerere is active' '\n     git reset --hard\n '\n \n+test_expect_failure 'mergetool ignores rerere in git-stash conflicts'  '\n+    git checkout -b stash3 stash1 &&\n+    git config rerere.enabled true &&\n+    echo \"Conflicting stash content\" >file11 &&\n+    git stash &&\n+    test_must_fail git merge stash2 &&\n+    echo resolved >file11 &&\n+    git add file11 &&\n+    git commit -mResolved-previous-conflict &&\n+    test -e .git/MERGE_RR &&\n+    test_must_fail git stash apply &&\n+    test_must_fail test -e .git/MERGE_RR &&\n+    test -n \"$(git ls-files -u)\" &&\n+    output=\"$(git mergetool --no-prompt)\" &&\n+    test \"$output\" != \"No files need merging\"\n+'\n+\n test_expect_success 'mergetool takes partial path' '\n+    git reset --hard\n     git config rerere.enabled false &&\n     git checkout -b test12 branch1 &&\n     git submodule update -N &&\n-- \n1.7.11.1.213.gb567ea5.dirty\n"},{"id":"194731","messageId":"1341591772-26251-3-git-send-email-hordp@cisco.com","threadId":"30969","inReplyTo":"1341591772-26251-1-git-send-email-hordp@cisco.com","subject":"[PATCH 2/2] Clear rerere status during stash conflict","fromName":"Phil Hord","fromEmail":"hordp@cisco.com","sentAt":"2012-07-06T16:22:52Z","receivedAt":"2012-07-06T16:22:52Z","isPatch":true,"sender":{"key":"phil.hord@gmail.com","avatar":"https://avatars.githubusercontent.com/u/123908?v=4"},"body":"The presence of a GIT_DIR/MERGE_RR file indicates we\nwere resolving a merge which had rerere candidates for\nrecording.  But the file does not get deleted after\nall resolutions are completed.  This is ok for most\ncases because the file will get replaced when the\nnext merge happens.  But stash apply directly uses\na merge backend, which is not supported by rerere.\nThe prior rerere state is left behind (in MERGE_RR)\nrather than being cleaned up or overwritten as it\nwould with a normal merge.\n\nThis then confuses mergetool who thinks a rerere\noperation is in play when it is not.\n\nWhen we encounter a conflicted stash,  ask rerere to\nclean up with 'git rerere clear'.  This is safe to do\nsince we know that rerere is not taking part in this\nconflict resolution, and any previous unresolved rerere\nactivity would have prevented us from attempting the\nstash apply in the first place.\n\nChange the test for this flaw to expect success.\n\nSigned-off-by: Phil Hord <hordp@cisco.com>\nMentored-by: Junio C Hamano <gitster@pobox.com>\n---\n git-stash.sh         | 1 +\n t/t7610-mergetool.sh | 2 +-\n 2 files changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/git-stash.sh b/git-stash.sh\nindex 4e2c7f8..5bd45ef 100755\n--- a/git-stash.sh\n+++ b/git-stash.sh\n@@ -469,6 +469,7 @@ apply_stash () {\n \telse\n \t\t# Merge conflict; keep the exit status from merge-recursive\n \t\tstatus=$?\n+\t\tgit rerere clear\n \t\tif test -n \"$INDEX_OPTION\"\n \t\tthen\n \t\t\tgettextln \"Index was not unstashed.\" >&2\ndiff --git a/t/t7610-mergetool.sh b/t/t7610-mergetool.sh\nindex 2796c53..99e8c1d 100755\n--- a/t/t7610-mergetool.sh\n+++ b/t/t7610-mergetool.sh\n@@ -203,7 +203,7 @@ test_expect_success 'mergetool skips resolved paths when rerere is active' '\n     git reset --hard\n '\n \n-test_expect_failure 'mergetool ignores rerere in git-stash conflicts'  '\n+test_expect_success 'mergetool ignores rerere in git-stash conflicts'  '\n     git checkout -b stash3 stash1 &&\n     git config rerere.enabled true &&\n     echo \"Conflicting stash content\" >file11 &&\n-- \n1.7.11.1.213.gb567ea5.dirty\n"}]}