Skip to content

Instantly share code, notes, and snippets.

@Orc
Created May 19, 2017 20:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Orc/2df8763e9007659af3baba04f156e71f to your computer and use it in GitHub Desktop.
Save Orc/2df8763e9007659af3baba04f156e71f to your computer and use it in GitHub Desktop.
create a git repository from a pile of tarballs (one tarball per commit, ordered cronologically, with the git dates forged to match the tarball dates)
#! /bin/ksh
#
extractomatic() {
tarball=$1
first_in_archive=`tar tzf $tarball | head -1`
path=`dirname ${first_in_archive}/thing`
when=`dateof $tarball`
export GIT_COMMITTER_DATE="$when"
export GIT_AUTHOR_DATE="$when"
echo "extract $tarball to $path"
tar xzf $tarball
if [ "$path" != "." ]; then
echo "rsync $path to ."
rsync -ar $path/. .
rm -rf $path
fi
echo -n "[more]"
read me
}
for x in ` ls -1rt "$@" `;do
messagetag=`basename $x`
extractomatic "$x"
for y in `git status -u | grep '# '`; do
if [ -f $y ]; then
case "`file $y`" in
*ELF*) rm $y ;;
esac
fi
if [ -f $y ]; then
case "$y" in
*.o) rm $y ;;
*.gz) rm $y ;;
*) git add $y ;;
esac
fi
done
git commit -m "$messagetag" -a
git tag "$messagetag"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment