chiark / gitweb /
CVS to git conversion cvs-to-git-conversion
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 5 May 2014 16:07:54 +0000 (17:07 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 5 May 2014 16:07:54 +0000 (17:07 +0100)
Record the scripts etc. we used (and their history) for posterity,
by binding them into the history.

.gitignore [new file with mode: 0644]
convert [new file with mode: 0755]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..b25c15b
--- /dev/null
@@ -0,0 +1 @@
+*~
diff --git a/convert b/convert
new file mode 100755 (executable)
index 0000000..a0f4e8f
--- /dev/null
+++ b/convert
@@ -0,0 +1,134 @@
+#!/bin/sh
+set -ex
+base=$HOME/things/Adns/Cvs-Convert
+cd $base
+tmp=$base/tmp
+
+rm -rf converted
+
+if ! test -d $tmp/git-cvsi; then
+       rm -rf tmp
+       mkdir tmp
+       git cvsimport -d `pwd`/cvs-repo -C tmp/git-cvsi.new -k -p --norc adns
+       mv tmp/git-cvsi.new tmp/git-cvsi
+fi
+cd tmp
+
+rsync -aH --delete git-cvsi/. adjust
+cd adjust
+
+abandonbranch () {
+       local oldbranchname=$1
+       local newtagname=$2
+       git tag $newtagname $oldbranchname
+       git branch -D $oldbranchname
+}
+ensurenotag () {
+       local tagname=$1
+       # these two together unconditionally delete the tag if it exists
+       git tag -f $tagname master
+       git tag -d $tagname
+}
+abandondatedbranch () {
+       local date=$1
+       local olddesc=$2
+       local newdesc=$3
+       if [ "x$newdesc" = x ]; then newdesc=$olddesc; fi
+       abandonbranch branch-$date-$olddesc abandon.$date.$newdesc
+       ensurenotag branchpoint-$date-$olddesc master
+}
+graftmergein () {
+       local desc=$1
+       local mergecommit=$2
+       local branchname=branch-$desc
+       mkdir -p .git/info
+       local branchtip=`git rev-parse $branchname~0`
+       local oldparents=`git log -n1 --pretty=format:%P $mergecommit`
+       cat <<END >>.git/info/grafts
+$2 $oldparents $branchtip
+END
+       git branch -D $branchname
+       ensurenotag mergepoint-$desc
+       ensurenotag branchpoint-$desc
+}
+
+abandonbranch branch-rrtypenoenum abandon.1998-10-04.rrtypenoenum
+abandondatedbranch 1999-04-10 mthread multithread
+abandondatedbranch 1999-04-11 ipv6
+
+abandondatedbranch 2000-05-07 ipv6
+abandonbranch branch-0-7-inftodebug abandon.2000-03-26.infotodebug-0.7
+
+graftmergein logcallbackfn 741a795cdaa539b48f83afbc0ac8e471543b9bf6
+graftmergein 1999-05-09-gplvslgpl e7cf3a99e5829bf53a9f36e08769787a78261045
+graftmergein 1999-04-11-pollfds f889c99835eec14dacda4b18da0636911dcd8cbc
+
+xargs git tag -d <<END
+tochiark-1998-11-08
+fromchiark-1998-11-09
+tochiark-1998-11-09-b
+fromchiark-1998-11-14
+tochiark-1998-11-15
+tochiark-1998-11-17
+fromchiark-1998-11-28
+END
+
+(set -e
+ cd $base/script
+ if [ x"`git diff`" != x ]; then
+       git checkout master~0
+       git commit -a -m autocommit
+       git tag -f actual
+       git reset master
+       git checkout master
+ else
+       git tag -f actual
+ fi)
+
+git checkout master
+git fetch $base/script actual
+git merge -m 'CVS to git conversion
+
+Record the scripts etc. we used (and their history) for posterity,
+by binding them into the history.' FETCH_HEAD
+
+git branch -d origin
+git tag cvs-to-git-conversion
+
+cat >$tmp/msg-filter <<'FEND'
+perl -ne '
+               $out .= $_;
+       END {
+               if ($out =~ /\*\*\* empty log message/) {
+                       ($out = `git diff $ENV{GIT_COMMIT}^ $ENV{GIT_COMMIT} -- changelog`)
+                          =~ s/\A.*\n\@\@ /\@\@ /s;
+               }
+               if ($out !~ /\n.*\n/) {
+                       $out = `fmt <<'\''EOF'\''
+$out
+EOF
+`;
+               }
+               if ($out =~ m/^\@\@/s &&
+                   ($out =~ m/^\+(?!u?adns).*\w.*$/m ||
+                    $out =~ m/^\-(?!u?adns).*\w.*$/m)) {
+                       print $&, "\n\n" or die $!;
+               }
+               print $out or die $!;
+       }
+'
+FEND
+chmod +x $tmp/msg-filter
+
+git filter-branch --msg-filter $tmp/msg-filter \
+       `git show-ref | awk '{print $2}'`
+
+git show-ref | awk '{print $2}' | grep '^refs/original/' \
+       | xargs -n1 git update-ref -d
+
+rm -rf $tmp/converted
+mkdir $tmp/converted
+cd $tmp/converted
+git init
+git fetch -u $tmp/adjust 'refs/*:refs/*'
+git checkout master