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

Re: Migrating SVN to Git, and preserve merge information

From
Nick Douma <n.douma@nekoconeko.nl>
Date
Apr 11, 2012, 07:24 UTC
Message-ID
<4F8531B3.9030501@nekoconeko.nl>
In-Reply-To
<4F84BAE2.5090803@pileofstuff.org>
Hi Andrew,
On 11-04-12 00:57, Andrew Sayers wrote:
> Would I be right in thinking that a commit like "Merged r100,r101,r102
> from trunk" will create three grafts?  If so, that might be the problem.

One SVN 'merge' commit will generate one graft. The graft itself will contain all revisions mentioned in the merge commit, and whatever the original git parent was before the graft.

Show 8 quoted lines
> Git differentiates between "merges" (which include every commit up to
> and including the specified one) and "cherry-picks" (which just include
> the specified commit), whereas SVN calls both of these "merges".  Grafts
> are a way of creating "merges" rather than "cherry-picks" (which git
> doesn't have any metadata for), and it's not at all easy to get "merge"
> data out of SVN in the general case.  Having said that, it's often a
> good enough heuristic to pick the highest revision number mentioned in
> the commit message and pretend it's a merge.

The way we 'merged' in SVN was indeed more like cherry-picking, but I'm looking to display this information as a merge in Git. I also would like to include all revisions if possible.

The real problem I seem to be having is not completely understanding how Git grafts work, because I think I'm hitting some kind of limitation or bug, or just not using it right.

Show 6 quoted lines
> Incidentally, I'm planning to work on this area of SVN->git conversion
> in the coming months.  I don't have anything you could use yet, but I
> don't suppose the scripts you used are available somewhere?  Getting
> revision information out of log files is particularly tricky, and
> everyone stumbles over a different set of issues.  I'd be really
> interested to pick any nuggets of wisdom out of the approach you took.

I don't really have any useful script for you at the moment, but the main approach is this:

* I first tag all SVN Git commits with the original SVN revision, like:
"svn/1234"
* Then I retrieve all commits with "merge" in the message, but not "unmerge"
* Now I filter all revisions from the commit message using a regex or two.
* Using all relevant revisions, I retrieve the corresponding SHA hashes
using the tag names I created in step 1.
* Finally, I write a graft file in format:
<merge commit> <original git parent> <merge rev 1> ... <merge rev n>
Kind regards,
Nick Douma
Previous: Andrew SayersNext: Santi Béjar
Message 3 of 5 in “Migrating SVN to Git, and preserve merge information”
  1. Nick DoumaApr 10, 2012
  2. Andrew SayersApr 10, 2012
  3. Nick DoumaApr 11, 2012
  4. Santi BéjarApr 11, 2012
  5. Andrew SayersApr 11, 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.