lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] Converting a proprietary svn repository to git


From: Greg Chicares
Subject: Re: [lmi] Converting a proprietary svn repository to git
Date: Tue, 1 Mar 2016 16:17:17 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.5.0

On 2016-02-29 17:28, Vadim Zeitlin wrote:
> On Mon, 29 Feb 2016 16:58:42 +0000 Greg Chicares <address@hidden> wrote:
[...]
> GC> I think I've found the point where it fails, but why is 'origin/'
> GC> prepended to 'trunk' on Cygwin, and what's the right way to fix it?
> 
>  The way to fix it is to use --prefix "" (I'm not sure if it's supported
> by the old version however, it could be, but I didn't test it) but, again,
> it might be better to just explicitly use something like --prefix=svn for
> both the new and old versions and update the script accordingly.

With this old version, 'git help svn' says '--prefix' is supported, so I
specified '--prefix="origin/"' because that's the default for more recent
'git' versions. Now, the migration succeeds on both Cygwin and GNU/Linux
with the script pasted below [0] for reference.

There is one imperfection: in the final step, I had to specify the branch:
  git clone -b master file:///tmp/migration/blessed/proprietary
            ^^^^^^^^^
Without it, the command above gives:
  remote HEAD refers to nonexistent ref, unable to checkout
I thought 'clone' was normally expected to work without specifying a branch,
so this seems kind of wrong. Or is it merely untidy? The most common advice,
here, e.g.:
  
https://help.github.com/articles/error-remote-head-refers-to-nonexistent-ref-unable-to-checkout/
  
http://stackoverflow.com/questions/11893678/warning-remote-head-refers-to-nonexistent-ref-unable-to-checkout
seems to be to do 'git checkout' on the original that's being cloned from.
But that's a "blessed" bare repository that I'm trying to keep bare, so I
don't want to check out a working copy there.

In case it helps, I've listed the repository's contents [1] including the
contents of the 'HEAD' and 'master' files.

---------

[0] "the script pasted below"

-------------------------------------8<-------------------------------------
#!/bin/bash

# migrate a particular svn repository to git

set -v

# edit the next line to set insurer's domain
export CompanyDomain="REDACTED.com"
[ "REDACTED.com" != "$CompanyDomain" ] || { echo "YOU WERE SUPPOSED TO 
CUSTOMIZE THAT"; exit 8; }

# make sure the svn tarball is in /tmp
[ -f "/tmp/repository-20160212T2239Z.tar.bz2" ] || { echo "SVN TARBALL NOT 
FOUND"; exit 9; }

uname -a
git --version
svn --version |head -1

# do everything in a fresh subdir of /tmp just to see if it all works
rm -rf /tmp/migration
mkdir --parents /tmp/migration
cd /tmp/migration

# unpack svn tarball and verify it
tar -xjvf /tmp/repository-20160212T2239Z.tar.bz2
svnadmin verify repository

# check out an svn working copy...
mkdir --parents svn_working_copy
pushd svn_working_copy
svn checkout \
  file:///tmp/migration/repository
popd

# ...for the sole purpose of extracting authors
pushd svn_working_copy/repository
svn log --xml \
  | grep author | sort -u \
  | sed -e "s/^[^>]*>\([^<]*\)<[^<]*$/\1 = \1 <address@hidden>/" \
  >/tmp/migration/authors.txt
popd

# create a transitional git clone of the svn repository
# [GNU/Linux: 2 min; msw-xp: 41 min]
git svn clone \
  file:///tmp/migration/repository \
  --authors-file=/tmp/migration/authors.txt \
  --prefix="origin/" --no-metadata --trunk=/ ./transitional
# list remote branches, and all branches
pushd /tmp/migration/transitional
git rev-parse HEAD
git branch -r
git branch -a
popd

# create new bare repository
mkdir blessed
pushd blessed
git init --bare ./proprietary
pushd proprietary
git symbolic-ref HEAD refs/heads/trunk
git rev-parse HEAD
popd
popd

# push to bare repository
pushd /tmp/migration/transitional
git remote add bare /tmp/migration/blessed/proprietary
git config remote.bare.push 'refs/remotes/*:refs/heads/*'
git push bare
popd

# rename 'trunk' to 'master'
pushd /tmp/migration/blessed/proprietary
git branch -m origin/trunk master
popd

# clone from bare repository
mkdir --parents migrated
pushd migrated
git clone -b master file:///tmp/migration/blessed/proprietary
pushd proprietary
git rev-parse HEAD
popd
popd

-------------------------------------8<-------------------------------------

[1] "listed the repository's contents" (the "master" sha1sum is correct):

/home/greg/tainted/migration[0]$cat 
/tmp/migration/blessed/proprietary/refs/heads/master
b5f2b3d4cfd179bbe4ac433d5bbe86d922bec2dc
/home/greg/tainted/migration[0]$cat /tmp/migration/blessed/proprietary/HEAD
ref: refs/heads/trunk
/home/greg/tainted/migration[0]$ls -lR /tmp/migration/blessed
/tmp/migration/blessed:
total 4
drwxr-xr-x 7 greg greg 4096 Feb 29 23:54 proprietary

/tmp/migration/blessed/proprietary:
total 32
-rw-r--r-- 1 greg greg   22 Feb 29 23:53 HEAD
drwxr-xr-x 2 greg greg 4096 Feb 29 23:53 branches
-rw-r--r-- 1 greg greg   66 Feb 29 23:54 config
-rw-r--r-- 1 greg greg   73 Feb 29 23:53 description
drwxr-xr-x 2 greg greg 4096 Feb 29 23:53 hooks
drwxr-xr-x 2 greg greg 4096 Feb 29 23:53 info
drwxr-xr-x 4 greg greg 4096 Feb 29 23:53 objects
drwxr-xr-x 4 greg greg 4096 Feb 29 23:53 refs

/tmp/migration/blessed/proprietary/branches:
total 0

/tmp/migration/blessed/proprietary/hooks:
total 36
-rwxr-xr-x 1 greg greg  452 Feb 29 23:53 applypatch-msg.sample
-rwxr-xr-x 1 greg greg  896 Feb 29 23:53 commit-msg.sample
-rwxr-xr-x 1 greg greg  189 Feb 29 23:53 post-update.sample
-rwxr-xr-x 1 greg greg  398 Feb 29 23:53 pre-applypatch.sample
-rwxr-xr-x 1 greg greg 1704 Feb 29 23:53 pre-commit.sample
-rwxr-xr-x 1 greg greg 4898 Feb 29 23:53 pre-rebase.sample
-rwxr-xr-x 1 greg greg 1239 Feb 29 23:53 prepare-commit-msg.sample
-rwxr-xr-x 1 greg greg 3611 Feb 29 23:53 update.sample

/tmp/migration/blessed/proprietary/info:
total 4
-rw-r--r-- 1 greg greg 240 Feb 29 23:53 exclude

/tmp/migration/blessed/proprietary/objects:
total 8
drwxr-xr-x 2 greg greg 4096 Feb 29 23:53 info
drwxr-xr-x 2 greg greg 4096 Feb 29 23:54 pack

/tmp/migration/blessed/proprietary/objects/info:
total 0

/tmp/migration/blessed/proprietary/objects/pack:
total 2604
-r--r--r-- 1 greg greg  195336 Feb 29 23:54 
pack-51943388f47c7909679ffcc5746907c5669f44e1.idx
-r--r--r-- 1 greg greg 2468370 Feb 29 23:54 
pack-51943388f47c7909679ffcc5746907c5669f44e1.pack

/tmp/migration/blessed/proprietary/refs:
total 8
drwxr-xr-x 3 greg greg 4096 Feb 29 23:54 heads
drwxr-xr-x 2 greg greg 4096 Feb 29 23:53 tags

/tmp/migration/blessed/proprietary/refs/heads:
total 8
-rw-r--r-- 1 greg greg   41 Feb 29 23:54 master
drwxr-xr-x 2 greg greg 4096 Feb 29 23:54 origin

/tmp/migration/blessed/proprietary/refs/heads/origin:
total 0

/tmp/migration/blessed/proprietary/refs/tags:
total 0
/home/greg/tainted/migration[0]$




reply via email to

[Prev in Thread] Current Thread [Next in Thread]