views:

104

answers:

2

Migrating from Subversion to Git using svn2git (which internally uses git-svn) I'd like to know how I can find a specific revision commit.

It is quite common to have issues tracker to have comments like: "Fixed in r12345".

Given this, I'd like to be able, for example, to extract the diff corresponding to r12345.

Thanks in advance.

Regards

A: 

With Git it’s similar:

Fixed in d8602bb9729ddb2f28e61028cc5981cb310231a2.

Get the diff with:

git show d8602bb9729ddb2f28e61028cc5981cb310231a2
Bombe
note that you typically only need the first five or so characters of the hash
Matt Briggs
It doesn't tell me at all how I can figure out that svn commit 12345 has been mapped to commit ID: d8602bb9729ddb2f28e61028cc5981cb310231a2 after the migration!Basically I need something like:git show -r12345
Patrick Allaert
You can use `git log -1` to show the commit ID of the latest commit. Feed that ID to `git show`, voilá. To find a specific svn revision in a repository, try `git log --grep=‘@12345’ -p`.
Bombe
+7  A: 

Given the revision number, you can find the Git SHA with

git svn find-rev r1938

I don't know if there's a "one-shot" way to get the commit or anything, but you can write something like

git log -p `git svn find-rev r1938`

Update: note that you can also grab the commit message with

git svn log -r 1938

Update again: note that find-rev also works in reverse:

git svn find-rev c7443021942

returns the SVN commit number.

Will Robertson
This is working on the repository which has been used for the migration. If this repository is going remote, it cannot be used anymore, however it is still possible to get it using: `git log --grep='@12345'`. Can you update your answer with this too?
Patrick Allaert
I think your comment is good enough `:)` I'm not really sure what you mean by "going remote" so I can't help too much more, sorry.
Will Robertson
I mean: if you push the local repository to a remote one. Then only the `git log` method will work.
Patrick Allaert