merge the script's history into the generated history
[adns] / convert
CommitLineData
8f100340
MW
1#!/bin/sh
2set -ex
3base=$HOME/things/Adns/Cvs-Convert
4cd $base
5tmp=$base/tmp
6
7rm -rf converted
8
9if ! test -d $tmp/git-cvsi; then
10 rm -rf tmp
11 mkdir tmp
12 git cvsimport -d `pwd`/cvs-repo -C tmp/git-cvsi.new -k -p --norc adns
13 mv tmp/git-cvsi.new tmp/git-cvsi
14fi
15cd tmp
16
17rsync -aH --delete git-cvsi/. adjust
18cd adjust
19
20abandonbranch () {
21 local oldbranchname=$1
22 local newtagname=$2
23 git tag $newtagname $oldbranchname
24 git branch -D $oldbranchname
25}
26ensurenotag () {
27 local tagname=$1
28 # these two together unconditionally delete the tag if it exists
29 git tag -f $tagname master
30 git tag -d $tagname
31}
32abandondatedbranch () {
33 local date=$1
34 local olddesc=$2
35 local newdesc=$3
36 if [ "x$newdesc" = x ]; then newdesc=$olddesc; fi
37 abandonbranch branch-$date-$olddesc abandon.$date.$newdesc
38 ensurenotag branchpoint-$date-$olddesc master
39}
40graftmergein () {
41 local desc=$1
42 local mergecommit=$2
43 local branchname=branch-$desc
44 mkdir -p .git/info
45 local branchtip=`git rev-parse $branchname~0`
2a87cbc4 46 local oldparents=`git log -n1 --pretty=format:%P $mergecommit`
8f100340
MW
47 cat <<END >>.git/info/grafts
48$2 $oldparents $branchtip
49END
50 git branch -D $branchname
51 ensurenotag mergepoint-$desc
52 ensurenotag branchpoint-$desc
53}
54
55abandonbranch branch-rrtypenoenum abandon.1998-10-04.rrtypenoenum
56abandondatedbranch 1999-04-10 mthread multithread
57abandondatedbranch 1999-04-11 ipv6
58
59abandondatedbranch 2000-05-07 ipv6
60abandonbranch branch-0-7-inftodebug abandon.2000-03-26.infotodebug-0.7
61
62graftmergein logcallbackfn 741a795cdaa539b48f83afbc0ac8e471543b9bf6
63graftmergein 1999-05-09-gplvslgpl e7cf3a99e5829bf53a9f36e08769787a78261045
64graftmergein 1999-04-11-pollfds f889c99835eec14dacda4b18da0636911dcd8cbc
65
66xargs git tag -d <<END
67tochiark-1998-11-08
68fromchiark-1998-11-09
69tochiark-1998-11-09-b
70fromchiark-1998-11-14
71tochiark-1998-11-15
72tochiark-1998-11-17
73fromchiark-1998-11-28
74END
75
4631609f
IJ
76(set -e
77 cd $base/script
78 if [ x"`git diff`" != x ]; then
79 git checkout master~0
80 git commit -a -m autocommit
81 git tag -f actual
82 git reset master
83 git checkout master
84 fi)
8f100340 85
4631609f
IJ
86git checkout master
87git fetch $base/script actual
88git merge -m 'CVS to git conversion
8f100340 89
4631609f
IJ
90Record the scripts etc. we used (and their history) for posterity,
91by binding them into the history.' FETCH_HEAD
8f100340
MW
92
93git branch -d origin
94git tag cvs-to-git-conversion
95
96cat >$tmp/msg-filter <<'FEND'
97perl -ne '
98 $out .= $_;
99 END {
53057d8c
MW
100 if ($out =~ /\*\*\* empty log message/) {
101 ($out = `git diff $ENV{GIT_COMMIT}^ $ENV{GIT_COMMIT} -- changelog`)
102 =~ s/\A.*\n\@\@ /\@\@ /s;
103 }
f1ec69ce
MW
104 if ($out !~ /\n.*\n/) {
105 $out = `fmt <<'\''EOF'\''
106$out
107EOF
108`;
109 }
8f100340 110 if ($out =~ m/^\@\@/s &&
95360dba
MW
111 ($out =~ m/^\+(?!u?adns).*\w.*$/m ||
112 $out =~ m/^\-(?!u?adns).*\w.*$/m)) {
8f100340
MW
113 print $&, "\n\n" or die $!;
114 }
115 print $out or die $!;
116 }
117'
118FEND
119chmod +x $tmp/msg-filter
120
2a87cbc4
MW
121git filter-branch --msg-filter $tmp/msg-filter \
122 `git show-ref | awk '{print $2}'`
8f100340 123
2a87cbc4
MW
124git show-ref | awk '{print $2}' | grep '^refs/original/' \
125 | xargs -n1 git update-ref -d
8f100340
MW
126
127rm -rf $tmp/converted
128mkdir $tmp/converted
129cd $tmp/converted
130git init
131git fetch -u $tmp/adjust 'refs/*:refs/*'
132git checkout master