git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* who's on first? - following first parent and merge-management
@ 2012-03-07  5:36 Neal Kreitzinger
  2012-03-07  7:37 ` Junio C Hamano
  0 siblings, 1 reply; 13+ messages in thread
From: Neal Kreitzinger @ 2012-03-07  5:36 UTC (permalink / raw)
  To: git

"first parent" and "follow first parent" are mentioned frequently in git 
documentation.  This seems to imply that its pretty important.  That 
would imply it should be intentional (planned).  Who is "first parent"? 
  Who is "first parent" _meant_ to be?  What is "follow first parent" 
_meant_ to show?

(I've been on the rebase track until now so I'm "new" to git-merge's.) 
Symptomatically, I think "first parent" is the branch you were on when 
you did the merge.  That would mean the first parent can change 
depending on your merge-management practices.  This affects the results 
that "follow first parent" produces.  For example:

$ git log --first-parent --oneline origin/master
deadbee some commit x

Scenario A: "First-Parent Flip-Flop" (some users are doing this)

(1) I commit on local master.  USER=foo
$ git checkout master && hack && git commit -a -m "foo commit 1"
$ git log --first-parent --oneline master
foo1111 foo commit 1
deadbee some commit x

(2) You push to canonical master.  USER=bar
$ git checkout master && hack && git commit -a -m "bar commit 1"
$ git log --first-parent --oneline master
bar1111 bar commit 1
deadbee some commit x
$ git push origin HEAD && git fetch origin
$ git log --first-parent --oneline origin/master
bar1111 bar commit 1
deadbee some commit x

(3) I merge canonical master w/my master and push.  USER=foo
$ git checkout master && git pull origin
$ git log --first-parent --oneline master
mrg1111 Merge branch 'master' of file:///root/BARE
foo1111 foo commit 1
deadbee some commit x
$ git push origin HEAD && git fetch origin
$ git log --first-parent --oneline origin/master
mrg1111 Merge branch 'master' of file:///root/BARE
foo1111 foo commit 1
deadbee some commit x

(4) You merge canonical master w/your master and push.  USER=bar
$ git checkout master && hack && git commit -a -m "bar commit 2"
$ git log --first-parent --oneline master
bar2222 bar commit 2
bar1111 bar commit 1
deadbee some commit x
$ git pull origin
$ git log --first-parent --oneline master
mrg2222 Merge branch 'master' of file:///root/BARE
bar2222 bar commit 2
bar1111 bar commit 1
deadbee some commit x
$ git push origin HEAD && git fetch origin
$ git log --first-parent --oneline origin/master
mrg2222 Merge branch 'master' of file:///root/BARE
bar2222 bar commit 2
bar1111 bar commit 1
deadbee some commit x

This "flip-flop" practice does not seem right to me.  Please comment.

Scenario B: "First-Parent Consistency"
(1) I commit on local master.  USER=foo
$ git checkout -b foo-topic master && hack && git commit -a -m "foo 
commit 1"
$ git log --first-parent --oneline foo-topic
foo1111 foo commit 1
deadbee some commit x

(2) You push to canonical master.  USER=bar
$ git checkout -b bar-topic master && hack && git commit -a -m "bar 
commit 1"
$ git log --first-parent --oneline bar-topic
bar1111 bar commit 1
deadbee some commit x
$ git checkout master && git merge bar-topic && git push origin HEAD && 
git fetch origin
$ git log --first-parent --oneline origin/master
bar1111 bar commit 1
deadbee some commit x

(3) I merge --no-ff into master and push.  USER=foo
$ git checkout master && git pull --ff-only origin
$ git log --first-parent --oneline master
bar1111 bar commit 1
deadbee some commit x
$ git-merge foo-topic
$ git log --first-parent --oneline master
mrg1111 Merge branch 'foo-topic'
bar1111 bar commit 1
deadbee some commit x
$ git push origin HEAD && git fetch origin
$ git log --first-parent --oneline origin/master
mrg1111 Merge branch 'foo-topic'
bar1111 bar commit 1
deadbee some commit x

(4) You merge --no-ff into master and push.  USER=bar
$ git checkout bar-topic && hack && git commit -a -m "bar commit 2"
$ git log --first-parent --oneline bar-topic
bar2222 bar commit 2
bar1111 bar commit 1
deadbee some commit x
$ git checkout origin && git pull --ff-only origin
$ git log --first-parent --oneline master
mrg1111 Merge branch 'foo-topic'
bar1111 bar commit 1
deadbee some commit x
$ git merge bar-topic
$ git log --first-parent --oneline master
mrg2222 Merge branch 'bar-topic'
mrg1111 Merge branch 'foo-topic'
bar1111 bar commit 1
deadbee some commit x
$ git push origin HEAD && git fetch origin
$ git log --first-parent --oneline origin/master
mrg2222 Merge branch 'bar-topic'
mrg1111 Merge branch 'foo-topic'
bar1111 bar commit 1
deadbee some commit x

This "consistency" scenario seems better, but I'm not sure if its right. 
  Git seems to "like it" in that the merge messages make more sense. 
Please comment.

Please advise on "first parent" intent, best-practices, and pitfalls, or 
documentation that explains it.  (I haven't found documentation that 
directly explains "first parent theory and practice".  I've seen many 
references to "first parent" and its implied meaning that I'm supposed 
to "just know" or deduce).

Thanks in advance for any pointers.

v/r,
neal

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2012-03-09 16:26 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-07  5:36 who's on first? - following first parent and merge-management Neal Kreitzinger
2012-03-07  7:37 ` Junio C Hamano
2012-03-08  6:13   ` Junio C Hamano
2012-03-08  7:14     ` Jeff King
2012-03-08  7:38       ` Junio C Hamano
2012-03-08  8:03       ` Johannes Sixt
2012-03-08 17:30         ` Junio C Hamano
2012-03-09 12:05           ` Holger Hellmuth
2012-03-09 12:29             ` Johannes Sixt
2012-03-09 13:25               ` Holger Hellmuth
2012-03-09 16:26                 ` Junio C Hamano
2012-03-08  7:49     ` Jonathan Nieder
2012-03-08 22:52       ` Junio C Hamano

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).