Merge branch 'da/mergetool-temporary-filename'
authorJunio C Hamano <gitster@pobox.com>
Tue, 21 Oct 2014 20:28:19 +0000 (13:28 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 21 Oct 2014 20:28:20 +0000 (13:28 -0700)
Tweak the names of the three throw-away files "git mergetool" comes
up with to feed the merge tool backend, so that a file with a
single dot in its name in the original (e.g. "hello.c") will have
only one dot in these variants (e.g. "hello_BASE_4321.c").

* da/mergetool-temporary-filename:
mergetool: use more conservative temporary filenames

git-mergetool.sh
index 9a046b75d1dd810202d784d3fffe8afe6dd1963c..96a61ba6f470d7634552a42547de57f63fae8d81 100755 (executable)
@@ -228,11 +228,17 @@ merge_file () {
                return 1
        fi
 
-       ext="$$$(expr "$MERGED" : '.*\(\.[^/]*\)$')"
-       BACKUP="./$MERGED.BACKUP.$ext"
-       LOCAL="./$MERGED.LOCAL.$ext"
-       REMOTE="./$MERGED.REMOTE.$ext"
-       BASE="./$MERGED.BASE.$ext"
+       if BASE=$(expr "$MERGED" : '\(.*\)\.[^/]*$')
+       then
+               ext=$(expr "$MERGED" : '.*\(\.[^/]*\)$')
+       else
+               BASE=$MERGED
+               ext=
+       fi
+       BACKUP="./${BASE}_BACKUP_$$$ext"
+       LOCAL="./${BASE}_LOCAL_$$$ext"
+       REMOTE="./${BASE}_REMOTE_$$$ext"
+       BASE="./${BASE}_BASE_$$$ext"
 
        base_mode=$(git ls-files -u -- "$MERGED" | awk '{if ($3==1) print $1;}')
        local_mode=$(git ls-files -u -- "$MERGED" | awk '{if ($3==2) print $1;}')