git-svn: correctly handle packed-refs in refs/remotes/
[gitweb.git] / git-merge.sh
index 5fa8b0d577879e00c1959098250a9b1fd559fdc8..a948878b911f56a3d6ace784d5a93952ce25c64b 100755 (executable)
@@ -159,7 +159,7 @@ then
        shift
        head_arg="$1"
        shift
-elif ! git-rev-parse --verify HEAD 2>/dev/null
+elif ! git-rev-parse --verify HEAD >/dev/null 2>&1
 then
        # If the merged head is a valid one there is no reason to
        # forbid "git merge" into a branch yet to be born.  We do
@@ -188,14 +188,15 @@ else
        # in this loop.
        merge_name=$(for remote
                do
-                       rh=$(git-rev-parse --verify "$remote"^0 2>/dev/null) &&
-                       if git show-ref -q --verify "refs/heads/$remote"
+                       rh=$(git-rev-parse --verify "$remote"^0 2>/dev/null) ||
+                       continue ;# not something we can merge
+                       bh=$(git show-ref -s --verify "refs/heads/$remote" 2>/dev/null)
+                       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"