From: Jonathan Nieder Date: Tue, 17 Aug 2010 07:04:43 +0000 (-0500) Subject: merge script: improve log message subject X-Git-Tag: v1.7.3-rc0~16^2~9 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=13dd255e4abb95895aaef72e2b93564be90cb49c;p=git.git merge script: improve log message subject - point out remote-tracking branches as "remote branch 'upstream/master'"; - avoid misleading log messages when a tag and branch share a name. This approximates the builtin merge command's behavior well enough to pass the relevant tests. Based roughly on v1.6.4.2~10^2 (merge: indicate remote tracking branches in merge message, 2009-08-09) and v1.6.4.2~10^2~1 (merge: fix incorrect merge message for ambiguous tag/branch, 2009-08-09). Cc: Jeff King Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- diff --git a/contrib/examples/git-merge.sh b/contrib/examples/git-merge.sh index 50042df1b..d49156666 100755 --- a/contrib/examples/git-merge.sh +++ b/contrib/examples/git-merge.sh @@ -134,21 +134,32 @@ finish () { merge_name () { remote="$1" rh=$(git rev-parse --verify "$remote^0" 2>/dev/null) || return - bh=$(git show-ref -s --verify "refs/heads/$remote" 2>/dev/null) - if test "$rh" = "$bh" - then - echo "$rh branch '$remote' of ." - elif truname=$(expr "$remote" : '\(.*\)~[1-9][0-9]*$') && + if truname=$(expr "$remote" : '\(.*\)~[0-9]*$') && git show-ref -q --verify "refs/heads/$truname" 2>/dev/null then echo "$rh branch '$truname' (early part) of ." - elif test "$remote" = "FETCH_HEAD" -a -r "$GIT_DIR/FETCH_HEAD" + return + fi + if found_ref=$(git rev-parse --symbolic-full-name --verify \ + "$remote" 2>/dev/null) + then + if test "${found_ref#refs/heads/}" != "$found_ref" + then + echo "$rh branch '$remote' of ." + return + elif test "${found_ref#refs/remotes/}" != "$found_ref" + then + echo "$rh remote branch '$remote' of ." + return + fi + fi + if test "$remote" = "FETCH_HEAD" -a -r "$GIT_DIR/FETCH_HEAD" then sed -e 's/ not-for-merge / /' -e 1q \ "$GIT_DIR/FETCH_HEAD" - else - echo "$rh commit '$remote'" + return fi + echo "$rh commit '$remote'" } parse_config () {