From: Charles Bailey <charles@hashpling.org>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Jeff King <peff@peff.net>,
Andreas Ericsson <ae@op5.se>, "Theodore Ts'o" <tytso@mit.edu>,
William Pursell <bill.pursell@gmail.com>
Subject: [PATCH 2/2] mergetool: Don't keep temporary merge files unless told to
Date: Fri, 12 Dec 2008 21:48:41 +0000 [thread overview]
Message-ID: <1229118521-22923-3-git-send-email-charles@hashpling.org> (raw)
In-Reply-To: <1229118521-22923-2-git-send-email-charles@hashpling.org>
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>
---
Documentation/config.txt | 7 +++++++
git-mergetool.sh | 6 ++++++
2 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index bc5642d..3d5a8df 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 5144971..f04240d 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'"
--
1.6.1.rc1.342.g83b24d
next prev parent reply other threads:[~2008-12-12 21:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-12 21:48 Updates to the previous mergetool patches Charles Bailey
2008-12-12 21:48 ` [PATCH 1/2] mergetool: Add prompt to continue after failing to merge a file Charles Bailey
2008-12-12 21:48 ` Charles Bailey [this message]
2008-12-12 22:11 ` [PATCH 2/2] mergetool: Don't keep temporary merge files unless told to Jakub Narebski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1229118521-22923-3-git-send-email-charles@hashpling.org \
--to=charles@hashpling.org \
--cc=ae@op5.se \
--cc=bill.pursell@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=peff@peff.net \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).