diff options
author | Ben Hutchings <ben.hutchings@codethink.co.uk> | 2020-09-15 16:37:26 +0100 |
---|---|---|
committer | Ben Hutchings <ben.hutchings@codethink.co.uk> | 2020-09-15 21:34:37 +0100 |
commit | 90f22c6cf30a6bba768f77117923edb022c7ef39 (patch) | |
tree | 6d07ae50c231edc478d60114efc34dcf1fc0a79b | |
parent | bc8bac5b1915bc6771e916de41deb916447ff879 (diff) | |
download | lorry-90f22c6cf30a6bba768f77117923edb022c7ef39.tar.gz |
lorry: Avoid creating non-bare repository in gitify_svn
Our working repositories should always be initialised as bare, and
this should be done in one place. gitify_svn currently uses "git svn
init", which always creates a non-bare repository, and then modifies
the repository to be bare (though still with core.logallrefupdates
enabled).
Thankfully "git svn init" does very little beyond "git init", so
we can avoid this:
1. Call ensure_gitdir, like other gitify methods do
2. Create the directory svn/refs/remotes/git-svn
3. Set config parameters svn-remote.svn.url (which we already did) and
svn-remote.svn.fetch
-rwxr-xr-x | lorry | 34 |
1 files changed, 16 insertions, 18 deletions
@@ -479,7 +479,7 @@ class Lorry(cliapp.Application): if active_count == 0: # We can't create the repo here because "git cvsimport" - # and "git svn init" insist on doing so themselves + # insists on doing so itself return temp_repo, None, 1 self.copy_gitdir(active_repo, temp_repo) @@ -621,24 +621,22 @@ class Lorry(cliapp.Application): layout = { "trunk": "trunk", "tags": "tags/*", "branches": "branches/*" } - if not os.path.exists(gitdir): - self.progress('.. doing initial clone') - self.needs_aggressive = True - self.run_program(['git', 'svn', 'init', spec['url'], gitdir + "-tmp", - '--svn-remote=svn', '--no-minimize-url']) - os.rename(os.path.join(gitdir + "-tmp", '.git'), gitdir) - os.rmdir(gitdir + "-tmp") - self.run_program(['git', 'config', 'core.bare', 'true'], - cwd=gitdir) - else: - self.progress('.. updating existing clone') - # Force URL to the one in the Lorry spec. This way, if the - # URL in the spec changes, Lorry accepts the change rather - # than using the original one. - self.run_program( - ['git', 'config', 'svn-remote.svn.url', spec['url']], - cwd=gitdir) + # We should not run "git svn init" which creates a non-bare + # repository. Instead, create the directory and extra config + # parameters that it would create. This also ensures that if + # the URL in the spec changes, Lorry accepts the change rather + # than using the original one. + self.needs_aggressive = self.ensure_gitdir(gitdir) + os.makedirs(os.path.join(gitdir, 'svn/refs/remotes/git-svn'), + exist_ok=True) + self.run_program( + ['git', 'config', 'svn-remote.svn.url', spec['url']], + cwd=gitdir) + self.run_program( + ['git', 'config', 'svn-remote.svn.fetch', ':refs/remotes/git-svn'], + cwd=gitdir) + # manually set the refspecs to fetch into local # git-svn can apparently provide better history tracking by # fetching the root of the repository |