threads / discuss / 37235

Re: Amending merge commits?

Subject: Re: Amending merge commits?

## tl;dr

10 messages between Jul 28, 2014 and Jul 30, 2014.

replies: 9people: 3as markdown or json

Nico Williams· Jul 28, 2014, 21:47 UTC · lore
On Mon, Jul 28, 2014 at 3:00 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:
Show 10 quoted lines
> Sergei Organov wrote:
>
>> Is there any scenario at all where pull --rebase=true wins over
>> preserve?
>
> Basically always in my book. ;-)
>
> When people turn on 'pull --rebase', they are asking for a clean,
> simplified history where their changes are small discrete patches in a
> clump on top of upstream.
+1.  Words to develop by.

There are exceptions. E.g., when you pull commits from multiple [forked] upstreams, then you can't keep your local commits on top.

That exception aside, keeping all local commits "on top" by always rebasing them onto the upstream is extremely useful: a) in simplifying conflict resolution, b) making it easy to identify as-yet-unintegrated local commits, c) making it easy to contribute local commits.

Nico --

Sergei Organov· Jul 29, 2014, 09:58 UTC · re: Nico Williams · lore
Nico Williams <nico@cryptonector.com> writes:
Show 21 quoted lines
> On Mon, Jul 28, 2014 at 3:00 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:
>> Sergei Organov wrote:
>>
>>> Is there any scenario at all where pull --rebase=true wins over
>>> preserve?
>>
>> Basically always in my book. ;-)
>>
>> When people turn on 'pull --rebase', they are asking for a clean,
>> simplified history where their changes are small discrete patches in a
>> clump on top of upstream.
>
> +1.  Words to develop by.
>
> There are exceptions.  E.g., when you pull commits from multiple
> [forked] upstreams, then you can't keep your local commits on top.
>
> That exception aside, keeping all local commits "on top" by always
> rebasing them onto the upstream is extremely useful: a) in simplifying
> conflict resolution, b) making it easy to identify as-yet-unintegrated
> local commits, c) making it easy to contribute local commits.

But 'pull --rebase=preserve' does rebase local commits onto the upstream, and result is exactly the same as 'pull --rebase=true', unless you have some of your own merges to be rebased. That's where the difference between these two options appears. It's --rebase=false that performs merges rather than rebase.

Overall, I still can't see where '--rebase=true' wins over '--rebase=preserve'.

-- 
Sergey.
Nico Williams· Jul 29, 2014, 15:44 UTC · re: Sergei Organov · lore
On Tue, Jul 29, 2014 at 4:58 AM, Sergei Organov <osv@javad.com> wrote:
Show 11 quoted lines
> Nico Williams <nico@cryptonector.com> writes:
>> That exception aside, keeping all local commits "on top" by always
>> rebasing them onto the upstream is extremely useful: a) in simplifying
>> conflict resolution, b) making it easy to identify as-yet-unintegrated
>> local commits, c) making it easy to contribute local commits.
>
> But 'pull --rebase=preserve' does rebase local commits onto the
> upstream, and result is exactly the same as 'pull --rebase=true', unless
> you have some of your own merges to be rebased. That's where the
> difference between these two options appears. It's --rebase=false that
> performs merges rather than rebase.

Local merge commits mean that you either didn't rebase to keep all your local commits on top of the upstream, or that you have multiple upstreams (the example exception I gave).

Conversely, if you always rebase your local commits on top of the upstream then you won't have merge commits to worry about.

Nico --

Philip Oakley· Jul 29, 2014, 19:29 UTC · re: Nico Williams · lore
From: "Nico Williams" <nico@cryptonector.com>
Show 24 quoted lines
> On Tue, Jul 29, 2014 at 4:58 AM, Sergei Organov <osv@javad.com> wrote:
>> Nico Williams <nico@cryptonector.com> writes:
>>> That exception aside, keeping all local commits "on top" by always
>>> rebasing them onto the upstream is extremely useful: a) in 
>>> simplifying
>>> conflict resolution, b) making it easy to identify 
>>> as-yet-unintegrated
>>> local commits, c) making it easy to contribute local commits.
>>
>> But 'pull --rebase=preserve' does rebase local commits onto the
>> upstream, and result is exactly the same as 'pull --rebase=true', 
>> unless
>> you have some of your own merges to be rebased. That's where the
>> difference between these two options appears. It's --rebase=false 
>> that
>> performs merges rather than rebase.
>
> Local merge commits mean that you either didn't rebase to keep all
> your local commits on top of the upstream, or that you have multiple
> upstreams (the example exception I gave).
>
> Conversely, if you always rebase your local commits on top of the
> upstream then you won't have merge commits to worry about.
>

Whilst it may not be "the Git Way", I'd expect that in many less well informed companies, the need to keep merge commits fom other lines of development would be quite a common (political ) technique where some preparatory branch needs to be merged in before one's feature can be completed (similar to all those cases on the list when folk say 'builds on top of xy's commit deadbeaf)

Philip 
Nico Williams· Jul 29, 2014, 20:19 UTC · re: Philip Oakley · lore
On Tue, Jul 29, 2014 at 2:29 PM, Philip Oakley <philipoakley@iee.org> wrote:
Show 14 quoted lines
> From: "Nico Williams" <nico@cryptonector.com>
>> Local merge commits mean that you either didn't rebase to keep all
>> your local commits on top of the upstream, or that you have multiple
>> upstreams (the example exception I gave).
>>
>> Conversely, if you always rebase your local commits on top of the
>> upstream then you won't have merge commits to worry about.
>>
> Whilst it may not be "the Git Way", I'd expect that in many less well
> informed companies, the need to keep merge commits fom other lines of
> development would be quite a common (political ) technique where some
> preparatory branch needs to be merged in before one's feature can be
> completed (similar to all those cases on the list when folk say 'builds on
> top of xy's commit deadbeaf)

The way we did this at Sun, first with Teamware, then later with Mercurial, was as follows:

 - "projects" kept their own clone repos of the upstream
 - engineers working on a project cloned the project repo ("project gate")
 - engineers pushed/pulled to/from the project gate
 - each project gate had a gatekeeper whose job it was to periodically
rebase onto the latest upstream
 - then engineers would rebase onto the new project gate

No "merge turds" (Sun speak) were ever allowed in any upstream, whether a project gate or the ultimate upstream. All commits had to be organized according to specific rules, and squashed. These rules applied at the project gate and in the upstream.

 - when the project was ready for integration the gatekeeper would
rebase and squash as necessary, then push to the upstream

(I'm eliding some details. In particular when an intermediate upstream rebased the previous head was left available as a "snapshot" to make the equivalent of git rebase --onto possible.)

The upshot was: all local commits were always on top of whatever the next upstream in the chain was. Always. No merge commits ever.

That workflow works just fine with git. It worked really well at Sun (with thousands of engineers working on Solaris alone). And it should work well for anyone who doesn't have two or more forked upstreams to follow.

Nico --

Philip Oakley· Jul 29, 2014, 21:38 UTC · re: Nico Williams · lore
From: "Nico Williams" <nico@cryptonector.com>
Show 45 quoted lines
> On Tue, Jul 29, 2014 at 2:29 PM, Philip Oakley <philipoakley@iee.org> 
> wrote:
>> From: "Nico Williams" <nico@cryptonector.com>
>>> Local merge commits mean that you either didn't rebase to keep all
>>> your local commits on top of the upstream, or that you have multiple
>>> upstreams (the example exception I gave).
>>>
>>> Conversely, if you always rebase your local commits on top of the
>>> upstream then you won't have merge commits to worry about.
>>>
>> Whilst it may not be "the Git Way", I'd expect that in many less well
>> informed companies, the need to keep merge commits fom other lines of
>> development would be quite a common (political ) technique where some
>> preparatory branch needs to be merged in before one's feature can be
>> completed (similar to all those cases on the list when folk say 
>> 'builds on
>> top of xy's commit deadbeaf)
>
> The way we did this at Sun, first with Teamware, then later with
> Mercurial, was as follows:
>
> - "projects" kept their own clone repos of the upstream
> - engineers working on a project cloned the project repo ("project 
> gate")
> - engineers pushed/pulled to/from the project gate
> - each project gate had a gatekeeper whose job it was to periodically
> rebase onto the latest upstream
> - then engineers would rebase onto the new project gate
>
> No "merge turds" (Sun speak) were ever allowed in any upstream,
> whether a project gate or the ultimate upstream.  All commits had to
> be organized according to specific rules, and squashed.  These rules
> applied at the project gate and in the upstream.
>
> - when the project was ready for integration the gatekeeper would
> rebase and squash as necessary, then push to the upstream
>
> (I'm eliding some details.  In particular when an intermediate
> upstream rebased the previous head was left available as a "snapshot"
> to make the equivalent of git rebase --onto possible.)
>
> The upshot was: all local commits were always on top of whatever the
> next upstream in the chain was.  Always.  No merge commits ever.
>
> That workflow works just fine with git.

I'm not saying that it isn't a good technique and can work well. Rather I'm saying we should be tolerant of the rules and techniques of others who do have 'merges' in their workflow organisation. They may have a very long QA delay between feature 'done' and feature 'done done tested merged', which requires maintaining merges of done items that aren't yet merged to master. Such techniques are more common in mixed engineering than pure software environments (where engineering rules apply, and software has to follow)

>  It worked really well at Sun
> (with thousands of engineers working on Solaris alone).  And it should
> work well for anyone who doesn't have two or more forked upstreams to
> follow.

I'm just cautious of an accidental one size fits all approach, so the ability to rebase lines of development which contain merge commits should be possible (with an appropriate and documented option) without hidden traps.

>
Philip 
Nico Williams· Jul 29, 2014, 22:07 UTC · re: Philip Oakley · lore
On Tue, Jul 29, 2014 at 4:38 PM, Philip Oakley <philipoakley@iee.org> wrote:
Show 6 quoted lines
> From: "Nico Williams" <nico@cryptonector.com>
>> That workflow works just fine with git.
>
> I'm not saying that it isn't a good technique and can work well. Rather I'm
> saying we should be tolerant of the rules and techniques of others who do
> [...]

Sure. I was just giving advice as to how to avoid any problems at pull time w.r.t. local merge commits.

Better merge commit handling at pull time might be great (I'd not know; I avoid local merge commits!), but I would still strongly recommend keeping all local commits on top because otherwise you lose local history. Even if you use -m to set a better commit message, you might prefer to have kept the original N local -now rebased- commits around so you can tell what each discrete change was, even if you'll eventually squash them (you might not squash them all into one).

Show 8 quoted lines
>>  It worked really well at Sun
>> (with thousands of engineers working on Solaris alone).  And it should
>> work well for anyone who doesn't have two or more forked upstreams to
>> follow.
>
> I'm just cautious of an accidental one size fits all approach, so the
> ability to rebase lines of development which contain merge commits should be
> possible (with an appropriate and documented option) without hidden traps.

Thus far the only case I've seen where this approach doesn't work _at all_ is the case where you have multiple forked upstreams. The only other case where it doesn't work is a social problem: rebase allergy. For the repos I maintain I insist on contributed commits applying as fast forward merges, or I'll rebase them myself if need be.

Nico --

Sergei Organov· Jul 30, 2014, 08:42 UTC · re: Nico Williams · lore
Nico Williams <nico@cryptonector.com> writes:
Show 16 quoted lines
> On Tue, Jul 29, 2014 at 4:58 AM, Sergei Organov <osv@javad.com> wrote:
>> Nico Williams <nico@cryptonector.com> writes:
>>> That exception aside, keeping all local commits "on top" by always
>>> rebasing them onto the upstream is extremely useful: a) in simplifying
>>> conflict resolution, b) making it easy to identify as-yet-unintegrated
>>> local commits, c) making it easy to contribute local commits.
>>
>> But 'pull --rebase=preserve' does rebase local commits onto the
>> upstream, and result is exactly the same as 'pull --rebase=true', unless
>> you have some of your own merges to be rebased. That's where the
>> difference between these two options appears. It's --rebase=false that
>> performs merges rather than rebase.
>
> Local merge commits mean that you either didn't rebase to keep all
> your local commits on top of the upstream, or that you have multiple
> upstreams (the example exception I gave).

I rather have multiple (release) branches on single upstream, say, v2.3 and v2.4. When something needs to be fixed in 2.3, it's fixed there and pushed upstream, then, on 2.4, the 2.3 is merged to it, and result is pushed upstream. When I do this merge, I need to push the merge upstream, and this won't work reliably when --rebase=true is acitve (through pull.merge=rebase). If nothing changes upstream, I can simply push this, and the merge is correctly preserved. However, if somebody makes any changes upstream while I perform the merge, I'll need to pull before pushing, and this immediately flattens-out my merge, that is absolutely not what is needed here. Or I can simply pull before push, just in case, and this flattens history even when there are no any changes upstream!

Once again, nobody yet gave any clue of when/why pull.merge=preserve configuration is inferior to pull.merge=rebase, as for all the scenario you seem to care about they bring the same result.

> Conversely, if you always rebase your local commits on top of the
> upstream then you won't have merge commits to worry about.

Wrong. I do alwys rebase my local commits on top of upstream, but I still do have my own merge commits to worry about, as explained above.

-- 
Sergey.
Nico Williams· Jul 30, 2014, 17:43 UTC · re: Sergei Organov · lore
On Wed, Jul 30, 2014 at 3:42 AM, Sergei Organov <osv@javad.com> wrote:
Show 9 quoted lines
> Nico Williams <nico@cryptonector.com> writes:
>> Local merge commits mean that you either didn't rebase to keep all
>> your local commits on top of the upstream, or that you have multiple
>> upstreams (the example exception I gave).
>
> I rather have multiple (release) branches on single upstream, say, v2.3
> and v2.4. When something needs to be fixed in 2.3, it's fixed there and
> pushed upstream, then, on 2.4, the 2.3 is merged to it, and result is
> pushed upstream. When I do this merge, I need to push the merge

Hmm, why not cherry-pick the fix? That's how every project I know that ports fixes across release branches does it.

Show 8 quoted lines
> upstream, and this won't work reliably when --rebase=true is acitve
> (through pull.merge=rebase). If nothing changes upstream, I can simply
> push this, and the merge is correctly preserved. However, if somebody
> makes any changes upstream while I perform the merge, I'll need to pull
> before pushing, and this immediately flattens-out my merge, that is
> absolutely not what is needed here. Or I can simply pull before push,
> just in case, and this flattens history even when there are no any
> changes upstream!
Does this change if you give your merge commits an different commit message?
Show 5 quoted lines
>> Conversely, if you always rebase your local commits on top of the
>> upstream then you won't have merge commits to worry about.
>
> Wrong. I do alwys rebase my local commits on top of upstream, but I
> still do have my own merge commits to worry about, as explained above.

If you cherry-pick the cross-release-branch commits you'll not have a merge commit to worry about.

Nico --

Sergei Organov· Jul 30, 2014, 18:28 UTC · re: Nico Williams · lore
Nico Williams <nico@cryptonector.com> writes:
Show 13 quoted lines
> On Wed, Jul 30, 2014 at 3:42 AM, Sergei Organov <osv@javad.com> wrote:
>> Nico Williams <nico@cryptonector.com> writes:
>>> Local merge commits mean that you either didn't rebase to keep all
>>> your local commits on top of the upstream, or that you have multiple
>>> upstreams (the example exception I gave).
>>
>> I rather have multiple (release) branches on single upstream, say, v2.3
>> and v2.4. When something needs to be fixed in 2.3, it's fixed there and
>> pushed upstream, then, on 2.4, the 2.3 is merged to it, and result is
>> pushed upstream. When I do this merge, I need to push the merge
>
> Hmm, why not cherry-pick the fix?  That's how every project I know
> that ports fixes across release branches does it.

Cherry-pick? Why bother? What problem do we solve, having no merges whatsoever? Why? GIT is so good at merges!

My impression is that people mostly rather do topic branches, and merge them wherever they need the fixes, no?

Show 11 quoted lines
>> upstream, and this won't work reliably when --rebase=true is acitve
>> (through pull.merge=rebase). If nothing changes upstream, I can simply
>> push this, and the merge is correctly preserved. However, if somebody
>> makes any changes upstream while I perform the merge, I'll need to pull
>> before pushing, and this immediately flattens-out my merge, that is
>> absolutely not what is needed here. Or I can simply pull before push,
>> just in case, and this flattens history even when there are no any
>> changes upstream!
>
> Does this change if you give your merge commits an different commit
> message?

Different from what? I'm almost sure commit message has nothing to do with it. Please refer to this explanation to see for yourself how git behaves when rebasing:

http://www.mail-archive.com/git%40vger.kernel.org/msg55605.html
Show 9 quoted lines
>
>>> Conversely, if you always rebase your local commits on top of the
>>> upstream then you won't have merge commits to worry about.
>>
>> Wrong. I do alwys rebase my local commits on top of upstream, but I
>> still do have my own merge commits to worry about, as explained above.
>
> If you cherry-pick the cross-release-branch commits you'll not have a
> merge commit to worry about.

I fail to see why do you consider merge commits to be an evil, really. I didn't think about cherry-picking carefully, but I don't feel cherry-picking is the best tool for the job here. I suspect random cherry-picking would create a mess, sooner or later.

-- 
Sergey.

← back to recent threads