Currently a backup pre-merge file with conflict markers is sometimes kept with a .orig extenstion and sometimes removed depending on the particular merge tool used. This patch makes the handling consistent across all merge tools and configurable via a new mergetool.keepBackup config variable Signed-off-by: Charles Bailey <charles@xxxxxxxxxxxxx> --- I'm resending this series with result of all the previous contents integrated. This is, though, still the 'eval' version of the patch simply because it is significantly easier to implement and is not significantly worse than any of the other suggested implementations in any particular way. Documentation/config.txt | 6 ++++++ git-mergetool.sh | 25 +++++++++++++------------ 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/Documentation/config.txt b/Documentation/config.txt index 7b67671..4e17fd2 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -769,6 +769,12 @@ mergetool.<tool>.path:: Override the path for the given tool. This is useful in case your tool is not in the PATH. +mergetool.keepBackup:: + After performing a merge, the original file with conflict markers + can be saved as a file with a `.orig` extension. If this variable + is set to `false` then this file is not preserved. Defaults to + `true` (i.e. keep the backup files). + pack.window:: The size of the window used by linkgit:git-pack-objects[1] when no window size is given on the command line. Defaults to 10. diff --git a/git-mergetool.sh b/git-mergetool.sh index cbbb707..e27bb7b 100755 --- a/git-mergetool.sh +++ b/git-mergetool.sh @@ -201,7 +201,6 @@ merge_file () { -o "$path" -- "$LOCAL" "$REMOTE" > /dev/null 2>&1) fi status=$? - remove_backup ;; tkdiff) if base_present ; then @@ -210,20 +209,17 @@ merge_file () { "$merge_tool_path" -o "$path" -- "$LOCAL" "$REMOTE" fi status=$? - save_backup ;; meld|vimdiff) touch "$BACKUP" "$merge_tool_path" -- "$LOCAL" "$path" "$REMOTE" check_unchanged - save_backup ;; gvimdiff) - touch "$BACKUP" - "$merge_tool_path" -f -- "$LOCAL" "$path" "$REMOTE" - check_unchanged - save_backup - ;; + touch "$BACKUP" + "$merge_tool_path" -f -- "$LOCAL" "$path" "$REMOTE" + check_unchanged + ;; xxdiff) touch "$BACKUP" if base_present ; then @@ -240,7 +236,6 @@ merge_file () { --merged-file "$path" -- "$LOCAL" "$REMOTE" fi check_unchanged - save_backup ;; opendiff) touch "$BACKUP" @@ -250,7 +245,6 @@ merge_file () { "$merge_tool_path" "$LOCAL" "$REMOTE" -merge "$path" | cat fi check_unchanged - save_backup ;; ecmerge) touch "$BACKUP" @@ -260,7 +254,6 @@ merge_file () { "$merge_tool_path" "$LOCAL" "$REMOTE" --mode=merge2 --to="$path" fi check_unchanged - save_backup ;; emerge) if base_present ; then @@ -269,7 +262,6 @@ merge_file () { "$merge_tool_path" -f emerge-files-command "$LOCAL" "$REMOTE" "$(basename "$path")" fi status=$? - save_backup ;; esac if test "$status" -ne 0; then @@ -277,6 +269,13 @@ merge_file () { mv -- "$BACKUP" "$path" exit 1 fi + + if test "$merge_keep_backup" = "true"; then + mv -- "$BACKUP" "$path.orig" + else + rm -- "$BACKUP" + fi + git add -- "$path" cleanup_temp_files } @@ -380,6 +379,8 @@ else init_merge_tool_path "$merge_tool" + merge_keep_backup="$(git config --bool merge.keepBackup || echo true)" + if ! type "$merge_tool_path" > /dev/null 2>&1; then echo "The merge tool $merge_tool is not available as '$merge_tool_path'" exit 1 -- 1.5.4.2.133.g3d51e -- Charles Bailey http://ccgi.hashpling.plus.com/blog/ - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html