Skip to content

Commit

Permalink
merge script: improve log message subject
Browse files Browse the repository at this point in the history
 - 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 <peff@peff.net>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jonathan Nieder authored and Junio C Hamano committed Aug 18, 2010
1 parent 6239af1 commit 13dd255
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions contrib/examples/git-merge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down

0 comments on commit 13dd255

Please sign in to comment.