Code

git-merge: fix confusion between tag and branch
authorJunio C Hamano <junkio@cox.net>
Sun, 3 Dec 2006 00:58:30 +0000 (16:58 -0800)
committerJunio C Hamano <junkio@cox.net>
Sun, 3 Dec 2006 00:58:30 +0000 (16:58 -0800)
In a repository with core.warnambiguousrefs turned off, and with
a branch and a tag that have the same name 'frotz',

git merge frotz

would merge the commit pointed at by the tag 'frotz' but
incorrectly would identify what was merged as 'branch frotz' in
the merge message.

Signed-off-by: Junio C Hamano <junkio@cox.net>
git-merge.sh

index 75af10d3e431edf6f7447ab4a3dfcf84e994a2ef..272f004622572ad2aed62268d9a75cac5a8fa751 100755 (executable)
@@ -189,13 +189,13 @@ else
        merge_name=$(for remote
                do
                        rh=$(git-rev-parse --verify "$remote"^0 2>/dev/null) &&
-                       if git show-ref -q --verify "refs/heads/$remote"
+                       bh=$(git show-ref -s --verify "refs/heads/$remote") &&
+                       if test "$rh" = "$bh"
                        then
-                               what=branch
+                               echo "$rh               branch '$remote' of ."
                        else
-                               what=commit
-                       fi &&
-                       echo "$rh               $what '$remote'"
+                               echo "$rh               commit '$remote'"
+                       fi
                done | git-fmt-merge-msg
        )
        merge_msg="${merge_msg:+$merge_msg$LF$LF}$merge_name"