All of lore.kernel.org
 help / color / mirror / Atom feed
* Rebasing a branch with merges
@ 2017-01-06 19:12 Robert Dailey
  2017-01-06 21:28 ` Philip Oakley
  0 siblings, 1 reply; 4+ messages in thread
From: Robert Dailey @ 2017-01-06 19:12 UTC (permalink / raw)
  To: Git

Here's the scenario:

I create a topic branch so one other developer and myself can work on
a feature that takes 2 weeks to complete. During that 2 week period,
changes are occurring on master that I need in my topic branch. Since
I have a collaborator on the branch, I opt for merges instead of
rebase.

Each day I merge from master to the topic branch, which changes code
I'm actively working in and requires semantic changes (functions
renamed, moved, etc).

Once I'm ready to merge the topic branch back into master, I have two
options (bearing in mind the goal is to keep history as clean as
possible. Furthermore this implies that the constant merging into
topic from master has made the topic branch look unwieldy and
difficult to audit):

1. Do a squash merge, which keeps history clean but we lose context
for the important bits (the commits representing units of work that
contribute to the topic itself).

2. Do a final rebase prior to merging.

#2 doesn't seem to be possible due to patch ordering. For example, if
I have real commits after merge commits that depend on those changes
from master being present as a base at that point in time, the rebase
will cause the patch before it to no longer include those changes from
master.

Is there a mechanism to rebase in this situation to both achieve a
clean, linear history for the topic branch and allow fast forward
merging if desired, while still not causing superfluous conflicts due
to the merges being omitted during the rebase?

Thanks in advance for any advice in this scenario.

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

* Re: Rebasing a branch with merges
  2017-01-06 19:12 Rebasing a branch with merges Robert Dailey
@ 2017-01-06 21:28 ` Philip Oakley
  2017-01-09 18:52   ` Robert Dailey
  0 siblings, 1 reply; 4+ messages in thread
From: Philip Oakley @ 2017-01-06 21:28 UTC (permalink / raw)
  To: Robert Dailey, Git; +Cc: Johannes Schindelin

From: "Robert Dailey" <rcdailey.lists@gmail.com>
> Here's the scenario:
>
> I create a topic branch so one other developer and myself can work on
> a feature that takes 2 weeks to complete. During that 2 week period,
> changes are occurring on master that I need in my topic branch. Since
> I have a collaborator on the branch, I opt for merges instead of
> rebase.
>
> Each day I merge from master to the topic branch, which changes code
> I'm actively working in and requires semantic changes (functions
> renamed, moved, etc).
>
> Once I'm ready to merge the topic branch back into master, I have two
> options (bearing in mind the goal is to keep history as clean as
> possible. Furthermore this implies that the constant merging into
> topic from master has made the topic branch look unwieldy and
> difficult to audit):

a broader question zero;
0. Is the merge always clean? Do you always do a preparatory fixup! to 
ensure that the merge will be clean?

Ensuring that the merge will be clean should greatly simplify your decision 
about process.

>
> 1. Do a squash merge, which keeps history clean but we lose context
> for the important bits (the commits representing units of work that
> contribute to the topic itself).
>
> 2. Do a final rebase prior to merging.
>
> #2 doesn't seem to be possible due to patch ordering. For example, if
> I have real commits after merge commits that depend on those changes
> from master being present as a base at that point in time, the rebase
> will cause the patch before it to no longer include those changes from
> master.

How much of the historic fixups to cover changes on master do you want to 
keep visible? i.e. how many fork-points are truly needed (a. by you, b. by 
the project - personal knowledge vs corporate knowledge).?

>
> Is there a mechanism to rebase in this situation to both achieve a
> clean, linear history for the topic branch and allow fast forward
> merging if desired, while still not causing superfluous conflicts due
> to the merges being omitted during the rebase?
>
> Thanks in advance for any advice in this scenario.
>

Have you looked at @dscho's garden-shears scripts that he uses on 
Git-for-Windows as he has to continuously rebase the Windows specific 
patches on top of the progressing Git master? Very similar issues ;-)

https://github.com/git-for-windows/build-extra/blob/master/shears.sh 
https://blogs.msdn.microsoft.com/visualstudioalm/2016/09/03/whats-new-in-git-for-windows-2-10/ 
(#Fun Facts)

--
Philip 


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

* Re: Rebasing a branch with merges
  2017-01-06 21:28 ` Philip Oakley
@ 2017-01-09 18:52   ` Robert Dailey
  2017-01-09 21:03     ` Philip Oakley
  0 siblings, 1 reply; 4+ messages in thread
From: Robert Dailey @ 2017-01-09 18:52 UTC (permalink / raw)
  To: Philip Oakley; +Cc: Git, Johannes Schindelin

On Fri, Jan 6, 2017 at 3:28 PM, Philip Oakley <philipoakley@iee.org> wrote:
> From: "Robert Dailey" <rcdailey.lists@gmail.com>
>>
>> Here's the scenario:
>>
>> I create a topic branch so one other developer and myself can work on
>> a feature that takes 2 weeks to complete. During that 2 week period,
>> changes are occurring on master that I need in my topic branch. Since
>> I have a collaborator on the branch, I opt for merges instead of
>> rebase.
>>
>> Each day I merge from master to the topic branch, which changes code
>> I'm actively working in and requires semantic changes (functions
>> renamed, moved, etc).
>>
>> Once I'm ready to merge the topic branch back into master, I have two
>> options (bearing in mind the goal is to keep history as clean as
>> possible. Furthermore this implies that the constant merging into
>> topic from master has made the topic branch look unwieldy and
>> difficult to audit):
>
>
> a broader question zero;
> 0. Is the merge always clean? Do you always do a preparatory fixup! to
> ensure that the merge will be clean?
>
> Ensuring that the merge will be clean should greatly simplify your decision
> about process.

I don't understand what you're asking. How would I do a fixup with
merges? Can you explain a bit? Normally the only time I use fixup! or
squash! is for local changes prior to pushing.

>> 1. Do a squash merge, which keeps history clean but we lose context
>> for the important bits (the commits representing units of work that
>> contribute to the topic itself).
>>
>> 2. Do a final rebase prior to merging.
>>
>> #2 doesn't seem to be possible due to patch ordering. For example, if
>> I have real commits after merge commits that depend on those changes
>> from master being present as a base at that point in time, the rebase
>> will cause the patch before it to no longer include those changes from
>> master.
>
>
> How much of the historic fixups to cover changes on master do you want to
> keep visible? i.e. how many fork-points are truly needed (a. by you, b. by
> the project - personal knowledge vs corporate knowledge).?


Again, I do not understand. Maybe the first question you asked needs
to be understood before I can answer this one. Sorry for the trouble.

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

* Re: Rebasing a branch with merges
  2017-01-09 18:52   ` Robert Dailey
@ 2017-01-09 21:03     ` Philip Oakley
  0 siblings, 0 replies; 4+ messages in thread
From: Philip Oakley @ 2017-01-09 21:03 UTC (permalink / raw)
  To: Robert Dailey; +Cc: Git, Johannes Schindelin

From: "Robert Dailey" <rcdailey.lists@gmail.com>
> On Fri, Jan 6, 2017 at 3:28 PM, Philip Oakley <philipoakley@iee.org> 
> wrote:
>> From: "Robert Dailey" <rcdailey.lists@gmail.com>
>>>
>>> Here's the scenario:
>>>
>>> I create a topic branch so one other developer and myself can work on
>>> a feature that takes 2 weeks to complete. During that 2 week period,
>>> changes are occurring on master that I need in my topic branch. Since
>>> I have a collaborator on the branch, I opt for merges instead of
>>> rebase.
>>>
>>> Each day I merge from master to the topic branch, which changes code
>>> I'm actively working in and requires semantic changes (functions
>>> renamed, moved, etc).
>>>
>>> Once I'm ready to merge the topic branch back into master, I have two
>>> options (bearing in mind the goal is to keep history as clean as
>>> possible. Furthermore this implies that the constant merging into
>>> topic from master has made the topic branch look unwieldy and
>>> difficult to audit):
>>
>>
>> a broader question zero;
>> 0. Is the merge always clean? Do you always do a preparatory fixup! to
>> ensure that the merge will be clean?
>>
>> Ensuring that the merge will be clean should greatly simplify your 
>> decision
>> about process.
>
> I don't understand what you're asking. How would I do a fixup with
> merges? Can you explain a bit? Normally the only time I use fixup! or
> squash! is for local changes prior to pushing.
>

I was using 'fixup!' figuratively, rather than literally. If I understand 
the general setup correctly, what you want is that if one does a trial 
merge, then it must merge cleanly, compile and pass all tests, or if it 
doesn't, you would need to add that extra commit to ensure that you get that 
clean merge.

The alternative is that there is extra work to be done after the 'merge' 
(which may be a management choice) to then get your nice code ready for 
wider release - it may even be someone elses job to do 'integration'.

Either way, at least if you rationalise the clean end point it becomes 
easier to discuss the start point. If both ends are 'dirty' it is an open 
argument...

>>> 1. Do a squash merge, which keeps history clean but we lose context
>>> for the important bits (the commits representing units of work that
>>> contribute to the topic itself).
>>>
>>> 2. Do a final rebase prior to merging.
>>>
>>> #2 doesn't seem to be possible due to patch ordering. For example, if
>>> I have real commits after merge commits that depend on those changes
>>> from master being present as a base at that point in time, the rebase
>>> will cause the patch before it to no longer include those changes from
>>> master.
>>
>>
>> How much of the historic fixups to cover changes on master do you want to
>> keep visible? i.e. how many fork-points are truly needed (a. by you, b. 
>> by
>> the project - personal knowledge vs corporate knowledge).?
>
>
> Again, I do not understand. Maybe the first question you asked needs
> to be understood before I can answer this one. Sorry for the trouble.
>

In some scenarios it is important to keep the record of the exact start 
point (date and place) to formally justify the work performed (time eleapsed 
etc). Now given the other part of your scenario of a moving api / function 
naming etc, you now have two reference points - the original start point, 
and the release point of the new api/names.

So at that point you probably want to merge in those changes (one way or 
another), which gives you a choice of a true merge (option 1), or adding a 
patch to cherry pick the bulk changes on master (option2), or just the api 
changes (if you can isolate them) (option3). No option is inherently 
better - it will depend on local needs.

From a clean code perspective, it's nicest if you can simply rebase your 
code, but that isn't alway possible. The hard bit is to be clear about the 
local issues, and which ones are immutable. These will decide your choice.

Philip


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

end of thread, other threads:[~2017-01-09 21:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-06 19:12 Rebasing a branch with merges Robert Dailey
2017-01-06 21:28 ` Philip Oakley
2017-01-09 18:52   ` Robert Dailey
2017-01-09 21:03     ` Philip Oakley

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.