* [BUG] git-merge-octopus creates an empty merge commit with one parent
@ 2012-02-13 11:48 Michał Kiedrowicz
2012-02-13 18:48 ` Junio C Hamano
0 siblings, 1 reply; 5+ messages in thread
From: Michał Kiedrowicz @ 2012-02-13 11:48 UTC (permalink / raw)
To: git; +Cc: Michał Kiedrowicz
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 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
... and below is a patch that adds a testcase to Git's testsuite.
I would expect `git merge master master` to just 'Fast forward'.
Signed-off-by: Michał Kiedrowicz <michal.kiedrowicz@gmail.com>
---
t/t6028-merge-up-to-date.sh | 17 ++++++++++++++++-
1 files changed, 16 insertions(+), 1 deletions(-)
diff --git a/t/t6028-merge-up-to-date.sh b/t/t6028-merge-up-to-date.sh
index a91644e..824fca5 100755
--- a/t/t6028-merge-up-to-date.sh
+++ b/t/t6028-merge-up-to-date.sh
@@ -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' '
@@ -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
--
1.7.9.rc2.155.g2e96
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [BUG] git-merge-octopus creates an empty merge commit with one parent
2012-02-13 11:48 [BUG] git-merge-octopus creates an empty merge commit with one parent Michał Kiedrowicz
@ 2012-02-13 18:48 ` Junio C Hamano
2012-02-13 19:20 ` Michał Kiedrowicz
0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2012-02-13 18:48 UTC (permalink / raw)
To: Michał Kiedrowicz; +Cc: git
Michał Kiedrowicz <michal.kiedrowicz@gmail.com> writes:
> This happens when git merge is run to merge multiple commits that are
> descendants of current HEAD (or are HEAD).
I am reasonably sure you meant ancestors here.
> to origin/master but accidentaly we called (while being on master):
>
> $ git merge master origin/master
I am very tempted to throw this into "don't do it then" category.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [BUG] git-merge-octopus creates an empty merge commit with one parent
2012-02-13 18:48 ` Junio C Hamano
@ 2012-02-13 19:20 ` Michał Kiedrowicz
2012-02-13 19:51 ` Junio C Hamano
0 siblings, 1 reply; 5+ messages in thread
From: Michał Kiedrowicz @ 2012-02-13 19:20 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
Junio C Hamano <gitster@pobox.com> wrote:
> Michał Kiedrowicz <michal.kiedrowicz@gmail.com> writes:
>
> > This happens when git merge is run to merge multiple commits that are
> > descendants of current HEAD (or are HEAD).
>
> I am reasonably sure you meant ancestors here.
I meant: ... to merge commits whose parent, grand-parent or
grand-grand-...-parent is HEAD. Commits to which HEAD may be
fast-forwarded.
>
> > to origin/master but accidentaly we called (while being on master):
> >
> > $ git merge master origin/master
>
> I am very tempted to throw this into "don't do it then" category.
I'm all for it. This is not a thing I would want to be doing. At
no time I would call this "a serious bug that needs fixing right
now". Except that I still think this behavior is not correct. git-merge
should not create commits that even aren't merges (they have single
parrent) and have exactly the same tree as its parent, and give it a
message "merge". Isn't this against the normal behavior of Git:
forwarding if possible and refusing to create commits that don't change
any file?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [BUG] git-merge-octopus creates an empty merge commit with one parent
2012-02-13 19:20 ` Michał Kiedrowicz
@ 2012-02-13 19:51 ` Junio C Hamano
2012-02-13 20:53 ` Michał Kiedrowicz
0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2012-02-13 19:51 UTC (permalink / raw)
To: Michał Kiedrowicz; +Cc: git
Michał Kiedrowicz <michal.kiedrowicz@gmail.com> writes:
> ... Except that I still think this behavior is not correct.
Well, what was missing from my "don't do it then" quote was "Doctor it
HURTS when I do this."; there is no question that it is not correct if it
hurts ;-).
Patches welcome; I suspect it shouldn't be too intrusive or difficult.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-02-13 20:53 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-13 11:48 [BUG] git-merge-octopus creates an empty merge commit with one parent Michał Kiedrowicz
2012-02-13 18:48 ` Junio C Hamano
2012-02-13 19:20 ` Michał Kiedrowicz
2012-02-13 19:51 ` Junio C Hamano
2012-02-13 20:53 ` Michał Kiedrowicz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).