@matheusbsbs / matheus-bagliano / commits / 0bb733c91c
Fork 0

Use branch names in 'git-rebase -m' conflict hunks.

If a three-way merge in git-rebase generates a conflict then we should take advantage of git-merge-recursive's ability to include the branch name of each side of the conflict hunk by setting the GITHEAD_* environment variables. In the case of rebase there aren't really two clear branches; we have the branch we are rebasing onto, and we have the branch we are currently rebasing. Since most conflicts will be arising between the user's current branch and the branch they are rebasing onto we assume the stuff that isn't in the current commit is the "onto" branch and the stuff in the current commit is the "current" branch. This assumption may however come up wrong if the user resolves one conflict in such a way that it conflicts again on a future commit also being rebased. In this case the user's prior resolution will appear to be in the "onto" part of the hunk. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>

Shawn O. Pearce committed Dec 28, 2006 at 02:34 UTC 0bb733c91cb472a1a5b62381ff4037c6fb124e38
1 file changed +10 -1
git-rebase.sh
+10 -1
@@ -81,10 +81,18 @@ continue_merge () {
81 call_merge () {
82 cmt="$(cat $dotest/cmt.$1)"
83 echo "$cmt" > "$dotest/current"
84 - git-merge-$strategy "$cmt^" -- HEAD "$cmt"
84 + hd=$(git-rev-parse --verify HEAD)
85 + cmt_name=$(git-symbolic-ref HEAD)
86 + msgnum=$(cat $dotest/msgnum)
87 + end=$(cat $dotest/end)
88 + eval GITHEAD_$cmt='"${cmt_name##refs/heads/}~$(($end - $msgnum))"'
89 + eval GITHEAD_$hd='"$(cat $dotest/onto_name)"'
90 + export GITHEAD_$cmt GITHEAD_$hd
91 + git-merge-$strategy "$cmt^" -- "$hd" "$cmt"
92 rv=$?
93 case "$rv" in
94 0)
95 + unset GITHEAD_$cmt GITHEAD_$hd
96 return
97 ;;
98 1)
@@ -314,6 +322,7 @@ fi
322
323 mkdir -p "$dotest"
324 echo "$onto" > "$dotest/onto"
325 +echo "$onto_name" > "$dotest/onto_name"
326 prev_head=`git-rev-parse HEAD^0`
327 echo "$prev_head" > "$dotest/prev_head"
328