shithub: git9

ref: a08453bf28d8178919b62d01b73e56c209f5b4d1
dir: /export/

View raw version
#!/bin/rc
rfork ne
. /bin/git/common.rc

usage='
	git/export [query]
'

nl='
'
if(! cd `{git/conf -r})
	exit 'not in git repository'
git/fs
q=$*
if(~ $#q 0)
	q=HEAD
commits=`{git/query $q}
x=$status
if(! ~ $x ''){
	echo 'could not find commits: '$x
	exit $x
}

scratch=/tmp/gitexport.$pid
mkdir -p $scratch
mkdir $scratch/a $scratch/b
for(c in $commits){
	cp=`{git/query -p $c}
	pp=`{git/query -p $c'^'}

	@{
		rfork n
		cd $scratch
		bind $pp/tree a
		bind $cp/tree b
		
		echo From $c
		echo From: `{cat $cp/author}
		echo Date: `{date -m `{mtime $cp/author}}
		echo Subject: [PATCH] `{sed 1q $cp/msg}
		echo
		sed '1d' $cp/msg

		ape/diff -urN a b
	}
}
rm $scratch/a $scratch/b
rm $scratch