2

When git-svn needs to rebuild its internal map, it outputs the wanted information to STDERR:

Rebuilding .git/svn/refs/remotes/origin/trunk/.rev_map.XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
r38601 = 28d3a624c5c96db9a1f45d8f261a9b0de1f6f288
r38652 = 74c55b8dff798e5ae1bc2ad00d8ec6eee4f2646b
r38744 = eb457e1949ecf854816ba9cf64b4bace710a7302
r38745 = 5bca99a37fbc6db72d2d50a75301185f4297926c
(...)

The file .git/svn/refs/remotes/origin/trunk/.rev_map.XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX is unfortunately binary, thus can't be parsed easily. Is there a way to have git-svn output the above information by a specific command? I'm on git 2.7.0, by the way.

Edit: I'm aware of git svn find-rev, but this will only allow me to find out the SHA-1 commit hash of a single revision and I have to provide a specific SVN revision. What I would like to get, though, is the mapping of all revisions. Preferably without brute-forcing my way through or using an external datasource (the SVN repo, namely) to provide SVN revisions as input. Most preferably, without providing anything, as this information is stored in the repository after git-svn has built its revision map - or is it not?

zb226
  • 9,586
  • 6
  • 49
  • 79

3 Answers3

6

Fetch all SVN revisions:

git config --add svn-remote.<Remote>.url <SVN URL>
git config --add svn-remote.<Remote>.fetch :refs/remotes/<Remote Name>
git svn fetch <Remote>

Map revision numbers <=> git SHA-1:

git checkout remotes/<Remote Name>
git svn log --show-commit --oneline

Output:

r50 | 77c9acf | "SVN Commit message"
...
r1 | 84e6c49 | "SVN Commit message"
Jaimin Ajmeri
  • 572
  • 3
  • 18
  • Excellent. Just note that the `git-svn` setup isn't really needed to answer this question. But it also does not hurt :) – zb226 Sep 29 '16 at 14:58
1

Get a list of all hashes (or revisions) and use git svn find-rev XXX in cycle.

When given an SVN revision number of the form rN, returns the corresponding Git commit hash (this can optionally be followed by a tree-ish to specify which branch should be searched). When given a tree-ish, returns the corresponding SVN revision number.

zb226
  • 9,586
  • 6
  • 49
  • 79
Lazy Badger
  • 94,711
  • 9
  • 78
  • 110
1

There might be a better way if you check the internals of the git-svn, but if nothing more convenient you have the mapping in the log messages in the form of

git-svn-id: http://svn.host/path/trunk@<SVN_REVISION> <SVN_REPO_GUID>

so potentially you could go through the revisions you are interested in and parse the mapping from the last line of the log.

Mykola Gurov
  • 8,517
  • 4
  • 29
  • 27
  • Thanks for your answer, going through the log like this is also a basic solution for the problem (provided that `--no-metadata` wasn't used on `git svn clone`), but as I stated in the edit, I still think this might/should be achieved in an easier way, so I'm leaving this question open for now. – zb226 Feb 22 '16 at 09:31