{"thread":{"id":"30992","subject":"[PATCH v3 1/2] test: git-stash conflict sets up rerere","startedAt":"2012-07-10T22:52:27Z","lastAt":"2012-08-17T18:01:17Z","messageCount":3,"participants":["Phil Hord","Junio C Hamano"],"isPatch":true,"patchVersion":3,"patchTotal":2},"messages":[{"id":"194887","messageId":"1341960748-26949-1-git-send-email-hordp@cisco.com","threadId":"30992","inReplyTo":null,"subject":"[PATCH v3 1/2] test: git-stash conflict sets up rerere","fromName":"Phil Hord","fromEmail":"hordp@cisco.com","sentAt":"2012-07-10T22:52:27Z","receivedAt":"2012-07-10T22:52:27Z","isPatch":true,"sender":{"key":"phil.hord@gmail.com","avatar":"https://avatars.githubusercontent.com/u/123908?v=4"},"body":"Add a failing test to confirm a conflicted stash apply\ninvokes rerere to record the conflicts and resolve the\nthe files it can.\n\nmergetool may be confused by a left-over\nstate from previous rerere activity causing it to\nthink no files have conflicts even though they do.\nThis condition is not verified by this test since a\nsubsequent commit will change the behavior to enable\nrerere for stash conflicts.\n\nAlso, the next test expected us to finish up with a reset,\nwhich is impossible to do if we fail (as we must) and it's\nan unreasonable expectation anyway.  Begin the next test\nwith a reset of his own instead.\n\nSigned-off-by: Phil Hord <hordp@cisco.com>\n---\n t/t7610-mergetool.sh | 38 ++++++++++++++++++++++++++++++++++++++\n 1 file changed, 38 insertions(+)\n\ndiff --git a/t/t7610-mergetool.sh b/t/t7610-mergetool.sh\nindex f5e16fc..725f316 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,35 @@ test_expect_success 'mergetool skips resolved paths when rerere is active' '\n     git reset --hard\n '\n \n+test_expect_failure 'conflicted stash sets up rerere'  '\n+    git config rerere.enabled true &&\n+    git checkout stash1 &&\n+    echo \"Conflicting stash content\" >file11 &&\n+    git stash &&\n+\n+    git checkout --detach stash2 &&\n+    test_must_fail git stash apply &&\n+\n+    test -n \"$(git ls-files -u)\" &&\n+    conflicts=\"$(git rerere remaining)\" &&\n+    test \"$conflicts\" = \"file11\" &&\n+    output=\"$(git mergetool --no-prompt)\" &&\n+    test \"$output\" != \"No files need merging\" &&\n+\n+    git commit -am \"save the stash resolution\" &&\n+\n+    git reset --hard stash2 &&\n+    test_must_fail git stash apply &&\n+\n+    test -n \"$(git ls-files -u)\" &&\n+    conflicts=\"$(git rerere remaining)\" &&\n+    test -z \"$conflicts\" &&\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":"194888","messageId":"1341960748-26949-2-git-send-email-hordp@cisco.com","threadId":"30992","inReplyTo":"1341960748-26949-1-git-send-email-hordp@cisco.com","subject":"[PATCH v3 2/2] stash: invoke rerere in case of conflict","fromName":"Phil Hord","fromEmail":"hordp@cisco.com","sentAt":"2012-07-10T22:52:28Z","receivedAt":"2012-07-10T22:52:28Z","isPatch":true,"sender":{"key":"phil.hord@gmail.com","avatar":"https://avatars.githubusercontent.com/u/123908?v=4"},"body":"'stash apply' directly calls a backend merge function\nwhich does not automatically invoke rerere.  This\nconfuses mergetool when leftover rerere state is left\nbehind from previous merges.\n\nInvoke rerere explicitly when we encounter a conflict\nduring stash apply\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..bbefdf6 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\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 725f316..6fa0c70 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 'conflicted stash sets up rerere'  '\n+test_expect_success 'conflicted stash sets up rerere'  '\n     git config rerere.enabled true &&\n     git checkout stash1 &&\n     echo \"Conflicting stash content\" >file11 &&\n-- \n1.7.11.1.213.gb567ea5.dirty\n"},{"id":"197201","messageId":"7v393lv1n6.fsf@alter.siamese.dyndns.org","threadId":"30992","inReplyTo":"1341960748-26949-1-git-send-email-hordp@cisco.com","subject":"Re: [PATCH v3 1/2] test: git-stash conflict sets up rerere","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-08-17T18:01:17Z","receivedAt":"2012-08-17T18:01:17Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Phil Hord <hordp@cisco.com> writes:\n\n> Add a failing test to confirm a conflicted stash apply\n> invokes rerere to record the conflicts and resolve the\n> the files it can.\n>\n> mergetool may be confused by a left-over\n> state from previous rerere activity causing it to\n> think no files have conflicts even though they do.\n> This condition is not verified by this test since a\n> subsequent commit will change the behavior to enable\n> rerere for stash conflicts.\n>\n> Also, the next test expected us to finish up with a reset,\n> which is impossible to do if we fail (as we must) and it's\n> an unreasonable expectation anyway.  Begin the next test\n> with a reset of his own instead.\n>\n> Signed-off-by: Phil Hord <hordp@cisco.com>\n> ---\n>  t/t7610-mergetool.sh | 38 ++++++++++++++++++++++++++++++++++++++\n>  1 file changed, 38 insertions(+)\n>\n> diff --git a/t/t7610-mergetool.sh b/t/t7610-mergetool.sh\n> index f5e16fc..725f316 100755\n> --- a/t/t7610-mergetool.sh\n> +++ b/t/t7610-mergetool.sh\n> ...\n>  test_expect_success 'mergetool takes partial path' '\n> +    git reset --hard\n\nI'll add \" &&\" at the end and queue.  Thanks.\n\n>      git config rerere.enabled false &&\n>      git checkout -b test12 branch1 &&\n>      git submodule update -N &&\n"}]}