{"thread":{"id":"6495","subject":"[PATCH] git-checkout -m: fix merge case","startedAt":"2007-01-24T01:42:07Z","lastAt":"2007-01-24T01:42:07Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"32471","messageId":"7vtzyhkxow.fsf@assigned-by-dhcp.cox.net","threadId":"6495","inReplyTo":null,"subject":"[PATCH] git-checkout -m: fix merge case","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-01-24T01:42:07Z","receivedAt":"2007-01-24T01:42:07Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Commit c1a4278e switched the \"merging checkout\" implementation\nfrom 3-way read-tree to merge-recursive, but forgot that\nmerge-recursive will signal an unmerged state with its own exit\nstatus code.  This prevented the clean-up phase (paths cleanly\nmerged should not be updated in the index) from running.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n git-checkout.sh |   15 +++++----------\n t/t7201-co.sh   |   28 +++++++++++++++++++++++++++-\n 2 files changed, 32 insertions(+), 11 deletions(-)\n\ndiff --git a/git-checkout.sh b/git-checkout.sh\nindex e02d4d8..c52f352 100755\n--- a/git-checkout.sh\n+++ b/git-checkout.sh\n@@ -200,17 +200,12 @@ else\n \t# Match the index to the working tree, and do a three-way.\n     \tgit diff-files --name-only | git update-index --remove --stdin &&\n \twork=`git write-tree` &&\n-\tgit read-tree --reset -u $new &&\n-\teval GITHEAD_$new=${new_name:-${branch:-$new}} GITHEAD_$work=local &&\n-\texport GITHEAD_$new GITHEAD_$work &&\n-\tgit merge-recursive $old -- $new $work || exit\n+\tgit read-tree --reset -u $new || exit\n \n-\tif result=`git write-tree 2>/dev/null`\n-\tthen\n-\t    echo >&2 \"Trivially automerged.\"\n-\telse\n-\t    git merge-index -o git-merge-one-file -a\n-\tfi\n+\teval GITHEAD_$new=${new_name:-${branch:-$new}} &&\n+\teval GITHEAD_$work=local &&\n+\texport GITHEAD_$new GITHEAD_$work &&\n+\tgit merge-recursive $old -- $new $work\n \n \t# Do not register the cleanly merged paths in the index yet.\n \t# this is not a real merge before committing, but just carrying\ndiff --git a/t/t7201-co.sh b/t/t7201-co.sh\nindex 315fa35..867bbd2 100755\n--- a/t/t7201-co.sh\n+++ b/t/t7201-co.sh\n@@ -100,7 +100,33 @@ test_expect_success \"checkout -m with dirty tree, renamed\" '\n \tgit checkout -m renamer &&\n \tfill 1 3 4 5 7 8 >expect &&\n \tdiff expect uno &&\n-\t! test -f one\n+\t! test -f one &&\n+\tgit diff --cached >current &&\n+\t! test -s current\n+\n+'\n+\n+test_expect_success 'checkout -m with merge conflict' '\n+\n+\tgit checkout -f master && git clean &&\n+\n+\tfill 1 T 3 4 5 6 S 8 >one &&\n+\tif git checkout renamer\n+\tthen\n+\t\techo Not happy\n+\t\tfalse\n+\telse\n+\t\techo \"happy - failed correctly\"\n+\tfi &&\n+\n+\tgit checkout -m renamer &&\n+\n+\tgit diff master:one :3:uno |\n+\tsed -e \"1,/^@@/d\" -e \"/^ /d\" -e \"s/^-/d/\" -e \"s/^+/a/\" >current &&\n+\tfill d2 aT d7 aS >expect &&\n+\tdiff current expect &&\n+\tgit diff --cached two >current &&\n+\t! test -s current\n '\n \n test_done\n-- \n1.5.0.rc2.gd7eb\n"}]}