Jed SVN to GIT

Jörg Sommer joerg at alea.gnuu.de
Sat Dec 15 15:56:12 UTC 2007


Hallo Rafael,

Rafael Laboissiere schrieb am Sat 08. Dec, 18:35 (+0100):
> * Jörg Sommer <joerg at alea.gnuu.de> [2007-12-08 17:10]:
> 
> > what do you think about moving the SVN repository to GIT? I only speak of
> > /jed/.
> > 
> > I would also migrate /tmexpand/ to GIT.
> 
> I have nothing against git but have never used it myself.  I would say yes
> for this move, provided that you can add a git tutorial in the DJG
> Guidelines document (this would help me a lot in getting started with git).

Importing the history from SVN wasn't as easy as I thought. We had the
big renaming in r337 which confuses git. I used the appended script to do
the import. I did a little beautifying of the history, because some tags
became edited and some tags became created with svn add (instead of svn
cp)

And I found we have no tag for 0.99.18+dfsg.1-9.

Install the packages git-core, git-doc, gitk.

At first you can do (this is like svn co)
% git clone ssh://alioth.debian.org/\~/public_git/jed.git jed
% cd jed

You can browse the history and see all tags and branches with
% gitk --all

Then you *must* tell git your name and your email address:
% git config --global user.name "Your Name Comes Here"
% git config --global user.email you at yourdomain.example.com

To get familiar with git I suggest to read:
file:///usr/share/doc/git-doc/tutorial.html
file:///usr/share/doc/git-doc/everyday.html

You can read both in 30 minutes. Much more is explained in
file:///usr/share/doc/git-doc/user-manual.html

Bye, Jörg.

#!/bin/sh

set -e

if ! [ -e authors ]; then
    cat > authors <<__EOF
jo-guest = Jörg Sommer <joerg at alea.gnuu.de>
milde-guest = Günter Milde <g.milde at web.de>
rafael = Rafael Laboissiere <rafael at debian.org>
__EOF
fi

git svn init --trunk=trunk/packages/jed --tags=tags/packages/jed \
  --no-metadata --prefix=pre/ svn://svn.debian.org/svn/pkg-jed

git svn fetch --quiet --authors-file=authors --revision=1:336

git config svn-remote.svn.fetch jed/trunk:refs/remotes/post/trunk
git config svn-remote.svn.branches 'jed/branches/*:refs/remotes/post/*'
git config svn-remote.svn.tags 'jed/tags/*:refs/remotes/tags/post/*'

git svn fetch --quiet --authors-file=authors --revision=338:HEAD

# Remove the import stuff
rm authors
git config --remove-section svn-remote.svn
rm -r .git/svn

echo "Debian packaging of JED" > .git/description

##
#  Now, let's start with cleanup of the history
##
git reset --hard

# Create a git tag from the svn "tag"
for t in $(git branch -a | grep tags); do
    if git diff --exit-code --quiet $t..$t~1; then
        git tag ${t##*/} $t~1 && git branch -d -r $t
    fi
done

##
#  Clean up the history before the movment
##

echo cleanup pre...

# pre/tags/0.99.16-4 is not the successor of the tagged version
git tag 0.99.16-4 2aae6c98c321dd3a0a2011f5684fe7af2924649f
git branch -d -r pre/tags/0.99.16-4

# This svn tag was modified
git tag 0.99.16-5 0eac6a3eb5e50ea1c243e9ac69d1b6eed33568d3

# Remove the first commit and other empty commits
git filter-branch -d /tmp/aaa \
  --commit-filter \
    'if [ $3 = '$(git rev-parse 0.99.16-4~1)' ]; then
      git commit-tree $1;
    elif git diff-tree --exit-code --quiet $1 $(git cat-file commit $3 | sed "s/tree //;q"); then
      map $3;
    else git commit-tree "$@"; fi' \
  --tag-name-filter cat 0.99.16-4~1..pre/trunk
rm .git/refs/original/refs/remotes/pre/trunk

# The tag 0.99.16-5 was used to create the tag 0.99.16-5.1
git branch tmp pre/tags/0.99.16-5~1
git filter-branch --parent-filter "echo -p $(git rev-parse 0.99.16-5)" \
  tmp~1..tmp
rm .git/refs/original/refs/heads/tmp
git tag 0.99.16-5.1 tmp
git branch -d -r pre/tags/0.99.16-5
git branch -D tmp

git branch tmp pre/tags/0.99.16-6
git filter-branch --parent-filter "echo -p $(git rev-parse 0.99.16-5.1)" tmp
rm .git/refs/original/refs/heads/tmp
git branch -d -r pre/tags/0.99.16-6
git tag 0.99.16-6 tmp
git branch -D tmp

# This branch is completly wrong. I don't know where git got it from.
git branch -d -r pre/tags/0.99.16-5.1

# The 0.99.16 branch was merged in two steps (control in
# 0.99.16.pre.0.99.17.84-1~1 and changelog in th fifth commit after
# 0.99.17.135-1)in  so it's not possible to do a git merge

##
#  Clean up the master branch
##
# Do it before etch, because etch forkes this branch

echo Clean up master...

# This is needed later.
git tag etch-point tags/post/0.99.18-8~2

git checkout master
git reset --hard post/trunk
git branch -d -r post/trunk

# Bind the branch on pre/trunk and remove empty commits
git filter-branch -d /tmp/aaa \
  --commit-filter 'if [ $# -eq 1 ]; then
      git commit-tree $1 -p '$(git rev-parse pre/trunk)';
    elif git diff-tree --exit-code --quiet $1 $(git cat-file commit $3 | sed "s/tree //;q"); then
      map $3;
    else git commit-tree "$@"; fi' \
  --tag-name-filter cat master
rm .git/refs/original/refs/heads/master

# This tag is missing in svn
git tag 1%3A0.99.18+dfsg.1-9 master~5

##
#  Clean up the etch brunch
##

echo clean up etch...

# Fix the tags
git tag 0.99.18-8.etch.3 remotes/post/etch~3
git branch -d -r tags/post/0.99.18-8.etch.3

git tag 0.99.18-8.etch.4 remotes/post/etch~2
git branch -d -r tags/post/0.99.18-8.etch.4

git branch tmp tags/post/0.99.18-8
git filter-branch --parent-filter "echo -p $(git rev-parse etch-point)" tmp~1..tmp
rm .git/refs/original/refs/heads/tmp
git branch -d -r tags/post/0.99.18-8

git tag -d etch-point

# This tag is missing.
git tag 0.99.18-8 tmp

git branch etch remotes/post/etch

# remove the first commit (it's empty) and bind the branch on tmp
git filter-branch --parent-filter 'read line;
  if [ "x$line" = "x-p '$(git rev-parse etch~6)'" ]; then
     echo -p '$(git rev-parse tmp)';
  else echo "$line"; fi' \
  --tag-name-filter cat heads/etch~6..heads/etch
rm .git/refs/original/refs/heads/etch
git branch -d -r post/etch
git branch -D tmp

# There are empty commits in this branch
git branch tmp remotes/tags/post/0.99.18-8.etch.1
git filter-branch --parent-filter "echo -p $(git rev-parse 0.99.18-8~1)" \
  tmp~1..tmp
rm .git/refs/original/refs/heads/tmp
git branch -d -r tags/post/0.99.18-8.etch.1

git tag 0.99.18-8.etch.1 tmp
git branch -D tmp

##
#  Clean up the 0.99.19 branch
##

echo Clean up 0.99.19...

# Remove the last two commits from these where mistakes
git branch 0.99.19 post/0.99.19~2
git branch -d -r post/0.99.19

# Bind the branch on pre/trunk and remove empty commits
git filter-branch -d /tmp/aaa \
  --commit-filter \
    'if [ $# -eq 1 ]; then
      git commit-tree $1 -p '$(git rev-parse pre/trunk)';
    elif git diff-tree --exit-code --quiet $1 $(git cat-file commit $3 | sed "s/tree //;q"); then
      map $3;
    else git commit-tree "$@"; fi' \
  --tag-name-filter cat heads/0.99.19
rm .git/refs/original/refs/heads/0.99.19

git branch -d -r pre/trunk

# This is a duplicate indue to "svn add" instead of "svn cp"
git branch -d -r tags/post/1%3A0.99.19%7Epre78-1 at 728

# Reset the tag
git tag -d 1%3A0.99.19%7Epre78-1
git tag 1%3A0.99.19%7Epre78-1 1%3A0.99.19%7Epre89-1~9

# Fix the tag name pre115 had never exist
git tag -d 1%3A0.99.19%7Epre117-1
git tag 1%3A0.99.19%7Epre117-1 1%3A0.99.19%7Epre115-1
git tag -d 1%3A0.99.19%7Epre115-1

# Check for empty commits
git log --pretty=oneline --shortstat --all |tac |sed '/^ /{N;d;}'

# Cleanup git's internal structures
git gc --prune --aggressive
-- 
Nutze die Talente, die du hast. Die Wälder wären sehr still,
wenn nur die begabtesten Vögel sängen.                (Henry van Dyke)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.alioth.debian.org/pipermail/pkg-jed-devel/attachments/20071215/ccdb22f4/attachment.pgp 


More information about the Pkg-jed-devel mailing list