Skip to content

Commit

Permalink
merge tests: octopus with redundant parents
Browse files Browse the repository at this point in the history
This happens when git merge is run to merge multiple commits that are
descendants of current HEAD (or are HEAD).  We've hit this while updating
master to origin/master but accidentaly we called (while being on master):

	$ git merge master origin/master

Here is a minimal testcase:

	$ git init a && cd a
	$ echo a >a && git add a
	$ git commit -minitial
	$ echo b >a && git add a
	$ git commit -msecond
	$ git checkout master^

	$ git merge master master
	Fast-forwarding to: master
	Already up-to-date with master
	Merge made by the 'octopus' strategy.
	 a |    2 +-
	  1 files changed, 1 insertions(+), 1 deletions(-)

	$ git cat-file commit HEAD
	tree eebfed94e75e7760540d1485c740902590a00332
	parent bd679e85202280b263e20a57639a142fa14c2c64
	author Michał Kiedrowicz <michal.kiedrowicz@gmail.com> 1329132996 +0100
	committer Michał Kiedrowicz <michal.kiedrowicz@gmail.com> 1329132996 +0100

	Merge branches 'master' and 'master' into HEAD

Signed-off-by: Michał Kiedrowicz <michal.kiedrowicz@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Michał Kiedrowicz authored and Junio C Hamano committed Apr 18, 2012
1 parent 6eab5f2 commit 833abdc
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 7 deletions.
17 changes: 16 additions & 1 deletion t/t6028-merge-up-to-date.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ test_expect_success setup '
test_tick &&
git commit -m second &&
git tag c1 &&
git branch test
git branch test &&
echo third >file &&
git add file &&
test_tick &&
git commit -m third &&
git tag c2
'

test_expect_success 'merge -s recursive up-to-date' '
Expand Down Expand Up @@ -74,4 +79,14 @@ test_expect_success 'merge -s subtree up-to-date' '
'

test_expect_failure 'merge fast-forward octopus' '
git reset --hard c0 &&
test_tick &&
git merge c1 c2
expect=$(git rev-parse c2) &&
current=$(git rev-parse HEAD) &&
test "$expect" = "$current"
'

test_done
10 changes: 4 additions & 6 deletions t/t7602-merge-octopus-many.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,15 @@ test_expect_success 'merge output uses pretty names' '
'

cat >expected <<\EOF
Already up-to-date with c4
Trying simple merge with c5
Merge made by the 'octopus' strategy.
Merge made by the 'recursive' strategy.
c5.c | 1 +
1 file changed, 1 insertion(+)
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_expect_failure 'merge reduces irrelevant remote heads' '
GIT_MERGE_VERBOSITY=0 git merge c4 c5 >actual &&
test_cmp expected actual
'

cat >expected <<\EOF
Expand Down
19 changes: 19 additions & 0 deletions t/t7603-merge-reduce-heads.sh
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,23 @@ test_expect_success 'verify merge result' '
test $(git rev-parse HEAD^1) = $(git rev-parse E2) &&
test $(git rev-parse HEAD^2) = $(git rev-parse I2)
'

test_expect_success 'fast-forward to redundant refs' '
git reset --hard c0 &&
git merge c4 c5
'

test_expect_failure 'verify merge result' '
test $(git rev-parse HEAD) = $(git rev-parse c5)
'

test_expect_success 'merge up-to-date redundant refs' '
git reset --hard c5 &&
git merge c0 c4
'

test_expect_success 'verify merge result' '
test $(git rev-parse HEAD) = $(git rev-parse c5)
'

test_done

0 comments on commit 833abdc

Please sign in to comment.