turning a series of tarballs into a series of git commits

I find that gitk, the git history browser, is immensely valuable for navigating code. I found myself wanting to navigate the history of code for which I only had the release tarballs. So I wanted to turn them into a series of git commits. The tricky thing here is that I wanted to include adds and deletes, so basically I rm -rf the contents of the git repo, then untar the tarball into the git repo, then you can see adds and deletes. Here’s the script that I actually used:

#!/bin/sh

for tarball in `\ls -1 Pd-0.42.5-extended-l2ork-dev-201*.tar.bz2 | sort`; do
	 date=`ls -l --time-style=long-iso $tarball | cut -b35-52`
	 echo --------------------------------
	 echo $tarball $date
	 rm -rf pd-l2ork.git/*
	 tar --exclude-vcs \
		  --exclude .svn \
		  --exclude .git \
		  --exclude pure-data/pd/.git \
		  --exclude \*~ \
		  --exclude pure-data/pd/bin \
		  --exclude pure-data/pd/obj \
		  --exclude \*.o \
		  --transform 's|pure-data/pd|pd-l2ork.git|' \
		  -xjf $tarball pure-data/pd
	 cd /export/storage/pd-l2ork/pd-l2ork.git/
	 echo "git add"
	 git add `find . -type f | grep -v .git`
	 echo "git commit"
	 git commit --date="$date" --author="Ivica Ico Bukvic " -am "$tarball"
	 cd /export/storage/pd-l2ork/
done
Advertisement

You must be logged in to post a comment.

Follow

Get every new post delivered to your Inbox.