Re: Using git svn rebase at quarantine environment or a feasible alternative to synchronize git and svn repositories
- Date: Mon, 1 Oct 2018 10:53:44 -0400
- From: Jeff King <peff@xxxxxxxx>
- Subject: Re: Using git svn rebase at quarantine environment or a feasible alternative to synchronize git and svn repositories
On Mon, Oct 01, 2018 at 08:12:49AM +0000, Jose Gisbert wrote:
> My proposal consists to import the svn repository to git using git svn and set
> receive.denyCurrentBranch to updateInstead. Then install pre-receive and
> post-receive hooks and set that repository as the central repository for git
> The pre-receive hook does git svn rebase and, if there is an update at the svn
> repository, rejects the push and instructs the user to do git pull. The
> post-receive hook does git svn dcommit to update the state of the svn
> repository, then instructs the user to do git pull too.
> However I'm stuck at this point because the pre-receive hook it's not allowed
> to do git svn rebase because update refs are not allowed at the quarantine
> environment. I was sure that I tried this solution with a past version of git
> and it worked, but now I doubt this because the restriction to update refs at
> quarantine environment was delivered at version 2.13, that dates from April
> 2017, if I'm not wrong.
As you noticed, this used to be allowed. But it's dangerous, because if
the movement of the objects out of quarantine fails, then you're left
with a corrupted ref (ditto, anybody looking at the ref after update but
before quarantine ends will see what appears to be a corrupted
There are two solutions I can think of:
1. The unsafe thing is to just unset $GIT_QUARANTINE_PATH before
running "git svn rebase". That will skip the safety check
completely, enabling the pre-v2.13 behavior. I don't really
recommend this, but modulo the race and unlikely file-moving
errors, it would probably generally work.
2. Store intermediate results from pre-receive not as actual refs, and
then install the refs as part of the post-receive. I don't think
there's out of the box support for this, since "git svn rebase" is
always going to call "git rebase", which is going to try to write
The smoothest thing would be for the refs code to see that
$GIT_QUARANTINE_PATH is set, write a journal of ref updates into a
file in that path, and then have the quarantine code try to apply
those ref updates immediately after moving the objects out of
quarantine (with the usual lease-locking mechanism).
That's likely to be pretty tricky to implement, so I'm not even
going to try to sketch out a patch in this email.
You might be able to do something similar by hand by using a
temporary sub-repository. E.g., "clone -s" to a temp repo, do the
rebase there, and then in the post-receive fetch the refs back.
That's less efficient, but the boundaries of the operation are very
easy to understand.
> I come here asking for help because I think this is the appropriate place to
> do so. I apologise if this is not the case. Any help is welcome. If anything
> needs to be clarified, please, ask me to do so. I can share with you the
> source code of the hook scripts, if necessary.
This is definitely the right place. Sorry I don't have a better answer!