Hacking:git rewrite

From ParabolaWiki
Jump to: navigation, search

lukeshu commited a large sourceball to abslibre.git. This is bad, it means bandwidth used all around. We use repo.parabolagnulinux.org/other for that. This calls for rewriting git history.

Here is the command I used to correct this (after uploading the file to the repo server). I put it in a file because it's a pain to type correctly at the command line, especially while getting the quoting right.

File: rewrite.sh
#!/bin/sh
git filter-branch --tree-filter '
if [ -f ./~lukeshu/iceweasel-libre-current/iceweasel-9.0.1.tar.gz ]; then
  rm ./~lukeshu/iceweasel-libre-current/iceweasel-9.0.1.tar.gz
  rm ./~lukeshu/iceweasel-libre-current/.gitignore
  sed -i '\''s@source=(iceweasel-${pkgver}\.tar\.gz@&::https://repo.parabolagnulinux.org/other/iceweasel-${pkgver}-connos.tar.gz@'\'' ./~lukeshu/iceweasel-libre-current/PKGBUILD
fi
'

That runs pretty quickly. If you care to check it's work, the original history is still there under remotes/origin/master, and you can compare them using gitk.

After the history has been rewritten, and you are happy with it, you normally would push it to the server with
 $ git push -f

However, on the server this has been disabled (which is probably good). Anyway, you'll need to find someone with access to the relevent user on the server to do it for you.

After the rewrite hits the repo, anyone who has pulled since the earliest rewritten commit will get a bunch of warnings the next time they pull. In this case, we're pretty sure this was just fauno and lukeshu, so that's not too bad.

After it has been put in the repo, you can clean up the git database with this:

 $ rm -rf .git/refs/original/ && git reflog expire --all &&  git gc --aggressive --prune

Although, if the repo was already properly garbage collected, it should only clear up nominal space.