mergetool: Don't keep temporary merge files unless told to
This changes git mergetool to remove the temporary files used to invoke the merge tool even if it returns non-zero. This also adds a configuration option (mergetool.keepTemporaries) to retain the previous behaviour if desired. Signed-off-by: Charles Bailey <charles@hashpling.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Charles Bailey committed
Dec 12, 2008 at 21:48 UTC
162eba8b43a0e665c8e3439191981412815cc6db
2 files changed
+13
Documentation/config.txt
+7
@@ -976,6 +976,13 @@ mergetool.keepBackup::
976
is set to `false` then this file is not preserved. Defaults to
977
`true` (i.e. keep the backup files).
978
979
+mergetool.keepTemporaries::
980
+ When invoking a custom merge tool, git uses a set of temporary
981
+ files to pass to the tool. If the tool returns an error and this
982
+ variable is set to `true`, then these temporary files will be
983
+ preserved, otherwise they will be removed after the tool has
984
+ exited. Defaults to `false`.
985
+
986
mergetool.prompt::
987
Prompt before each invocation of the merge resolution program.
988
git-mergetool.sh
+6
@@ -269,6 +269,11 @@ merge_file () {
269
if test "$status" -ne 0; then
270
echo "merge of $MERGED failed" 1>&2
271
mv -- "$BACKUP" "$MERGED"
272
+
273
+ if test "$merge_keep_temporaries" = "false"; then
274
+ cleanup_temp_files
275
+ fi
276
+
277
return 1
278
fi
279
@@ -415,6 +420,7 @@ else
420
init_merge_tool_path "$merge_tool"
421
422
merge_keep_backup="$(git config --bool merge.keepBackup || echo true)"
423
+ merge_keep_temporaries="$(git config --bool mergetool.keepTemporaries || echo false)"
424
425
if test -z "$merge_tool_cmd" && ! type "$merge_tool_path" > /dev/null 2>&1; then
426
echo "The merge tool $merge_tool is not available as '$merge_tool_path'"