tags:

views:

1696

answers:

3

Below svn branches have been added into .git/config file.

[svn-remote "svnb02"]
        url = https://svn/repos/Project/branches/b02
        fetch = :refs/remotes/git-svn-b02
[svn-remote "svnb03"]
        url = https://svn/repos/Project/branches/b03
        fetch = :refs/remotes/git-svn-b03

But only "svnb03" can be fetched using below command:

git svn fetch -R svnb03 -r HEAD

For "svnb02", below command will return quietly without fetching anything.

git svn fetch -R svnb02 -r HEAD

Any commed will be welcome.

+1  A: 

Maybe branch HEAD is not being set. Look at .git/remotes/svnb02/HEAD. If it's missing or not up-to-date, that might account for your problem.

Git has code to find HEAD in this situation, but apparently git svn doesn't; there's a patch in the works about this.

If that's okay, then I'd look for a weird entry to a svn. or remote.svn. variable in the config file or something weird in the .git/remotes directory.

This is all guesswork. A weird situation usually has a weird explanation. Good luck.

EDIT -- I'm assuming that svnb02 had new revisions when you had this problem. Your command is only going to fetch from svn if there are un-fetched revisions.

Paul
Thanks Paul, I was kinda stuck on this one. +1
VonC
Yeah, yesterday I was looking forward to somebody having an answer for this that I could learn from. This feels a little like trying to fix a plumbing problem over the telephone.
Paul
Hi Paul, Many appreciate for you answer. It's very helpful.To clarify the problem, both svnb02 and svnb03 are new revision and came from same trunk. The most confusing thing is svnb03 can be fetched correctly, but svnb02 cannot. I didn't set any HEAD manually, just used "git svn fetch .."
Lei
+1  A: 

Note I am a new user so can only have one hyperlink in my reply. Assume that BASE is "https://svn/repos/Project".

My answer is not directly the cause of this issue but it is closely related and is almost certainly a factor.

The problem is related to the fact that you are treating an SVN branch as the git trunk. I have found that new versions of git (1.6+) don't allow you to check out branches or tags as the git trunk. Git assumes a standard layout. In your case it probably assumes.

trunk - {BASE}/trunk/ branches - {BASE}/branches/ tags - {BASE}/tags/

Since b02 and b03 are children of branches it thinks they are branches and not trunk. In late 1.5.x versions I found that the behaviour is not very consistent but in 1.6.x versions (especially later 1.6.x versions) the behaviour is quite repoducable.

The work around that has worked for me very well is to explicitely declare tags and branches URLS:

git svn init -T {BASE}/branches/b03 -b {BASE}/anydir -t {BASE}/tags git svn fetch -r33666 # where 33666 is the most recent version.

There after I suggest using git svn rebase.

Jesse Eichar
A: 

This occurs if the requested revision (HEAD) is not on the trunk. Our build scripts automatically tag the source after successful build so in my case the last svn revision rarely ever points to the trunk so I get this a lot. The following script will get the last modified revision of the trunk and use that when performing the fetch:


#! /bin/sh
URL=$1
# git-svn fails to pull files if specified revision is not in path specified
# so find the last changed revision and use that
REV=$(svn info ${URL}trunk | grep "Last Changed Rev:" | awk '{print $NF}')
[ -n "$REV" ] || {
  echo "Revision not found. Check URL"
  exit 1
}
git svn init "$URL" -s --prefix svn/
git svn fetch -r $REV
Kurt Harriger