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 3/3] Add -k/--keep-going option to mergetool
Date: Thu, 13 Nov 2008 12:41:15 +0000 [thread overview]
Message-ID: <1226580075-29289-4-git-send-email-charles@hashpling.org> (raw)
In-Reply-To: <1226580075-29289-3-git-send-email-charles@hashpling.org>
This option stops git mergetool from aborting at the first failed merge.
This allows some additional use patterns. Merge conflicts can now be
previewed one at time and merges can also be skipped so that they can be
performed in a later pass.
There is also a mergetool.keepGoing configuration variable covering the
same behaviour.
Signed-off-by: Charles Bailey <charles@hashpling.org>
---
Documentation/config.txt | 4 +++
Documentation/git-mergetool.txt | 12 +++++++++-
git-mergetool.sh | 46 ++++++++++++++++++++++++++++++--------
3 files changed, 51 insertions(+), 11 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index c5b211a..0b0bc99 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -976,6 +976,10 @@ mergetool.keepBackup::
is set to `false` then this file is not preserved. Defaults to
`true` (i.e. keep the backup files).
+mergetool.keepGoing::
+ Continue to attempt resolution of remaining conflicted files even
+ after a merge has failed or been aborted.
+
mergetool.prompt::
Prompt before each invocation of the merge resolution program.
diff --git a/Documentation/git-mergetool.txt b/Documentation/git-mergetool.txt
index 176483a..bd2a5ab 100644
--- a/Documentation/git-mergetool.txt
+++ b/Documentation/git-mergetool.txt
@@ -7,7 +7,8 @@ git-mergetool - Run merge conflict resolution tools to resolve merge conflicts
SYNOPSIS
--------
-'git mergetool' [--tool=<tool>] [-y|--no-prompt|--prompt] [<file>]...
+'git mergetool' [--tool=<tool>] [-y|--no-prompt|--prompt]
+ [-k|--keep-going|--no-keep-going] [<file>]...
DESCRIPTION
-----------
@@ -69,6 +70,15 @@ success of the resolution after the custom tool has exited.
This is the default behaviour; the option is provided to
override any configuration settings.
+-k or --keep-going::
+ Continue to attempt resolution of remaining conflicted files
+ even after a merge has failed or been aborted.
+
+--no-keep-going::
+ Abort the conflict resolution attempt if any single conflict
+ resolution fails or is aborted. This is the default behaviour;
+ the option is provided to override any configuration settings.
+
Author
------
Written by Theodore Y Ts'o <tytso@mit.edu>
diff --git a/git-mergetool.sh b/git-mergetool.sh
index 507028f..d60f493 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -8,7 +8,8 @@
# at the discretion of Junio C Hamano.
#
-USAGE='[--tool=tool] [-y|--no-prompt|--prompt] [file to merge] ...'
+USAGE='[--tool=tool] [-y|--no-prompt|--prompt]
+[-k|--keep-going|--no-keep-going] [file to merge] ...'
SUBDIRECTORY_OK=Yes
OPTIONS_SPEC=
. git-sh-setup
@@ -70,16 +71,16 @@ resolve_symlink_merge () {
git checkout-index -f --stage=2 -- "$MERGED"
git add -- "$MERGED"
cleanup_temp_files --save-backup
- return
+ return 0
;;
[rR]*)
git checkout-index -f --stage=3 -- "$MERGED"
git add -- "$MERGED"
cleanup_temp_files --save-backup
- return
+ return 0
;;
[aA]*)
- exit 1
+ return 1
;;
esac
done
@@ -97,15 +98,15 @@ resolve_deleted_merge () {
[mMcC]*)
git add -- "$MERGED"
cleanup_temp_files --save-backup
- return
+ return 0
;;
[dD]*)
git rm -- "$MERGED" > /dev/null
cleanup_temp_files
- return
+ return 0
;;
[aA]*)
- exit 1
+ return 1
;;
esac
done
@@ -137,7 +138,7 @@ merge_file () {
else
echo "$MERGED: file does not need merging"
fi
- exit 1
+ return 1
fi
ext="$$$(expr "$MERGED" : '.*\(\.[^/]*\)$')"
@@ -269,7 +270,8 @@ merge_file () {
if test "$status" -ne 0; then
echo "merge of $MERGED failed" 1>&2
mv -- "$BACKUP" "$MERGED"
- exit 1
+ cleanup_temp_files
+ return 1
fi
if test "$merge_keep_backup" = "true"; then
@@ -280,9 +282,11 @@ merge_file () {
git add -- "$MERGED"
cleanup_temp_files
+ return 0
}
prompt=$(git config --bool mergetool.prompt || echo true)
+keep_going=$(git config --bool mergetool.keepGoing || echo false)
while test $# != 0
do
@@ -305,6 +309,12 @@ do
--prompt)
prompt=true
;;
+ -k|--keep-going)
+ keep_going=true
+ ;;
+ --no-keep-going)
+ keep_going=false
+ ;;
--)
break
;;
@@ -409,6 +419,7 @@ else
fi
fi
+rollup_status=0
if test $# -eq 0 ; then
files=`git ls-files -u | sed -e 's/^[^ ]* //' | sort -u`
@@ -424,12 +435,27 @@ if test $# -eq 0 ; then
do
printf "\n"
merge_file "$i" < /dev/tty > /dev/tty
+ if test $? -ne 0; then
+ if test "$keep_going" = true; then
+ rollup_status=1
+ else
+ exit 1
+ fi
+ fi
done
else
while test $# -gt 0; do
printf "\n"
merge_file "$1"
+ if test $? -ne 0; then
+ if test "$keep_going" = true; then
+ rollup_status=1
+ else
+ exit 1
+ fi
+ fi
shift
done
fi
-exit 0
+
+exit $rollup_status
--
1.6.0.2.534.g5ab59
next prev parent reply other threads:[~2008-11-13 12:42 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-13 12:41 git mergetool enhancements Charles Bailey
2008-11-13 12:41 ` [PATCH 1/3] Fix some tab/space inconsistencies in git-mergetool.sh Charles Bailey
2008-11-13 12:41 ` [PATCH 2/3] Add -y/--no-prompt option to mergetool Charles Bailey
2008-11-13 12:41 ` Charles Bailey [this message]
2008-11-14 6:47 ` [PATCH 3/3] Add -k/--keep-going " Jeff King
2008-11-14 13:25 ` Charles Bailey
2008-11-14 16:21 ` Jeff King
2008-11-15 16:12 ` Theodore Tso
2008-11-15 5:35 ` Junio C Hamano
2008-11-15 5:38 ` Jeff King
2008-11-24 21:59 ` Charles Bailey
2008-11-15 15:56 ` Theodore Tso
2008-11-24 22:03 ` Charles Bailey
2008-11-15 15:50 ` [PATCH 2/3] Add -y/--no-prompt " Theodore Tso
-- strict thread matches above, loose matches on Subject: below --
2008-10-21 10:13 [PATCH 1/3] Fix some tab/space inconsistencies in git-mergetool.sh Charles Bailey
2008-10-21 10:13 ` [PATCH 2/3] Add -n/--no-prompt option to mergetool Charles Bailey
2008-10-21 10:13 ` [PATCH 3/3] Add -k/--keep-going " Charles Bailey
2008-10-21 11:12 ` Jeff King
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=1226580075-29289-4-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).