Skip to content

Commit

Permalink
mergetool: use more conservative temporary filenames
Browse files Browse the repository at this point in the history
Avoid filenames with multiple dots so that overly-picky tools do
not misinterpret their extension.

Previously, foo/bar.ext in the worktree would result in e.g.

	./foo/bar.ext.BASE.1234.ext

This can be improved by having only a single .ext and using
underscore instead of dot so that the extension cannot be
misinterpreted.  The resulting path becomes:

	./foo/bar_BASE_1234.ext

Suggested-by: Sergio Ferrero <[email protected]>
Helped-by: Junio C Hamano <[email protected]>
Signed-off-by: David Aguilar <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
davvid authored and gitster committed Oct 16, 2014
1 parent 9e8f8de commit eab335c
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions git-mergetool.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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;}')
Expand Down

0 comments on commit eab335c

Please sign in to comment.