зеркало из https://github.com/microsoft/git.git
Tidy up git mergetool's backup file behaviour
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>
This commit is contained in:
Родитель
79b1138e78
Коммит
44c36d1ccc
|
@ -777,6 +777,12 @@ mergetool.<tool>.path::
|
||||||
Override the path for the given tool. This is useful in case
|
Override the path for the given tool. This is useful in case
|
||||||
your tool is not in the PATH.
|
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::
|
pack.window::
|
||||||
The size of the window used by linkgit:git-pack-objects[1] when no
|
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.
|
window size is given on the command line. Defaults to 10.
|
||||||
|
|
|
@ -127,18 +127,6 @@ check_unchanged () {
|
||||||
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 () {
|
merge_file () {
|
||||||
path="$1"
|
path="$1"
|
||||||
|
|
||||||
|
@ -201,7 +189,6 @@ merge_file () {
|
||||||
-o "$path" -- "$LOCAL" "$REMOTE" > /dev/null 2>&1)
|
-o "$path" -- "$LOCAL" "$REMOTE" > /dev/null 2>&1)
|
||||||
fi
|
fi
|
||||||
status=$?
|
status=$?
|
||||||
remove_backup
|
|
||||||
;;
|
;;
|
||||||
tkdiff)
|
tkdiff)
|
||||||
if base_present ; then
|
if base_present ; then
|
||||||
|
@ -210,19 +197,16 @@ merge_file () {
|
||||||
"$merge_tool_path" -o "$path" -- "$LOCAL" "$REMOTE"
|
"$merge_tool_path" -o "$path" -- "$LOCAL" "$REMOTE"
|
||||||
fi
|
fi
|
||||||
status=$?
|
status=$?
|
||||||
save_backup
|
|
||||||
;;
|
;;
|
||||||
meld|vimdiff)
|
meld|vimdiff)
|
||||||
touch "$BACKUP"
|
touch "$BACKUP"
|
||||||
"$merge_tool_path" -- "$LOCAL" "$path" "$REMOTE"
|
"$merge_tool_path" -- "$LOCAL" "$path" "$REMOTE"
|
||||||
check_unchanged
|
check_unchanged
|
||||||
save_backup
|
|
||||||
;;
|
;;
|
||||||
gvimdiff)
|
gvimdiff)
|
||||||
touch "$BACKUP"
|
touch "$BACKUP"
|
||||||
"$merge_tool_path" -f -- "$LOCAL" "$path" "$REMOTE"
|
"$merge_tool_path" -f -- "$LOCAL" "$path" "$REMOTE"
|
||||||
check_unchanged
|
check_unchanged
|
||||||
save_backup
|
|
||||||
;;
|
;;
|
||||||
xxdiff)
|
xxdiff)
|
||||||
touch "$BACKUP"
|
touch "$BACKUP"
|
||||||
|
@ -240,7 +224,6 @@ merge_file () {
|
||||||
--merged-file "$path" -- "$LOCAL" "$REMOTE"
|
--merged-file "$path" -- "$LOCAL" "$REMOTE"
|
||||||
fi
|
fi
|
||||||
check_unchanged
|
check_unchanged
|
||||||
save_backup
|
|
||||||
;;
|
;;
|
||||||
opendiff)
|
opendiff)
|
||||||
touch "$BACKUP"
|
touch "$BACKUP"
|
||||||
|
@ -250,7 +233,6 @@ merge_file () {
|
||||||
"$merge_tool_path" "$LOCAL" "$REMOTE" -merge "$path" | cat
|
"$merge_tool_path" "$LOCAL" "$REMOTE" -merge "$path" | cat
|
||||||
fi
|
fi
|
||||||
check_unchanged
|
check_unchanged
|
||||||
save_backup
|
|
||||||
;;
|
;;
|
||||||
ecmerge)
|
ecmerge)
|
||||||
touch "$BACKUP"
|
touch "$BACKUP"
|
||||||
|
@ -260,7 +242,6 @@ merge_file () {
|
||||||
"$merge_tool_path" "$LOCAL" "$REMOTE" --mode=merge2 --to="$path"
|
"$merge_tool_path" "$LOCAL" "$REMOTE" --mode=merge2 --to="$path"
|
||||||
fi
|
fi
|
||||||
check_unchanged
|
check_unchanged
|
||||||
save_backup
|
|
||||||
;;
|
;;
|
||||||
emerge)
|
emerge)
|
||||||
if base_present ; then
|
if base_present ; then
|
||||||
|
@ -269,7 +250,6 @@ merge_file () {
|
||||||
"$merge_tool_path" -f emerge-files-command "$LOCAL" "$REMOTE" "$(basename "$path")"
|
"$merge_tool_path" -f emerge-files-command "$LOCAL" "$REMOTE" "$(basename "$path")"
|
||||||
fi
|
fi
|
||||||
status=$?
|
status=$?
|
||||||
save_backup
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
if test "$status" -ne 0; then
|
if test "$status" -ne 0; then
|
||||||
|
@ -277,6 +257,13 @@ merge_file () {
|
||||||
mv -- "$BACKUP" "$path"
|
mv -- "$BACKUP" "$path"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if test "$merge_keep_backup" = "true"; then
|
||||||
|
mv -- "$BACKUP" "$path.orig"
|
||||||
|
else
|
||||||
|
rm -- "$BACKUP"
|
||||||
|
fi
|
||||||
|
|
||||||
git add -- "$path"
|
git add -- "$path"
|
||||||
cleanup_temp_files
|
cleanup_temp_files
|
||||||
}
|
}
|
||||||
|
@ -380,6 +367,8 @@ else
|
||||||
|
|
||||||
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
|
if ! type "$merge_tool_path" > /dev/null 2>&1; then
|
||||||
echo "The merge tool $merge_tool is not available as '$merge_tool_path'"
|
echo "The merge tool $merge_tool is not available as '$merge_tool_path'"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
Загрузка…
Ссылка в новой задаче