#!/bin/sh set -eu if ! [ -d tarball_archive ]; then echo "$0: Directory tarball_archive does not exist in the current directory" >&2 exit 1 fi if [ -d .git ]; then if git status --porcelain | grep -q .; then git status >&2 echo "$0: Git working tree unclean, won't continue" >&2 exit 1 fi else echo "$0: .git does not exist in the current directory" >&2 exit 1 fi tmpfile="$(mktemp /tmp/extract_and_commit.XXXXXX)" for archive in ./tarball_archive/{mon-2.{0,1,2,3,4},symon-2.{5,51,52,53,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88}}.tar.gz; do if git log --format=oneline | grep -q "$archive"; then echo "$0: $archive already in git, continuing" >&2 continue fi zcat $archive | pax -0 > "$tmpfile" zcat $archive | pax -r xargs -0 git add < "$tmpfile" git commit -m "Add $archive" tr '\0' '\n' < "$tmpfile" | egrep -o "^[^/.]+/" | sort -u | xargs rm -R xargs -0 git add < "$tmpfile" done rm "$tmpfile" git reset --hard HEAD