From: David Aguilar <davvid@gmail.com>
To: gitster@pobox.com
Cc: charles@hashpling.org, markus.heidelberg@web.de,
git@vger.kernel.org, David Aguilar <davvid@gmail.com>
Subject: [PATCH] mergetool-lib: refactor run_mergetool and check_unchanged
Date: Thu, 2 Apr 2009 19:10:03 -0700 [thread overview]
Message-ID: <1238724603-59551-1-git-send-email-davvid@gmail.com> (raw)
This moves run_mergetool and check_unchanged into mergetool--lib.
git-mergetool no longer uses the global $status variable and instead
checks the return value of run_mergetool.
Signed-off-by: David Aguilar <davvid@gmail.com>
---
git-mergetool--lib.sh | 21 +++++++++++++++++++--
git-mergetool.sh | 20 +-------------------
2 files changed, 20 insertions(+), 21 deletions(-)
diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh
index 91d5453..06d261a 100644
--- a/git-mergetool--lib.sh
+++ b/git-mergetool--lib.sh
@@ -22,9 +22,25 @@ get_merge_tool_path () {
echo "$path"
}
-# Overridden in git-mergetool
check_unchanged () {
- true
+ if merge_mode; then
+ if test "$MERGED" -nt "$BACKUP"; then
+ status=0
+ else
+ while true; do
+ echo "$MERGED seems unchanged."
+ printf "Was the merge successful? [y/n] "
+ read answer < /dev/tty
+ case "$answer" in
+ y*|Y*) status=0; break ;;
+ n*|N*) status=1; break ;;
+ esac
+ done
+ fi
+ else
+ status=0
+ fi
+ return $status
}
valid_tool () {
@@ -213,4 +229,5 @@ run_mergetool () {
fi
;;
esac
+ return $status
}
diff --git a/git-mergetool.sh b/git-mergetool.sh
index 401c107..298b0a1 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -112,22 +112,6 @@ resolve_deleted_merge () {
done
}
-check_unchanged () {
- if test "$MERGED" -nt "$BACKUP" ; then
- status=0;
- else
- while true; do
- echo "$MERGED seems unchanged."
- printf "Was the merge successful? [y/n] "
- read answer < /dev/tty
- case "$answer" in
- y*|Y*) status=0; break ;;
- n*|N*) status=1; break ;;
- esac
- done
- fi
-}
-
checkout_staged_file () {
tmpfile=$(expr "$(git checkout-index --temp --stage="$1" "$2")" : '\([^ ]*\) ')
@@ -194,9 +178,7 @@ merge_file () {
base_present &&
present=true
- run_mergetool "$merge_tool" "$present"
-
- if test "$status" -ne 0; then
+ if ! run_mergetool "$merge_tool" "$present"; then
echo "merge of $MERGED failed" 1>&2
mv -- "$BACKUP" "$MERGED"
--
1.6.1.3
reply other threads:[~2009-04-03 2:11 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1238724603-59551-1-git-send-email-davvid@gmail.com \
--to=davvid@gmail.com \
--cc=charles@hashpling.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=markus.heidelberg@web.de \
/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).