From 22e0560a70f4b5bfbbf571647e03fa154a6d6bd1 Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Tue, 17 Aug 2010 02:03:07 -0500 Subject: merge script: --squash, --ff from unborn branch are errors Port v1.6.1-rc1~319 (provide more errors for the "merge into empty head" case, 2008-08-21) to the example merge script. Noticed by comparison with builtin merge. Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- contrib/examples/git-merge.sh | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'contrib') diff --git a/contrib/examples/git-merge.sh b/contrib/examples/git-merge.sh index 8f617fcb70..72853cf7fe 100755 --- a/contrib/examples/git-merge.sh +++ b/contrib/examples/git-merge.sh @@ -245,6 +245,10 @@ then exit 1 fi + test "$squash" != t || + die "Squash commit into empty head not supported yet" + test "$allow_fast_forward" = t || + die "Non-fast-forward into an empty head does not make sense" rh=$(git rev-parse --verify "$1^0") || die "$1 - not something we can merge" -- cgit v1.2.3 From 64048d670b4810125493ff0a2bab88cb12344e7f Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Tue, 17 Aug 2010 02:03:36 -0500 Subject: merge script: tweak unmerged files message to match builtin Before: You are in the middle of a conflicted merge. After: Merge is not possible because you have unmerged files. I prefer the old message, but the new one is more consistent with other commands and tests expect it. In particular, without this change the scripted merge does not pass t3030. Based on v1.7.0-rc0~66^2 (Be more user-friendly when refusing to do something because of conflict., 2010-01-12). Cc: Matthieu Moy Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- contrib/examples/git-merge.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'contrib') diff --git a/contrib/examples/git-merge.sh b/contrib/examples/git-merge.sh index 72853cf7fe..99fe1f2594 100755 --- a/contrib/examples/git-merge.sh +++ b/contrib/examples/git-merge.sh @@ -25,7 +25,7 @@ require_work_tree cd_to_toplevel test -z "$(git ls-files -u)" || - die "You are in the middle of a conflicted merge." + die "Merge is not possible because you have unmerged files." LF=' ' -- cgit v1.2.3 From 6239af1c6c272eeb2b15359ff0dc25d769d5ac78 Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Tue, 17 Aug 2010 02:03:58 -0500 Subject: merge script: refuse to merge during merge Check MERGE_HEAD and bail out if it exists. Based on v1.6.3.3~3^2 (refuse to merge during a merge, 2009-06-01). Without this change, the scripted merge does not pass t3030. Cc: Clemens Buchacher Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- contrib/examples/git-merge.sh | 3 +++ 1 file changed, 3 insertions(+) (limited to 'contrib') diff --git a/contrib/examples/git-merge.sh b/contrib/examples/git-merge.sh index 99fe1f2594..50042df1b9 100755 --- a/contrib/examples/git-merge.sh +++ b/contrib/examples/git-merge.sh @@ -27,6 +27,9 @@ cd_to_toplevel test -z "$(git ls-files -u)" || die "Merge is not possible because you have unmerged files." +! test -e "$GIT_DIR/MERGE_HEAD" || + die 'You have not concluded your merge (MERGE_HEAD exists).' + LF=' ' -- cgit v1.2.3 From 13dd255e4abb95895aaef72e2b93564be90cb49c Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Tue, 17 Aug 2010 02:04:43 -0500 Subject: 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 --- contrib/examples/git-merge.sh | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'contrib') diff --git a/contrib/examples/git-merge.sh b/contrib/examples/git-merge.sh index 50042df1b9..d491566660 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 () { -- cgit v1.2.3 From 5d75a52b3a8870c3c1b27c5d791da5c9267e1fb5 Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Tue, 17 Aug 2010 02:05:10 -0500 Subject: merge script: merge -X