I’m trying to modify my bash prompt to print out if I’m in a git-svn repo. I see that git svn repos have a .git/svn folder, so I could check with:
# Find the top level git folder
_git_dir=`git rev-parse --show-toplevel 2> /dev/null`
# Find svn folder
_gsvn_check=`cd $_git_dir; ls .git/svn 2> /dev/null`
But then I noticed that my normal git repo has a .git/svn folder. Is there any way to know for sure that you’re in git-svn?
The
.git/svndirectory can be created if you run anygit svncommand in any repository – e.g. just runninggit svn info, as Carl Norum suggests will create it. However, a slightly better test might be that.git/svnexists and is non-empty, e.g.If you want a stricter test, you could look through the history of
HEADfor any commit messages that contain agit-svn-id– essentially that’s whatgit svn infois doing before it gives up. For example:… but it sounds as if that might be too slow for your use case.
The source code in
git-svn.perldescribes the layout of agit-svnrepository in its different versions:… so you could write tests for all of those if you want to be careful to catch all the different versions.