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

Re: Inheritance of files for parent/child branches

From
Jeff King <peff@peff.net>
Date
Feb 16, 2008, 18:09 UTC
Message-ID
<20080216180903.GB19506@sigill.intra.peff.net>
In-Reply-To
<alpine.DEB.1.00.0802161110310.32252@an.sumeria>
On Sat, Feb 16, 2008 at 11:32:01AM -0600, Adam Flott wrote:
Show 11 quoted lines
> The only redeeming feature in AccuRev was the ability to an use
> inheritance for files in streams (nearly analogous to branches). While
> this idea in the SCM world sounds strange, is there anything in git land
> that could mimic this sort of behavior?
>
> In case, "inheritance for files..." isn't clear, what I would like to
> accomplish is: have a branch "parent" with multiple "children" branches
> (which may have descendents of their own). If a file is committed to the
> parent branch, then the all the descendents would receive the same
> update without manually cherry-picking the commit across all the
> branches.

Wouldn't that just be a merge of the parent branch into the child branch? Which really isn't any different than cherry-picking, except that you retain the history instead of picking the one patch. In both cases, you are saying "take the differences in the parent tree between point X and point Y, and merge them into what I have now." In the case of cherry pick, you are saying that X is really Y^. In the case of a merge, you are saying that X is "the last point parent and child merged" (.e., git merge-base parent child).

It won't happen _automatically_, though, and I don't think it should (since each merge may have conflicts). But you could probably accomplish what you want by cascading the merges. Something like:

  git checkout parent
  hack hack hack
  git commit -a -m whatever
  cascade_merge() {
    parent=$1
    for child in `somehow lookup the child branches of $parent`
    do
      git checkout $child
      git merge $parent
      cascade_merge $child
    done
  }
  cascade merge parent

This snippet is illustrative, not functional; recursion in the shell will stomp on the variables. But more importantly, the "git merge" may actually require human intervention. So you need to stop, let the user fix up the working tree, and then continue.

-Peff
Previous: Adam FlottNext: Adam Flott
Message 2 of 4 in “Inheritance of files for parent/child branches”
  1. Adam FlottFeb 16, 2008
  2. Jeff KingFeb 16, 2008
  3. Adam FlottFeb 16, 2008
  4. Jeff KingFeb 16, 2008

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.