From: Charles Bailey <charles@hashpling.org>
To: git@vger.kernel.org
Cc: Caleb Cushing <xenoterracide@gmail.com>,
Junio C Hamano <gitster@pobox.com>,
Charles Bailey <charles@hashpling.org>
Subject: [PATCH] Test refactor
Date: Tue, 24 Feb 2009 23:01:55 +0000 [thread overview]
Message-ID: <1235516515-3996-1-git-send-email-charles@hashpling.org> (raw)
In-Reply-To: <1235516466-3930-1-git-send-email-charles@hashpling.org>
---
git-mergetool.sh | 110 +++++++++++++++++++++++++++++-------------------------
1 files changed, 59 insertions(+), 51 deletions(-)
diff --git a/git-mergetool.sh b/git-mergetool.sh
index 87fa88a..9446b8e 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -99,7 +99,7 @@ resolve_deleted_merge () {
return 0
;;
[dD]*)
- git rm -- "$MERGED" > /dev/null
+ git rm -q -- "$MERGED"
cleanup_temp_files
return 0
;;
@@ -134,55 +134,8 @@ checkout_staged_file () {
fi
}
-merge_file () {
- MERGED="$1"
-
- f=`git ls-files -u -- "$MERGED"`
- if test -z "$f" ; then
- if test ! -f "$MERGED" ; then
- echo "$MERGED: file not found"
- else
- echo "$MERGED: file does not need merging"
- fi
- return 1
- fi
-
- ext="$$$(expr "$MERGED" : '.*\(\.[^/]*\)$')"
- BACKUP="./$MERGED.BACKUP.$ext"
- LOCAL="./$MERGED.LOCAL.$ext"
- REMOTE="./$MERGED.REMOTE.$ext"
- BASE="./$MERGED.BASE.$ext"
-
- mv -- "$MERGED" "$BACKUP"
- cp -- "$BACKUP" "$MERGED"
-
- base_mode=`git ls-files -u -- "$MERGED" | awk '{if ($3==1) print $1;}'`
- local_mode=`git ls-files -u -- "$MERGED" | awk '{if ($3==2) print $1;}'`
- remote_mode=`git ls-files -u -- "$MERGED" | awk '{if ($3==3) print $1;}'`
-
- base_present && checkout_staged_file 1 "$MERGED" "$BASE"
- local_present && checkout_staged_file 2 "$MERGED" "$LOCAL"
- remote_present && checkout_staged_file 3 "$MERGED" "$REMOTE"
+resolve_normal_merge () {
- if test -z "$local_mode" -o -z "$remote_mode"; then
- echo "Deleted merge conflict for '$MERGED':"
- describe_file "$local_mode" "local" "$LOCAL"
- describe_file "$remote_mode" "remote" "$REMOTE"
- resolve_deleted_merge
- return
- fi
-
- if is_symlink "$local_mode" || is_symlink "$remote_mode"; then
- echo "Symbolic link merge conflict for '$MERGED':"
- describe_file "$local_mode" "local" "$LOCAL"
- describe_file "$remote_mode" "remote" "$REMOTE"
- resolve_symlink_merge
- return
- fi
-
- echo "Normal merge conflict for '$MERGED':"
- describe_file "$local_mode" "local" "$LOCAL"
- describe_file "$remote_mode" "remote" "$REMOTE"
if "$prompt" = true; then
printf "Hit return to start merge resolution tool (%s): " "$merge_tool"
read ans
@@ -278,7 +231,62 @@ merge_file () {
fi
;;
esac
- if test "$status" -ne 0; then
+
+ if test $status -eq 0; then
+ git add -- "$MERGED"
+ fi
+
+ return $status
+}
+
+merge_file () {
+ MERGED="$1"
+
+ f=`git ls-files -u -- "$MERGED"`
+ if test -z "$f" ; then
+ if test ! -f "$MERGED" ; then
+ echo "$MERGED: file not found"
+ else
+ echo "$MERGED: file does not need merging"
+ fi
+ return 1
+ fi
+
+ ext="$$$(expr "$MERGED" : '.*\(\.[^/]*\)$')"
+ BACKUP="./$MERGED.BACKUP.$ext"
+ LOCAL="./$MERGED.LOCAL.$ext"
+ REMOTE="./$MERGED.REMOTE.$ext"
+ BASE="./$MERGED.BASE.$ext"
+
+ mv -- "$MERGED" "$BACKUP"
+ cp -- "$BACKUP" "$MERGED"
+
+ base_mode=`git ls-files -u -- "$MERGED" | awk '{if ($3==1) print $1;}'`
+ local_mode=`git ls-files -u -- "$MERGED" | awk '{if ($3==2) print $1;}'`
+ remote_mode=`git ls-files -u -- "$MERGED" | awk '{if ($3==3) print $1;}'`
+
+ base_present && checkout_staged_file 1 "$MERGED" "$BASE"
+ local_present && checkout_staged_file 2 "$MERGED" "$LOCAL"
+ remote_present && checkout_staged_file 3 "$MERGED" "$REMOTE"
+
+ if test -z "$local_mode" -o -z "$remote_mode"; then
+ echo "Deleted merge conflict for '$MERGED':"
+ describe_file "$local_mode" "local" "$LOCAL"
+ describe_file "$remote_mode" "remote" "$REMOTE"
+ resolve_deleted_merge
+ elif is_symlink "$local_mode" || is_symlink "$remote_mode"; then
+ echo "Symbolic link merge conflict for '$MERGED':"
+ describe_file "$local_mode" "local" "$LOCAL"
+ describe_file "$remote_mode" "remote" "$REMOTE"
+ resolve_symlink_merge
+ else
+ echo "Normal merge conflict for '$MERGED':"
+ describe_file "$local_mode" "local" "$LOCAL"
+ describe_file "$remote_mode" "remote" "$REMOTE"
+ resolve_normal_merge
+ fi
+
+ if test $? -ne 0; then
echo "merge of $MERGED failed" 1>&2
mv -- "$BACKUP" "$MERGED"
@@ -295,8 +303,8 @@ merge_file () {
rm -- "$BACKUP"
fi
- git add -- "$MERGED"
cleanup_temp_files
+
return 0
}
--
1.6.2.rc1.258.g314b8b
next prev parent reply other threads:[~2009-02-24 23:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-24 23:01 [PATCH] mergetool: demonstrate directory / file conflict breakage Charles Bailey
2009-02-24 23:01 ` Charles Bailey [this message]
2009-02-24 23:05 ` [PATCH] Test refactor Charles Bailey
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=1235516515-3996-1-git-send-email-charles@hashpling.org \
--to=charles@hashpling.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=xenoterracide@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.