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

Stitching histories of several repositories

From
Ramkumar Ramachandra <artagnon@gmail.com>
Date
Dec 1, 2012, 09:11 UTC
Message-ID
<CALkWK0kCQQioCeuwWAAWfKodvOR+w+hB=11MYs5mGviN6Zy5qA@mail.gmail.com>
Hi,

I've written a tool to stitch the first-parent histories of several git repositories. To illustrate, consider that we have a toplevel git repository inside which the other repositories reside.

  /.git
  /a/.git
  /b/.git

The tool pulls in the objects from /a/.git and /b/.git into /.git by using alternates. Then, it gets the list of commits by rev-list'ing and emits a fast-import stream rewriting the paths of the files in a/ from / to a/ and the paths of files in b/ form / to b/ (using M 040000), taking care to have one unified first-parent line. It turns out that this is quite non-trivial when the individual git repositories contain lots of merges. To illustrate, this is an example of how histories from two repositories with one merge commit each would be stitched:

  *   c1f81f1 (refs/figlets/first/origin/master)
  |\
  | * 6eaf22f (refs/figlets/first-2/origin/master)
  * 15cd841
  *   1f2f408 (refs/figlets/second/origin/master)
  |\
  | * 4bd7fe3 (refs/figlets/second-2/origin/master)
  * bfa9f3c
  *   5e1d337 (refs/replay/stitch2, fig/stitch2)
  |\
  | * 23437d5 (refs/replay/1f2f40-2)
  |/
  *   4f2d70b
  |\
  | * e017fa5 (refs/replay/c1f81f-2)
  * c0251c7
  * 4036fea

I'd like to know whether the tool would be useful to a wider audience, before I polish it and consider submitting it for inclusion in contrib/. I think the tool is especially useful for running bisect and tracking bugs that occur in large projects that consist of many git repositories. Will a unified log showing commits in different submodules be useful?

Ram
Next: Robin Rosenberg
Message 1 of 2 in “Stitching histories of several repositories”
  1. Ramkumar RamachandraDec 1, 2012
  2. Robin RosenbergDec 6, 2012

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.