Map of all svn revision numbers <=> git SHA-1 c

2019-02-26 02:48发布

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?

3条回答
叼着烟拽天下
2楼-- · 2019-02-26 03:13

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.

查看更多
可以哭但决不认输i
3楼-- · 2019-02-26 03:15

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"
查看更多
孤傲高冷的网名
4楼-- · 2019-02-26 03:18

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.

查看更多
登录 后发表回答