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':" - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html