Incomplete Clone Using Git-Svn - git-svn

I have an Svn repository at http://svn.domain.com/project that is structured as follows:
trunk/
build_file_1.xml
build_file_2.xml
project_root/
branches/
cc2.10/
cc3.00/
..
cc3.5/
jira-labs-39/
tags/
studio-2.10.0.0/
studio-2.10.0.1/
...
studio-3.4.1.0/
I want to clone the trunk and branches, but I'm only getting the trunk and the first branch. I'm using this command to clone:
git svn clone http://svn.domain.com/project working-dir --trunk=trunk --branches=branches --prefix=svn/
What I end up with is this:
$ git br -r
svn/cc2.10
svn/trunk
I need to do some work on one of the other branches, but can't figure out what I'm doing wrong. Can someone point me in the right direction?
UPDATE
I just noticed the following error at the end of the output stream:
merge-base 7c552afeaba8194137acb95e642a2222db801dad c40b790b610dc43da93de5328832b1f852a14ef2: command returned error: 1
I assume that error is aborting the clone before it's complete, but I can't find any reference to the error or what it means in order to debug.

So the problem appears to be in the fact that Git-Svn tries to being cloning from one directory above the requested start point. Using the --no-minimize option fixed that.
git svn clone http://svn.domain.com/project working-dir -s --no-minimize-url

Related

Error when cloning a svn repository using git-svn

I am trying to migrate a SVN repo to a git. For this I am using git-svn tool. I'm running the command:
git svn clone [SVN repo URL] --no-metadata -A authors-transform.txt --stdlayout ~/temp
and I'm getting the following error:
Name does not refer to a filesystem directory: Can’t get entries of non-directory at /Applications/Xcode.app/Contents/Developer/usr/share/git-core/perl/Git/SVN/Ra.pm line 312.”
Line 312 of that script is:
$reporter->finish_report($pool);
So I understand that finish_report is failing, but I don't understand why.
That particular section in perl/Git/SVN/Ra.pm is seven years old and part of the initial split of git-svn.perl
Try instead subgit (in its free version, for a one-shot import): it should be more robust.

Git Submodule fatal reference is not a tree

Hi I am getting fatal: reference is not a tree: 947a3c67349eb242a8d46d576e544f8129b28cbf
Unable to checkout '947a3c67349eb242a8d46d576e544f8129b28cbf' in submodule path 'modules/webform'
My work station is as follows:
[root]:
.gitmodules
/modules/webform
Inside .gitmodules I have:
[submodule "modules/webform"]
path = modules/webform
url = https://git.drupal.org/project/webform.git
I have gone into modules/webform and git pull I have also git submodule sync, which gives me Synchronizing submodule url for 'modules/webform'. I have even hard reset that directory. I was wondering if there is a way to delete that reference/reset to the newest version? when I git log it gives me that the reference is a bad object.
I had to update my git --version. I was on 1.7, the latest is 2.1 or something.

How do I clone a git repo from a local svn repo

I want to learn to use git-svn. I have an svn local repository on my disk that I've checked out a while ago using something like this:
svn co http://myserver.com/mysvnrepo/trunk/ /mysvnrepo/
ls -a /mysvnrepo/
. .. .svn foo bar
This /mysvnrepo/ is HUGE, so I want to avoid re-downloading or copying the files at all costs.
I'm wondering if there's a way to git clone this local repo without downloading / copying anything (because it's already there).
I have this which seems to be what I'm looking for, but when I do that it doesn't quite give me what I expect.
cd /mysvnrepo/
git svn clone file://mysvnrepo/
ls /mysvnrepo/
. .. .git .svn foo bar
git status
# On branch master
#
# Initial commit
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# .svn/
# foo/
# bar/
I would expect git to detect foo and bar as "versioned and up-to-date".
According to the docs it seems that I need to use git svn init because git svn clone runs a fetch, which I certainly don't want. So I tried
git svn init --trunk=file:///mysvnrepo/
...but no luck.
I'm completely new to git, so my confusion is off-the-charts... am I doing something utterly wrong?
Thanks in advance
You cannot take a subversion snapshot and convert it into a git repository.
It sounds like you are trying to avoid a lengthy initialization of the git repository from svn: which ordinarily will try to ready your entire history. This can be done in another way, by limiting the fetch to recent history depending on how much history is relevant to you:
git svn clone -s -r 12334:HEAD https://svn.host.org/repo
Where 12334 is the earliest svn revision you are interested in and assuming that the repo is laid out in a standard svn way with branches and tags.

git-svn: how to change the svn username on dcommit?

I cloned a SVN repository into a git repository using git svn clone. At that point in time, I did not have a username at that site and hence didn't use the --username option of clone. As I can now commit to the SVN repository with my new username, I would like to add that username. Without it, dcommit simply fails:
% LANG=C git svn dcommit
Committing to <THE URL> ...
RA layer request failed: Server sent unexpected return value (405 Method Not Allowed) in response to MKACTIVITY request for '/svn/!svn/act/0ceca4c5-f7b4-4432-94be-0485559a6040' at /usr/lib/git-core/git-svn line 945.
Is there a way to tell git about a new username? The git-svn manual doesn't seem to help: adding a username is only allowed on init and branch. I don't know how git works with SVN internally, but I guess there should be a way to add a username afterwards.
Note that I am using SVN over http.
You can specify the username in the dcommit command, e.g.
git svn dcommit --username=isapir
I think you can use this procedure (from the git svn manpage) to create a clone of your existing svn repository, but change the git svn init step so that it specifies a username. Your new git-svn repository will then have a username.
# Clone locally - make sure the refs/remotes/ space matches the server
mkdir project
cd project
git init
git remote add origin server:/pub/project
git config --replace-all remote.origin.fetch '+refs/remotes/*:refs/remotes/*'
git fetch
# Prevent fetch/pull from remote git server in the future,
# we only want to use git svn for future updates
git config --remove-section remote.origin
# Create a local branch from one of the branches just fetched
git checkout -b master FETCH_HEAD
# Initialize 'git svn' locally (be sure to use the same URL and -T/-b/-t options as were used on server)
git svn init --username my_new_name http://svn.example.com/project
# Pull the latest changes from Subversion
git svn rebase
Note that if you specify a username, you would not be able to dcommit a merge commit, not before Git 2.16.x/2.17 (Q1 2018).
That is because "git svn dcommit" did not take into account the fact that a
svn+ssh:// URL with a username# (typically used for pushing) refers
to the same SVN repository without the username# and failed when
svn.pushmergeinfo option is set.
See commit 8aaed89 (15 Sep 2017) by Jason Merrill (jwmerrill).
(Merged by Jason Merrill -- jwmerrill -- in commit 8aaed89, 17 Sep 2017)
git-svn: fix svn.pushmergeinfo handling of svn+ssh usernames.
Previously, svn dcommit of a merge with svn.pushmergeinfo set would
get error messages like
merge parent <X> for <Y> is on branch svn+ssh://gcc.gnu.org/svn/gcc/trunk,
which is not under the git-svn root svn+ssh://jason#gcc.gnu.org/svn/gcc!"
So, let's call remove_username (as we do for svn info) before comparing
rooturl to branchurl.

How do you view the status of your svn-git repo?

I understand how to initialize a git-svn repo, create a branch, do some work, merge branch, then use git svn rebase and git svn dcommit to push back to the svn repo. But between these two commands, how can you get a status of what is different between the two repos? Something like a git status that tells you that you have x number of files that have been changed.
Just do a diff between your branch and upstream.
git diff --stat git-svn/master..master
Obviously, you'll have to change the branch names to whatever's applicable for your setup.
The only real way I know is to run 'git svn dcommit -n' (or git svn dcommit --dry-run) which will usually give you output like this:
$git svn dcommit --dry-run
Committing to http://yourserver.com/trunk ...
diff-tree bc923cb54847fa340d094c3da1ebd66b8fb0e63e~1 bc923cb54847fa340d094c3da1ebd66b8fb0e63e
diff-tree a05c8be4af7f82dc4de5b4778e2b58203c75eebd~1 a05c8be4af7f82dc4de5b4778e2b58203c75eebd
And then you can 'git show bc923cb54847fa340d094c3da1ebd66b8fb0e63e' to view that diff.