git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Dealing with an upstream cherry-picked branch

From
Jay Soffian <jaysoffian@gmail.com>
Date
Mar 15, 2010, 04:17 UTC
Message-ID
<76718491003142117w4fd10449j51deef27548c4d2e@mail.gmail.com>
I have the following scenario:
  o---o---Ma---o---o    local-master
 /       /
|       | .-b'------d'  upstream-a
|       |/  :       :
o---o---a---b---c---d   upstream-master

Local-master branched from upstream-master in distant past. upstream-master periodically cuts tentative release branch upstream-a. When they do this, that branch point (a) is merged into local-master (Ma).

Over time, upstream applies fixes to upstream-a, but does so by committing the fixes to upstream-master and then cherry-picking them to upstream-a.

The question is how to best integrate the fixes on upstream-a into local-master, w/o causing a headache when upstream cuts the next tentative release branch, at which point upstrea-master will again need to be merged into local-master (and that will also have other local development). Here are two options I've considered:

1) Create a local-a integration branch, merged from upstream-a and
local-master. Keep this branch up-to-date by periodically merging
local-master and upstream-a:
  o---o---Ma---o---o     local-master
 /       /  \       \
|       |    `o------`o  local-a
|       |    /       /
|       | .-b'------d'   upstream-a
|       |/  :       :
o---o---a---b---c---d    upstream-master
2) Periodically merge upstream-a into local-master:
  o---o---Ma--o---o---o  local-master
 /       /   /       /
|       | .-b'------d'   upstream-a
|       |/  :       :
o---o---a---b---c---d    upstream-master
Then when it is next time to merge upstream-master into local-master either:

(a) Backout the upstream-a merges to local-master by reverting the merge commits which introduced them to local-master, then merge upstream-master.

(b) Just merge upstream-master and carefully deal with all the conflicts. I think this will necessarily be an evil merge.

(c) Create a new branch at point Ma and cherry-pick only the local commits from local-master past point Ma. This essentially gives me the clean local-master I would've had if I'd been doing (1) all along.

- Are there any other options I'm missing?
- If I'm going to do (2a), I'm wondering if I'm missing any
subtleties. I've read the revert-a-faulty-merge how-to and I realize
my history won't be the cleanest, but I think it should work and leave
a picture like:
  o---o---Ma--o---o---o---o---Wd'---Wb'---Mi  local-master
 /       /   /       /                   /
|       | .-b'------d' upstream-a       |
|       |/  :       :                   |
o---o---a---b---c---d---e---f---g---h---i    upstream-master

Wd' is the revert of d' into local master. Wb' is the revert of b' into local master. This reverts both merges from upstream-a into local master. There may be conflicts to resolve due to the local changes that happened in local-master. However, local-master should now be "clean" to merge in upstream-master w/o having to worry about conflicts between b and b', d and d'. Correct?

Thanks,
j.
Next: Avery Pennarun
Message 1 of 7 in “Dealing with an upstream cherry-picked branch”
  1. Jay SoffianMar 15, 2010
  2. Avery PennarunMar 15, 2010
  3. Jay SoffianMar 15, 2010
  4. Avery PennarunMar 15, 2010
  5. Junio C HamanoMar 15, 2010
  6. Jay SoffianMar 16, 2010
  7. Junio C HamanoMar 16, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.