From: Charles Bailey Date: Fri, 12 Dec 2008 21:48:41 +0000 (+0000) Subject: mergetool: Don't keep temporary merge files unless told to X-Git-Tag: v1.6.2-rc0~201^2 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=162eba8b43a0e665c8e3439191981412815cc6db;p=git.git 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 Signed-off-by: Junio C Hamano --- diff --git a/Documentation/config.txt b/Documentation/config.txt index bc5642d60..3d5a8df0c 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -976,6 +976,13 @@ mergetool.keepBackup:: is set to `false` then this file is not preserved. Defaults to `true` (i.e. keep the backup files). +mergetool.keepTemporaries:: + When invoking a custom merge tool, git uses a set of temporary + files to pass to the tool. If the tool returns an error and this + variable is set to `true`, then these temporary files will be + preserved, otherwise they will be removed after the tool has + exited. Defaults to `false`. + mergetool.prompt:: Prompt before each invocation of the merge resolution program. diff --git a/git-mergetool.sh b/git-mergetool.sh index 514497164..f04240dac 100755 --- a/git-mergetool.sh +++ b/git-mergetool.sh @@ -269,6 +269,11 @@ merge_file () { if test "$status" -ne 0; then echo "merge of $MERGED failed" 1>&2 mv -- "$BACKUP" "$MERGED" + + if test "$merge_keep_temporaries" = "false"; then + cleanup_temp_files + fi + return 1 fi @@ -415,6 +420,7 @@ else init_merge_tool_path "$merge_tool" merge_keep_backup="$(git config --bool merge.keepBackup || echo true)" + merge_keep_temporaries="$(git config --bool mergetool.keepTemporaries || echo false)" if test -z "$merge_tool_cmd" && ! type "$merge_tool_path" > /dev/null 2>&1; then echo "The merge tool $merge_tool is not available as '$merge_tool_path'"