Skip to content

Commit eab335c

Browse files
davvidgitster
authored andcommitted
mergetool: use more conservative temporary filenames
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]>
1 parent 9e8f8de commit eab335c

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

git-mergetool.sh

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,17 @@ merge_file () {
228228
return 1
229229
fi
230230

231-
ext="$$$(expr "$MERGED" : '.*\(\.[^/]*\)$')"
232-
BACKUP="./$MERGED.BACKUP.$ext"
233-
LOCAL="./$MERGED.LOCAL.$ext"
234-
REMOTE="./$MERGED.REMOTE.$ext"
235-
BASE="./$MERGED.BASE.$ext"
231+
if BASE=$(expr "$MERGED" : '\(.*\)\.[^/]*$')
232+
then
233+
ext=$(expr "$MERGED" : '.*\(\.[^/]*\)$')
234+
else
235+
BASE=$MERGED
236+
ext=
237+
fi
238+
BACKUP="./${BASE}_BACKUP_$$$ext"
239+
LOCAL="./${BASE}_LOCAL_$$$ext"
240+
REMOTE="./${BASE}_REMOTE_$$$ext"
241+
BASE="./${BASE}_BASE_$$$ext"
236242

237243
base_mode=$(git ls-files -u -- "$MERGED" | awk '{if ($3==1) print $1;}')
238244
local_mode=$(git ls-files -u -- "$MERGED" | awk '{if ($3==2) print $1;}')

0 commit comments

Comments
 (0)