{"thread":{"id":"18000","subject":"[PATCH] mergetool: demonstrate directory / file conflict breakage","startedAt":"2009-02-24T23:01:06Z","lastAt":"2009-02-24T23:05:19Z","messageCount":3,"participants":["Charles Bailey"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"106120","messageId":"1235516466-3930-1-git-send-email-charles@hashpling.org","threadId":"18000","inReplyTo":null,"subject":"[PATCH] mergetool: demonstrate directory / file conflict breakage","fromName":"Charles Bailey","fromEmail":"charles@hashpling.org","sentAt":"2009-02-24T23:01:06Z","receivedAt":"2009-02-24T23:01:06Z","isPatch":true,"sender":{"key":"charles@hashpling.org","avatar":"https://avatars.githubusercontent.com/u/1668475?v=4"},"body":"---\n\nThis appears to demonstrate one of the corner cases that trips mergetool\nup. I also appear to have fixed it in my work-in-progress refactoring of\nmergetool, but I haven't yet completed it or tested it thoroughly enough\nso it's not ready for human consumption.\n\n t/t7610-mergetool.sh |   49 +++++++++++++++++++++++++++++++++++++++++++++++--\n 1 files changed, 47 insertions(+), 2 deletions(-)\n\ndiff --git a/t/t7610-mergetool.sh b/t/t7610-mergetool.sh\nindex e768c3e..df57b83 100755\n--- a/t/t7610-mergetool.sh\n+++ b/t/t7610-mergetool.sh\n@@ -34,6 +34,8 @@ test_expect_success 'setup' '\n     git add file1 file2 subdir/file3 &&\n     git commit -m \"master updates\" &&\n \n+    git branch empty $(echo empty | git commit-tree $(printf \"\" | git mktree)) &&\n+\n     git config merge.tool mytool &&\n     git config mergetool.mytool.cmd \"cat \\\"\\$REMOTE\\\" >\\\"\\$MERGED\\\"\" &&\n     git config mergetool.mytool.trustExitCode true\n@@ -67,13 +69,56 @@ test_expect_success 'mergetool crlf' '\n '\n \n test_expect_success 'mergetool in subdir' '\n-    git checkout -b test3 branch1\n-    cd subdir && (\n+    git checkout -b test3 branch1 &&\n+    ( cd subdir &&\n     test_must_fail git merge master >/dev/null 2>&1 &&\n     ( yes \"\" | git mergetool file3 >/dev/null 2>&1 ) &&\n     test \"$(cat file3)\" = \"master new sub\" )\n '\n \n+# Choosing the 'remote' symlink should work\n+test_expect_success 'mergetool symlink change' '\n+    git clean -f &&\n+    git checkout -f -b symlink-test empty &&\n+    echo file >file1 &&\n+    echo file >linktofile1 &&\n+    git add file1 linktofile1 &&\n+    git commit -m base &&\n+    rm linktofile1 &&\n+    ln -s file1 linktofile1 &&\n+    git commit -a -m \"change file to link\" &&\n+    git checkout -b symlink-test-2 HEAD^ &&\n+    rm linktofile1 &&\n+    printf file1 >linktofile1 &&\n+    git commit -a -m \"file change\" &&\n+    test_must_fail git merge symlink-test >/dev/null 2>&1 &&\n+    ( yes \"r\" | git mergetool linktofile1 >/dev/null 2>&1 ) &&\n+    test -L linktofile1 &&\n+    git commit -m \"symlink resolve\"\n+'\n+\n+# Aborting a conflicted dir -> file merge shouldn't remove the offending\n+# parth altogether\n+test_expect_failure 'abort mergetool directory change' '\n+    git clean -f &&\n+    git checkout -f -b dir-test empty &&\n+    echo file >dir1 &&\n+    git add dir1 &&\n+    git commit -m base &&\n+    rm dir1 &&\n+    mkdir dir1 &&\n+    echo file >dir1/file &&\n+    git add dir1\n+    git commit -a -m \"change file to dir\" &&\n+    git checkout -b dir-test-2 HEAD^ &&\n+    echo not a dir >dir1 &&\n+    git commit -a -m \"file change\" &&\n+    test_must_fail git merge -s resolve dir-test &&\n+    test -e dir1 &&\n+    ( yes \"a\" | test_must_fail git mergetool dir1 >/dev/null 2>&1 ) &&\n+    test -e dir1\n+'\n+\n # We can't merge files from parent directories when running mergetool\n # from a subdir. Is this a bug?\n #\n-- \n1.6.2.rc1.258.g314b8b\n"},{"id":"106121","messageId":"1235516515-3996-1-git-send-email-charles@hashpling.org","threadId":"18000","inReplyTo":"1235516466-3930-1-git-send-email-charles@hashpling.org","subject":"[PATCH] Test refactor","fromName":"Charles Bailey","fromEmail":"charles@hashpling.org","sentAt":"2009-02-24T23:01:55Z","receivedAt":"2009-02-24T23:01:55Z","isPatch":true,"sender":{"key":"charles@hashpling.org","avatar":"https://avatars.githubusercontent.com/u/1668475?v=4"},"body":"---\n git-mergetool.sh |  110 +++++++++++++++++++++++++++++-------------------------\n 1 files changed, 59 insertions(+), 51 deletions(-)\n\ndiff --git a/git-mergetool.sh b/git-mergetool.sh\nindex 87fa88a..9446b8e 100755\n--- a/git-mergetool.sh\n+++ b/git-mergetool.sh\n@@ -99,7 +99,7 @@ resolve_deleted_merge () {\n \t\treturn 0\n \t\t;;\n \t    [dD]*)\n-\t\tgit rm -- \"$MERGED\" > /dev/null\n+\t\tgit rm -q -- \"$MERGED\"\n \t\tcleanup_temp_files\n \t\treturn 0\n \t\t;;\n@@ -134,55 +134,8 @@ checkout_staged_file () {\n     fi\n }\n \n-merge_file () {\n-    MERGED=\"$1\"\n-\n-    f=`git ls-files -u -- \"$MERGED\"`\n-    if test -z \"$f\" ; then\n-\tif test ! -f \"$MERGED\" ; then\n-\t    echo \"$MERGED: file not found\"\n-\telse\n-\t    echo \"$MERGED: file does not need merging\"\n-\tfi\n-\treturn 1\n-    fi\n-\n-    ext=\"$$$(expr \"$MERGED\" : '.*\\(\\.[^/]*\\)$')\"\n-    BACKUP=\"./$MERGED.BACKUP.$ext\"\n-    LOCAL=\"./$MERGED.LOCAL.$ext\"\n-    REMOTE=\"./$MERGED.REMOTE.$ext\"\n-    BASE=\"./$MERGED.BASE.$ext\"\n-\n-    mv -- \"$MERGED\" \"$BACKUP\"\n-    cp -- \"$BACKUP\" \"$MERGED\"\n-\n-    base_mode=`git ls-files -u -- \"$MERGED\" | awk '{if ($3==1) print $1;}'`\n-    local_mode=`git ls-files -u -- \"$MERGED\" | awk '{if ($3==2) print $1;}'`\n-    remote_mode=`git ls-files -u -- \"$MERGED\" | awk '{if ($3==3) print $1;}'`\n-\n-    base_present   && checkout_staged_file 1 \"$MERGED\" \"$BASE\"\n-    local_present  && checkout_staged_file 2 \"$MERGED\" \"$LOCAL\"\n-    remote_present && checkout_staged_file 3 \"$MERGED\" \"$REMOTE\"\n+resolve_normal_merge () {\n \n-    if test -z \"$local_mode\" -o -z \"$remote_mode\"; then\n-\techo \"Deleted merge conflict for '$MERGED':\"\n-\tdescribe_file \"$local_mode\" \"local\" \"$LOCAL\"\n-\tdescribe_file \"$remote_mode\" \"remote\" \"$REMOTE\"\n-\tresolve_deleted_merge\n-\treturn\n-    fi\n-\n-    if is_symlink \"$local_mode\" || is_symlink \"$remote_mode\"; then\n-\techo \"Symbolic link merge conflict for '$MERGED':\"\n-\tdescribe_file \"$local_mode\" \"local\" \"$LOCAL\"\n-\tdescribe_file \"$remote_mode\" \"remote\" \"$REMOTE\"\n-\tresolve_symlink_merge\n-\treturn\n-    fi\n-\n-    echo \"Normal merge conflict for '$MERGED':\"\n-    describe_file \"$local_mode\" \"local\" \"$LOCAL\"\n-    describe_file \"$remote_mode\" \"remote\" \"$REMOTE\"\n     if \"$prompt\" = true; then\n \tprintf \"Hit return to start merge resolution tool (%s): \" \"$merge_tool\"\n \tread ans\n@@ -278,7 +231,62 @@ merge_file () {\n \t    fi\n \t    ;;\n     esac\n-    if test \"$status\" -ne 0; then\n+\n+    if test $status -eq 0; then\n+\tgit add -- \"$MERGED\"\n+    fi\n+\n+    return $status\n+}\n+\n+merge_file () {\n+    MERGED=\"$1\"\n+\n+    f=`git ls-files -u -- \"$MERGED\"`\n+    if test -z \"$f\" ; then\n+\tif test ! -f \"$MERGED\" ; then\n+\t    echo \"$MERGED: file not found\"\n+\telse\n+\t    echo \"$MERGED: file does not need merging\"\n+\tfi\n+\treturn 1\n+    fi\n+\n+    ext=\"$$$(expr \"$MERGED\" : '.*\\(\\.[^/]*\\)$')\"\n+    BACKUP=\"./$MERGED.BACKUP.$ext\"\n+    LOCAL=\"./$MERGED.LOCAL.$ext\"\n+    REMOTE=\"./$MERGED.REMOTE.$ext\"\n+    BASE=\"./$MERGED.BASE.$ext\"\n+\n+    mv -- \"$MERGED\" \"$BACKUP\"\n+    cp -- \"$BACKUP\" \"$MERGED\"\n+\n+    base_mode=`git ls-files -u -- \"$MERGED\" | awk '{if ($3==1) print $1;}'`\n+    local_mode=`git ls-files -u -- \"$MERGED\" | awk '{if ($3==2) print $1;}'`\n+    remote_mode=`git ls-files -u -- \"$MERGED\" | awk '{if ($3==3) print $1;}'`\n+\n+    base_present   && checkout_staged_file 1 \"$MERGED\" \"$BASE\"\n+    local_present  && checkout_staged_file 2 \"$MERGED\" \"$LOCAL\"\n+    remote_present && checkout_staged_file 3 \"$MERGED\" \"$REMOTE\"\n+\n+    if test -z \"$local_mode\" -o -z \"$remote_mode\"; then\n+\techo \"Deleted merge conflict for '$MERGED':\"\n+\tdescribe_file \"$local_mode\" \"local\" \"$LOCAL\"\n+\tdescribe_file \"$remote_mode\" \"remote\" \"$REMOTE\"\n+\tresolve_deleted_merge\n+    elif is_symlink \"$local_mode\" || is_symlink \"$remote_mode\"; then\n+\techo \"Symbolic link merge conflict for '$MERGED':\"\n+\tdescribe_file \"$local_mode\" \"local\" \"$LOCAL\"\n+\tdescribe_file \"$remote_mode\" \"remote\" \"$REMOTE\"\n+\tresolve_symlink_merge\n+    else\n+\techo \"Normal merge conflict for '$MERGED':\"\n+\tdescribe_file \"$local_mode\" \"local\" \"$LOCAL\"\n+\tdescribe_file \"$remote_mode\" \"remote\" \"$REMOTE\"\n+\tresolve_normal_merge\n+    fi\n+\n+    if test $? -ne 0; then\n \techo \"merge of $MERGED failed\" 1>&2\n \tmv -- \"$BACKUP\" \"$MERGED\"\n \n@@ -295,8 +303,8 @@ merge_file () {\n \trm -- \"$BACKUP\"\n     fi\n \n-    git add -- \"$MERGED\"\n     cleanup_temp_files\n+\n     return 0\n }\n \n-- \n1.6.2.rc1.258.g314b8b\n"},{"id":"106122","messageId":"20090224230519.GA4038@hashpling.org","threadId":"18000","inReplyTo":"1235516515-3996-1-git-send-email-charles@hashpling.org","subject":"Re: [PATCH] Test refactor","fromName":"Charles Bailey","fromEmail":"charles@hashpling.org","sentAt":"2009-02-24T23:05:19Z","receivedAt":"2009-02-24T23:05:19Z","isPatch":true,"sender":{"key":"charles@hashpling.org","avatar":"https://avatars.githubusercontent.com/u/1668475?v=4"},"body":"On Tue, Feb 24, 2009 at 11:01:55PM +0000, Charles Bailey wrote:\n> ---\n>  git-mergetool.sh |  110 +++++++++++++++++++++++++++++-------------------------\n>  1 files changed, 59 insertions(+), 51 deletions(-)\n\nLack of sign-off: deliberate.\nFailure to say 'RFC' and a have a meaningful commit subject: human\nerror.\n\nSorry about that.\n\n-- \nCharles Bailey\nhttp://ccgi.hashpling.plus.com/blog/\n"}]}