From 9c66cd3bd0a70b2cf56589a4df2cf63814270635 Mon Sep 17 00:00:00 2001 From: David Aguilar Date: Fri, 10 Oct 2014 01:19:47 -0700 Subject: 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 Helped-by: Junio C Hamano Signed-off-by: David Aguilar Signed-off-by: Junio C Hamano --- git-mergetool.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'git-mergetool.sh') diff --git a/git-mergetool.sh b/git-mergetool.sh index 332528ff45..0ff6566a0e 100755 --- a/git-mergetool.sh +++ b/git-mergetool.sh @@ -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;}') -- cgit v1.2.1 From 7bfb7c357cd33a9f3a72d65b0df96e054d2a9f06 Mon Sep 17 00:00:00 2001 From: Charles Bailey Date: Sat, 11 Oct 2014 01:39:37 -0700 Subject: mergetool: don't require a work tree for --tool-help Signed-off-by: Charles Bailey Signed-off-by: David Aguilar Signed-off-by: Junio C Hamano --- git-mergetool.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'git-mergetool.sh') diff --git a/git-mergetool.sh b/git-mergetool.sh index 0ff6566a0e..8098d2dc07 100755 --- a/git-mergetool.sh +++ b/git-mergetool.sh @@ -10,11 +10,11 @@ USAGE='[--tool=tool] [--tool-help] [-y|--no-prompt|--prompt] [file to merge] ...' SUBDIRECTORY_OK=Yes +NONGIT_OK=Yes OPTIONS_SPEC= TOOL_MODE=merge . git-sh-setup . git-mergetool--lib -require_work_tree # Returns true if the mode reflects a symlink is_symlink () { @@ -377,6 +377,9 @@ prompt_after_failed_merge () { done } +git_dir_init +require_work_tree + if test -z "$merge_tool" then merge_tool=$(get_merge_tool "$merge_tool") || exit -- cgit v1.2.1 From 4fb4b02d98310f4f859f7d52f57f36d49198be5c Mon Sep 17 00:00:00 2001 From: Charles Bailey Date: Sat, 11 Oct 2014 01:39:38 -0700 Subject: difftool: don't assume that default sh is sane git-difftool used to create a command list script containing $( ... ) and explicitly calls "sh -c" with this list. Instead, allow mergetool --tool-help to take a mode parameter and call mergetool directly to invoke the show_tool_help function. This mode parameter is intented for use solely by difftool. Signed-off-by: Charles Bailey Helped-by: John Keeping Signed-off-by: David Aguilar Signed-off-by: Junio C Hamano --- git-mergetool.sh | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'git-mergetool.sh') diff --git a/git-mergetool.sh b/git-mergetool.sh index 8098d2dc07..821253e368 100755 --- a/git-mergetool.sh +++ b/git-mergetool.sh @@ -326,6 +326,10 @@ prompt=$(git config --bool mergetool.prompt || echo true) while test $# != 0 do case "$1" in + --tool-help=*) + TOOL_MODE=${1#--tool-help=} + show_tool_help + ;; --tool-help) show_tool_help ;; -- cgit v1.2.1