From: "Jay Soffian" <jaysoffian@gmail.com>
To: "Git Mailing List" <git@vger.kernel.org>
Subject: mergetool local/remote improvements?
Date: Wed, 20 Feb 2008 16:40:04 -0500 [thread overview]
Message-ID: <76718490802201340g5ce15c1fl3e4f6d4e655c96be@mail.gmail.com> (raw)
When in branch <mine> and doing "git rebase <upstream>", if there are
any conflicts, the merge tool will come up with the version of the file
from branch <mine> tagged with ".REMOTE" and the version from branch
<upstream> tagged ".LOCAL".
I understand the reason for this, but still, it seems backwards. So I
was going to propose something like the patch below, but I realized that
it might be more useful if mergetool took --local and --remote arguments
so that the caller could provide more meaningful names, e.g. given
--local=mybranch
--remote=theirbranch
mergetool would use mybranch/MYBRANCH in place of local/LOCAL and
similarly theirbranch/THEIRBRANCH in place of remote/REMOTE.
Of course, I then have to wonder if mergetool could use branch names by
default in those cases where branch names can be determined
unambiguously (not sure how to do that though other than for git-merge
and git-rebase to leave a hint about the operation in progress).
Thoughts?
git-mergetool.sh | 21 ++++++++++++++++-----
1 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/git-mergetool.sh b/git-mergetool.sh
index cbbb707..c688858 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -20,6 +20,10 @@ is_symlink () {
test "$1" = 120000
}
+is_rebase_merge () {
+ test -d "$GIT_DIR/.dotest-merge"
+}
+
local_present () {
test -n "$local_mode"
}
@@ -162,12 +166,19 @@ merge_file () {
cp -- "$BACKUP" "$path"
base_mode=`git ls-files -u -- "$path" | awk '{if ($3==1) print $1;}'`
- local_mode=`git ls-files -u -- "$path" | awk '{if ($3==2) print $1;}'`
- remote_mode=`git ls-files -u -- "$path" | awk '{if ($3==3) print $1;}'`
+ base_present && git cat-file blob ":1:$prefix$path" >"$BASE" 2>/dev/null
- base_present && git cat-file blob ":1:$prefix$path" >"$BASE" 2>/dev/null
- local_present && git cat-file blob ":2:$prefix$path" >"$LOCAL" 2>/dev/null
- remote_present && git cat-file blob ":3:$prefix$path" >"$REMOTE"
2>/dev/null
+ if is_rebase_merge; then
+ local_mode=`git ls-files -u -- "$path" | awk '{if ($3==3) print $1;}'`
+ local_present && git cat-file blob ":3:$prefix$path" >"$LOCAL" 2>/dev/null
+ remote_mode=`git ls-files -u -- "$path" | awk '{if ($3==2) print $1;}'`
+ remote_present && git cat-file blob ":2:$prefix$path" >"$REMOTE" 2>/dev/null
+ else
+ local_mode=`git ls-files -u -- "$path" | awk '{if ($3==2) print $1;}'`
+ local_present && git cat-file blob ":2:$prefix$path" >"$LOCAL" 2>/dev/null
+ remote_mode=`git ls-files -u -- "$path" | awk '{if ($3==3) print $1;}'`
+ remote_present && git cat-file blob ":3:$prefix$path" >"$REMOTE" 2>/dev/null
+ fi
if test -z "$local_mode" -o -z "$remote_mode"; then
echo "Deleted merge conflict for '$path':"
reply other threads:[~2008-02-20 21:40 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=76718490802201340g5ce15c1fl3e4f6d4e655c96be@mail.gmail.com \
--to=jaysoffian@gmail.com \
--cc=git@vger.kernel.org \
/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).