ref: 926e838a32a4c46d38a767e8970987e31c6b5864
dir: /log/
#!/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=`{git/branch} query=() while(~ $1 -* && ! ~ $1 --){ switch($1){ case -b branch=$2 shift case -q query=$2 shift case * usage } shift } if(~ $1 --) shift if(~ $#query 0) commits=`{git/query $branch} if not commits=`{git/query $query} 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-) if(~ $#query 0) commits=($commits `{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 -n 'Hash: '`''{cat $base/$c/hash} echo -n 'Author: '`''{cat $base/$c/author} echo -n 'Date: '`''{date `{mtime $base/$c/msg | awk '{print $1}'}} sed 's/^/ /g' $base/$c/msg echo } }