summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 79b1138)
raw | patch | inline | side by side (parent: 79b1138)
author | Charles Bailey <charles@hashpling.org> | |
Thu, 21 Feb 2008 23:30:02 +0000 (23:30 +0000) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 5 Mar 2008 20:07:03 +0000 (12:07 -0800) |
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@hashpling.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
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@hashpling.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/config.txt | patch | blob | history | |
git-mergetool.sh | patch | blob | history |
index 4027726f2ee66ebad69412a5c8c6d1aef7f7463f..514169066db4504212afc062fb9a6723b183e07c 100644 (file)
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
Override the path for the given tool. This is useful in case
your tool is not in the 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.
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 cbbb707959cc64427f7bbd7bfefb0a8f0f263596..9e6c4065fc56cad3db40a14e0a69414a256c0c03 100755 (executable)
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
fi
}
fi
}
-save_backup () {
- if test "$status" -eq 0; then
- mv -- "$BACKUP" "$path.orig"
- fi
-}
-
-remove_backup () {
- if test "$status" -eq 0; then
- rm "$BACKUP"
- fi
-}
-
merge_file () {
path="$1"
merge_file () {
path="$1"
-o "$path" -- "$LOCAL" "$REMOTE" > /dev/null 2>&1)
fi
status=$?
-o "$path" -- "$LOCAL" "$REMOTE" > /dev/null 2>&1)
fi
status=$?
- remove_backup
;;
tkdiff)
if base_present ; then
;;
tkdiff)
if base_present ; then
"$merge_tool_path" -o "$path" -- "$LOCAL" "$REMOTE"
fi
status=$?
"$merge_tool_path" -o "$path" -- "$LOCAL" "$REMOTE"
fi
status=$?
- save_backup
;;
meld|vimdiff)
touch "$BACKUP"
"$merge_tool_path" -- "$LOCAL" "$path" "$REMOTE"
check_unchanged
;;
meld|vimdiff)
touch "$BACKUP"
"$merge_tool_path" -- "$LOCAL" "$path" "$REMOTE"
check_unchanged
- save_backup
;;
gvimdiff)
;;
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
xxdiff)
touch "$BACKUP"
if base_present ; then
--merged-file "$path" -- "$LOCAL" "$REMOTE"
fi
check_unchanged
--merged-file "$path" -- "$LOCAL" "$REMOTE"
fi
check_unchanged
- save_backup
;;
opendiff)
touch "$BACKUP"
;;
opendiff)
touch "$BACKUP"
"$merge_tool_path" "$LOCAL" "$REMOTE" -merge "$path" | cat
fi
check_unchanged
"$merge_tool_path" "$LOCAL" "$REMOTE" -merge "$path" | cat
fi
check_unchanged
- save_backup
;;
ecmerge)
touch "$BACKUP"
;;
ecmerge)
touch "$BACKUP"
"$merge_tool_path" "$LOCAL" "$REMOTE" --mode=merge2 --to="$path"
fi
check_unchanged
"$merge_tool_path" "$LOCAL" "$REMOTE" --mode=merge2 --to="$path"
fi
check_unchanged
- save_backup
;;
emerge)
if base_present ; then
;;
emerge)
if base_present ; then
"$merge_tool_path" -f emerge-files-command "$LOCAL" "$REMOTE" "$(basename "$path")"
fi
status=$?
"$merge_tool_path" -f emerge-files-command "$LOCAL" "$REMOTE" "$(basename "$path")"
fi
status=$?
- save_backup
;;
esac
if test "$status" -ne 0; then
;;
esac
if test "$status" -ne 0; then
mv -- "$BACKUP" "$path"
exit 1
fi
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
}
git add -- "$path"
cleanup_temp_files
}
init_merge_tool_path "$merge_tool"
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
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