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 <sferrero@ensoftcorp.com> Helped-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
David Aguilar committed
Oct 10, 2014 at 01:19 UTC
9c66cd3bd0a70b2cf56589a4df2cf63814270635
1 file changed
+11
-5
git-mergetool.sh
+11
-5
@@ -228,11 +228,17 @@ merge_file () {
228
return 1
229
fi
230
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"
242
243
base_mode=$(git ls-files -u -- "$MERGED" | awk '{if ($3==1) print $1;}')
244
local_mode=$(git ls-files -u -- "$MERGED" | awk '{if ($3==2) print $1;}')