From: Jonathan Nieder <jrnieder@gmail.com>
To: Richard Lee <richard@webdezign.co.uk>
Cc: "Björn Steinbrink" <B.Steinbrink@gmx.de>,
"Eric Raible" <raible@gmail.com>,
git@vger.kernel.org
Subject: Re: Preserving branches after merging on ancestor
Date: Fri, 6 Nov 2009 16:52:50 -0600 [thread overview]
Message-ID: <20091106225250.GA14642@progeny.tock> (raw)
In-Reply-To: <1257520877359-3959325.post@n2.nabble.com>
Richard Lee wrote:
> Jonathan Nieder wrote:
>> Then your response pushed me towards the question of whether --no-ff is a
>> good idea in general
>>
>
> John, I get the feeling from what you say in general that fast forwards are
> default behaviour for merges for a reason and by using the --no-ff option I
> am making my workflow and git history uncessesarily awkward and working
> against best practices?
Well, no. Some of us (read: I) just haven’t figured out yet how to fit the
--no-ff option into a broader workflow yet. It is only two years old. :)
There are pros and cons to using --no-ff to merge topic branches. Pros:
* 'git log --first-parent' will give the list of topics now.
* The beginning and end of each topic is not forgotten by a clone any
more.
Cons:
* The perceived beginning and end of a topic might be irrelevant or
misleading.
* Every topic needs a good name. :)
* More commits for a person looking through the history to deal with.
A merge commit from a would-be fast-forward records content identical
to its second parent, and it is not necessary as glue to tie the
content-changing commits together any more.
After thinking about it a little, the pros seem to far outweight the cons.
>> Björn Steinbrink wrote:
>>
>>> I guess Richard took the "branch topic1, merge topic1, branch topic2,
>>> merge topic2" thing just as an example because that ends up with two
>>> fast-forwards.
>>
>> Hmm, I found Richard’s example pretty realistic. I used to work like
>> that, and I don’t think I am the only one.
>>
>
> I'm not saying there is any one "right" workflow. But is there a more
> suitable workflow than than "branch topic1, merge topic1, branch topic2,
> merge topic2"?
Yes, in my opinion. I prefer to branch topic1, branch topic2, ...
and only later (after some time to reflect) decide which topics to
merge. For this to work, each topic should not have all previous
topics as ancestors, or there is no way to postpone merging any one.
This is especially nice when a topic turns into a long-term project.
By not merging in the partial work, I keep the code in the master
branch a little cleaner, but more importantly, bugs in the partial
work do not interfere with work on other topics. Once it is finally
time to merge the topic back to master, it is in one clean merge, and
all the commits are together for someone looking at the history.
“What about testing?” one might ask. “How can I tell when it is safe
to merge the topic to master, when the topic and other features since
then might work well separately but not together?” The “Throw-away
integration” section in gitworkflows(7) [1] discusses how to deal with
this.
Taking the idea of forking from the oldest relevant commit to an
extreme in a single-person project, you can end up with history like
this:
initial---------------final
\ /|
\---A-------/ |
\ / /|
\---B---/ / |
\ / |
\---C-- |
\ /
\--D---
\
-E- ...
i.e., full of octopus merges and basically unreadable in gitk.
Arguably, this is at least partially a gitk bug. [Aside: a dream
feature for gitk would be to give the --first-parent history at first
and then fill in topics when the user requests them. That is, in this
example, it would show
initial---final
but after a click on the parent A, it would show
initial---final
\ /
A
and so on.] To avoid this, it is best not defer merging topics into
the mainline for too long, and to base each topic branch not on the
oldest relevant commit but on the tip of the oldest branch it might be
merged to (which in the simplest case is usually the mainline).
A single person has a lot of control over the shape of the history,
so that it is easy to make it totally linear or sequence of enormous
octopuses. The nicest history for others to read, I think, is that
most like one created by many people in a healthy project. But that’s
a hard ideal to achieve, and more important than crafting well shaped
history is to write good code, so it is not worth obsessing over.
I hope that is a little clearer.
Regards,
Jonathan
[1] http://www.kernel.org/pub/software/scm/git/docs/gitworkflows.html#_throw_away_integration
next prev parent reply other threads:[~2009-11-06 22:47 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-05 18:30 Preserving branches after merging on ancestor Richard Lee
2009-11-05 18:38 ` Eric Raible
2009-11-05 22:30 ` Jonathan Nieder
2009-11-05 23:28 ` Björn Steinbrink
2009-11-06 1:09 ` Jonathan Nieder
2009-11-06 2:10 ` Björn Steinbrink
2009-11-06 5:03 ` Jonathan Nieder
2009-11-06 15:21 ` rhlee
2009-11-06 22:52 ` Jonathan Nieder [this message]
2009-11-07 3:41 ` Dilip M
2009-11-07 13:31 ` Björn Steinbrink
2009-11-07 13:28 ` Björn Steinbrink
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20091106225250.GA14642@progeny.tock \
--to=jrnieder@gmail.com \
--cc=B.Steinbrink@gmx.de \
--cc=git@vger.kernel.org \
--cc=raible@gmail.com \
--cc=richard@webdezign.co.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox