From 81334502eed1c78f49fc74936b712b3cf32b682a Mon Sep 17 00:00:00 2001 From: Stephen Boyd Date: Fri, 11 Dec 2009 16:38:57 -0800 Subject: octopus: make merge process simpler to follow Its not very easy to understand what heads are being merged given the current output of an octopus merge. Fix this by replacing the sha1 with the (usually) better description in GITHEAD_. Suggested-by: Jari Aalto Signed-off-by: Stephen Boyd Signed-off-by: Junio C Hamano --- git-merge-octopus.sh | 9 +++++---- t/t7602-merge-octopus-many.sh | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/git-merge-octopus.sh b/git-merge-octopus.sh index 1dadbb4966..3bb1acd527 100755 --- a/git-merge-octopus.sh +++ b/git-merge-octopus.sh @@ -61,12 +61,13 @@ do exit 2 esac + eval pretty_name=\${GITHEAD_$SHA1:-$SHA1} common=$(git merge-base --all $SHA1 $MRC) || - die "Unable to find common commit with $SHA1" + die "Unable to find common commit with $pretty_name" case "$LF$common$LF" in *"$LF$SHA1$LF"*) - echo "Already up-to-date with $SHA1" + echo "Already up-to-date with $pretty_name" continue ;; esac @@ -81,7 +82,7 @@ do # tree as the intermediate result of the merge. # We still need to count this as part of the parent set. - echo "Fast forwarding to: $SHA1" + echo "Fast-forwarding to: $pretty_name" git read-tree -u -m $head $SHA1 || exit MRC=$SHA1 MRT=$(git write-tree) continue @@ -89,7 +90,7 @@ do NON_FF_MERGE=1 - echo "Trying simple merge with $SHA1" + echo "Trying simple merge with $pretty_name" git read-tree -u -m --aggressive $common $MRT $SHA1 || exit 2 next=$(git write-tree 2>/dev/null) if test $? -ne 0 diff --git a/t/t7602-merge-octopus-many.sh b/t/t7602-merge-octopus-many.sh index 01e5415e94..7377033226 100755 --- a/t/t7602-merge-octopus-many.sh +++ b/t/t7602-merge-octopus-many.sh @@ -49,4 +49,37 @@ test_expect_success 'merge c1 with c2, c3, c4, ... c29' ' done ' +cat >expected <<\EOF +Trying simple merge with c2 +Trying simple merge with c3 +Trying simple merge with c4 +Merge made by octopus. + c2.c | 1 + + c3.c | 1 + + c4.c | 1 + + 3 files changed, 3 insertions(+), 0 deletions(-) + create mode 100644 c2.c + create mode 100644 c3.c + create mode 100644 c4.c +EOF + +test_expect_success 'merge output uses pretty names' ' + git reset --hard c1 && + git merge c2 c3 c4 >actual && + test_cmp actual expected +' + +cat >expected <<\EOF +Already up-to-date with c4 +Trying simple merge with c5 +Merge made by octopus. + c5.c | 1 + + 1 files changed, 1 insertions(+), 0 deletions(-) + create mode 100644 c5.c +EOF + +test_expect_success 'merge up-to-date output uses pretty names' ' + git merge c4 c5 >actual && + test_cmp actual expected +' test_done -- cgit v1.2.3 From 85bf49f9a55fd9ded396460d245a55b651d7bdaa Mon Sep 17 00:00:00 2001 From: Stephen Boyd Date: Fri, 11 Dec 2009 16:38:58 -0800 Subject: octopus: reenable fast-forward merges The fast-forward logic is never being triggered because $common and $MRC are never equivalent. $common is initialized to a commit id by merge-base and MRC is initialized to HEAD. Fix this by initializing $MRC to the commit id for HEAD so that its possible for $MRC and $common to be equal. Signed-off-by: Stephen Boyd Signed-off-by: Junio C Hamano --- git-merge-octopus.sh | 2 +- t/t7602-merge-octopus-many.sh | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/git-merge-octopus.sh b/git-merge-octopus.sh index 3bb1acd527..3d1a29ecd2 100755 --- a/git-merge-octopus.sh +++ b/git-merge-octopus.sh @@ -44,7 +44,7 @@ esac # MRC is the current "merge reference commit" # MRT is the current "merge result tree" -MRC=$head MSG= PARENT="-p $head" +MRC=$(git rev-parse --verify -q $head) MSG= PARENT="-p $head" MRT=$(git write-tree) CNT=1 ;# counting our head NON_FF_MERGE=0 diff --git a/t/t7602-merge-octopus-many.sh b/t/t7602-merge-octopus-many.sh index 7377033226..2746169514 100755 --- a/t/t7602-merge-octopus-many.sh +++ b/t/t7602-merge-octopus-many.sh @@ -82,4 +82,22 @@ test_expect_success 'merge up-to-date output uses pretty names' ' git merge c4 c5 >actual && test_cmp actual expected ' + +cat >expected <<\EOF +Fast-forwarding to: c1 +Trying simple merge with c2 +Merge made by octopus. + c1.c | 1 + + c2.c | 1 + + 2 files changed, 2 insertions(+), 0 deletions(-) + create mode 100644 c1.c + create mode 100644 c2.c +EOF + +test_expect_success 'merge fast-forward output uses pretty names' ' + git reset --hard c0 && + git merge c1 c2 >actual && + test_cmp actual expected +' + test_done -- cgit v1.2.3 From f08aa017675bffe2359e0122cff2e447486b97c1 Mon Sep 17 00:00:00 2001 From: Stephen Boyd Date: Fri, 11 Dec 2009 16:38:59 -0800 Subject: octopus: remove dead code MSG, PARENT, and CNT are never used, just assigned to. Signed-off-by: Stephen Boyd Signed-off-by: Junio C Hamano --- git-merge-octopus.sh | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/git-merge-octopus.sh b/git-merge-octopus.sh index 3d1a29ecd2..615753c83c 100755 --- a/git-merge-octopus.sh +++ b/git-merge-octopus.sh @@ -44,9 +44,8 @@ esac # MRC is the current "merge reference commit" # MRT is the current "merge result tree" -MRC=$(git rev-parse --verify -q $head) MSG= PARENT="-p $head" +MRC=$(git rev-parse --verify -q $head) MRT=$(git write-tree) -CNT=1 ;# counting our head NON_FF_MERGE=0 OCTOPUS_FAILURE=0 for SHA1 in $remotes @@ -72,9 +71,6 @@ do ;; esac - CNT=`expr $CNT + 1` - PARENT="$PARENT -p $SHA1" - if test "$common,$NON_FF_MERGE" = "$MRC,0" then # The first head being merged was a fast-forward. -- cgit v1.2.3