All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael J Gruber <git@drmicha.warpmail.net>
To: Peter Weseloh <Peter.Weseloh@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: What is the best way to backport a feature?
Date: Sun, 29 Nov 2009 18:02:32 +0100	[thread overview]
Message-ID: <4B12A928.2000401@drmicha.warpmail.net> (raw)
In-Reply-To: <loom.20091129T164518-669@post.gmane.org>

Peter Weseloh venit, vidit, dixit 29.11.2009 17:28:
> Hi,
> 
> Suppose I have the following situation:
> 
>   o--o--o                    Release_1.0
>  /    \  \                  
> o-o-o--o--o-o-o-o-o-o---o--o Mainline
>      \       \       \ /    
>       F1--F2--M1--F3--M2     Feature_A
> 
> Now I want to backport "Feature_A" to the "Release_1.0" branch so that it gets
> included into the next minor release, i.e. I want to apply the commits F1, F2
> and F3 onto the "Release_1.0" branch.
> I cannot just merge "Feature_A" into "Release_1.0" because that would also bring
> in the merges M1 and M2 so a lot of other stuff from the Mainline.
> 
> I played with cherry-pick but that means I have to manually find the commits F1,
> F2 and F3 (which in reality could be many more if Feature_A is big) which is not
> very nice.
> 
> I also tried 'rebase -i' but that means I have to manually delete all the lines
> for changesets from the mainline. Also not very nice.
> 
> Is there a better way? To me this scenario sounds not unusual but I could not
> find a solution.

The problem is that you've been a bad boy to begin with ;)

Seriously, I suggest reading up on "topic branches". Feature_A should
have been based off the common merge base of Mainline and Release_1.0,
and, even more importantly, there should not have been any merges from
Mainline into Feature_A. So, that branch is not at all what one would
call a feature branch/topic branch. Hopefully, this scenario is very
uncommon :)

I assume you have to deal with the given structure anyhow, and merge
will not help. The only solution is to try and replay your Feature_A
commits on top of the release branch. (Since you have merged Feature_A
into Mainline already, you probabably don't want to redo that branch and
merge.)

I you have many commits to deal with I suggest finding a good
semi-automated way to list the commits you are after, such as git
rev-list --no-merges sha1..Feature_A (with sha1 being the fork point). A
good way to find out could be git log --no-merges sha1..Feature_A.

Then, try and cherry-pick those onto the release branch. Alternatively,
you can use format-patch/am, or in fact try with rebase (I thought it
would ignore merges), which basically does what cherry-pick does.

Cheers,
Michael

  parent reply	other threads:[~2009-11-29 17:02 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-29 16:28 What is the best way to backport a feature? Peter Weseloh
2009-11-29 16:47 ` Björn Steinbrink
2009-11-29 16:52   ` Pascal Obry
     [not found]   ` <4db3b0200911290941j42c5a0aaq2c6a9836b38066b2@mail.gmail.com>
2009-11-29 17:45     ` Fwd: " Peter Weseloh
2009-11-29 18:33       ` Johannes Sixt
2009-11-29 19:03         ` Peter Weseloh
2009-11-29 18:17     ` Björn Steinbrink
2009-11-29 16:49 ` Pascal Obry
2009-11-29 17:02 ` Michael J Gruber [this message]
2009-11-30 19:08   ` Greg A. Woods

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=4B12A928.2000401@drmicha.warpmail.net \
    --to=git@drmicha.warpmail.net \
    --cc=Peter.Weseloh@gmail.com \
    --cc=git@vger.kernel.org \
    /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 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.