shithub: git9

ref: 26b0b7a8d040c802af32e57184df45b9eaaa4491
dir: /log/

View raw version
#!/bin/rc -e

rfork en

nl='
'

fn usage {
	echo usage: $0 '[-b branch] [file ...]' >[1=2]
	exit usage
}


base=/mnt/git/object/
git/fs
branch=master

while(~ $1 -* && ! ~ $1 --){
	switch($1){
	case -b
		branch=$2
		shift
	case *
		usage
	}
	shift
}
if(~ $1 --)
	shift
commits=`{git/query $branch}
files=()
if(! ~ $#* 0)
	files=`$nl{walk -f $*}

if(! ~ $#files 0)
	nids=`{sha1sum $base/$commits(1)^/tree/$files | awk '{print $1}' >[2]/dev/null}

while(! ~ $#commits 0){
	ids=$nids
	c=$commits(1)
	if(! ~ $#files 0)
		nids=`{sha1sum $base/$commits(1)^/tree/$files | awk '{print $1}' >[2]/dev/null}

	commits=($commits(2-) `{cat $base/$c/parent >[2]/dev/null})
	if(! ~ $#commits 0)
		commits=`$nl{walk -emp -n0 $base^$commits | sort -rn | uniq | awk -F/ '{print $NF}'}

	if(~ $#files 0 || ! ~ $"ids $"nids || ~ $#commits 0){
		echo 'Hash:	'^`''{cat $base/$c/hash}^'Author:	'^`''{cat $base/$c/author}
		sed 's/^/	/g' $base/$c/msg
		echo
	}
}