7

When using git-svn, Git associates SVN revision with individual commits.

Most of other team members quote SVN revisions when they want their code reviewed. Is it possible to some how make Git 'aware' of the SVN revisions and implicitly convert them to Git hashes? Or perhaps is there a way to expose the mapping between Git commits and SVN revisions, so that I can write myself a tool that could leverage that?

Ideally I would like to do something like:

$ git diff r12000 e0a4f09 # r12000 is SVN revision, e0a4f09 is Git hash
sneg
  • 2,088
  • 4
  • 19
  • 23
  • This is similar to this other question: http://stackoverflow.com/q/7599707/223092 if not a duplicate. – Mark Longair Oct 28 '11 at 09:54
  • Hoping that this will be useful to somebody. As you are using git svn, you would have created an svn remote of that repository to fetch the revisions, right ? git checkout remotes/ git svn log --show-commit --oneline Refer my answer from [here](http://stackoverflow.com/a/39653616/4328594). Correct me if something's not right. – Jaimin Ajmeri Sep 29 '16 at 04:41

1 Answers1

15

The git-svn tool has a conversion option to find the git object if by a SVN revision, or the other way around. This option can be used as follows:

git svn find-rev rSVNID

Thus, your diff command could be:

git diff $(git svn find-rev r12000) e0a4f09

As opposed to the other answer, this should also work with branches and tags.

For further information, see the manpage of git-svn on this command.

Legolas
  • 1,432
  • 10
  • 11