Skip to main content
Glimpses of Daniel's world

Getting a diff between two commits with git-svn when you only know the subversion revisions

Given you have the need for git and prefer to use it as your personal SCM for everything, but some projects will not switch from Subversion just because of you. Then how would you get a diff for a file when you only know the subversion revision numbers?

The current version of git installed on my laptop is 1.7.5.4. So far I was unable to find a way for git-svn to give me what I need, although I did find some useful information. At least useful is the fact that

bash
log --show-commit -r <rev> --oneline | awk '{print $3}'
bash
log --show-commit -r <rev> --oneline | awk '{print $3}'

Will show the git commit for revision .

Knowing this, that led to me writing this small script, which will get you a diff between two commits of which you only know the subversion revisions.

bash
#!/bin/sh
r2hash () {
git svn log --show-commit -r $1 --oneline | awk '{print $3}'
}
git diff `r2hash $1` `r2hash $2` -- $3
bash
#!/bin/sh
r2hash () {
git svn log --show-commit -r $1 --oneline | awk '{print $3}'
}
git diff `r2hash $1` `r2hash $2` -- $3