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

Re: [libvirt] Switch from CVS to GIT is done



Daniel Veillard wrote:
>   Thanks to Jim Meyering we now have a new git repository, I deprecated the
> CVS repository, it's read only, you should still be able to keep it
> around to make patches for a few weeks if needed.
>   The new repo is at:
>     http://libvirt.org/git/?p=libvirt.git;a=summary

To create that new repository, I rewrote the git repository from
et.redhat.com to correct a few minor problems.
In case anyone is interested, here are the details.

---------------------------------------
Some commits had incomplete names.
Run this to see all 64 commits:

  $ git log --pretty=format:%h:%an|grep -v ' '

Here's a summary:

  $ git log --pretty=format:%an|grep -v ' '|sort|uniq -c
      1 aliguori
     13 clalance
      3 crobinso
      8 danms
      5 dlesko
     23 meyering
     11 sakaia

============================
Note that rewriting changes nearly all SHA1 values, so
any reference to an SHA1 in a commit log should be updated
to point to the new SHA1.  There are a few:

$ git log|grep -E '\b[0-9a-f]{7,40}\b'|grep -v '^commit'
    This regressed via commit 4c3f3b4d.
    [043d702f] "use virAsprintf instead of asprintf" introducted
    The 'getVer' fix introducted in d88d459d [Allow remote://hostname/
    Bug introduced in 895d0fdf5bef358fafb91c672609190b3088097b.

====================================================
Run the following long(!) command to rewrite the "master" branch,
preserving tags (but not signed ones), fixing bogus author names and
preserving SHA1 references like the above:

git filter-branch -d $TMPDIR/.git-rewrite \
 --tag-name-filter cat \
 --env-filter '

case $GIT_AUTHOR_NAME in
  agx) n="Guido G√ľnther" e="agx sigxcpu org" ;;
  aliguori) n="Anthony Liguori" e="aliguori us ibm com" ;;
  clalance) n="Chris Lalancette" e="clalance redhat com" ;;
  crobinso) n="Cole Robinson" e="crobinso redhat com" ;;
  danms) n="Dan Smith" e="danms us ibm com" ;;
  dlesko) n="David L. Leskovec" e="dlesko linux vnet ibm com" ;;
  meyering) n="Jim Meyering" e="meyering redhat com" ;;
  sakaia) n="Atsushi SAKAI" e="sakaia jp fujitsu com" ;;
  *) n=$GIT_AUTHOR_NAME e=$GIT_AUTHOR_EMAIL ;;
esac

export GIT_AUTHOR_EMAIL=$e GIT_AUTHOR_NAME=$n
export GIT_COMMITTER_EMAIL=$e GIT_COMMITTER_NAME=$n

' --msg-filter '

cat > t.msg
ref=$(perl -ne "/\b([0-9a-f]{7,40})\b/ and print \$1" t.msg)
test -n "$ref" && sha=$(git rev-parse $ref) &&
  {
    len=$(printf $ref|wc -c)
    new_sha=$(map $sha)
    short_sha=$(printf %.${len}s $new_sha)
    perl -pi -e "s/$ref/$short_sha/" t.msg
  }
cat t.msg

' master

I tested it on this tiny repository:
  git init -q; : > j; git add j; git ci -q --author='meyering <meyering>' -m. -a
  c=$(git log --pretty=%h)
  echo a > j; git ci -q -m "fix bug in $c" -a

====================================================

The above preserves regular tags, but not the signed ones.
Reapply the signed vM.N.O tags:

for i in $(git tag -l 'LIBVIRT_*'); do
  v=$(echo $i|sed 's/LIBVIRT_/v/;s/_/./g')
  echo $v
  git tag -f -s -m$v $v $i
done

====================================================

With the above changes, we've bloated the repository by ~50%,
increasing its size from 22M to 34M.

Remove the cruft:

  git for-each-ref --format="%(refname)" refs/original/ \
    | xargs -n 1 git update-ref -d
  git reflog expire --expire=now --all
  git gc --prune=now

And that brings it back down to 23M.
Run this function

git-repo-compress()
{
  local d=$1
  du -sh "$d"; start=$(date); /usr/bin/time \
    git --git-dir=$d repack -afd --window=250 --depth=250
  echo started $start; date; du -sh "$d"
}

to compress a few remaining bits.
Final size: 21M.

Push to libvirt.org:

  git push libvirt.org:/git/libvirt.git master:master
  git push --tags libvirt.org:/git/libvirt.git

====================================================

After I'd pushed all of the above, Dan Berrange noticed
that the new signed tags were out of order and had all
been created today.

Back-date the signed tags so that each has the same date as its
unsigned counterpart:

for i in $(git tag -l 'LIBVIRT_*'); do
  v=$(echo $i|sed 's/LIBVIRT_/v/;s/_/./g')
  date=$(git log --pretty=%ci -1 $i)
  echo $v
  GIT_COMMITTER_DATE="$date" git tag -f -s -m$v $v $i
done

# And push (now we need the -f option):
git push -f --tags libvirt.org:/git/libvirt.git


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