ref: a08453bf28d8178919b62d01b73e56c209f5b4d1
dir: /log/
#!/bin/rc -e rfork en . /bin/git/common.rc usage=' git/log [-q query] [file ...] ' nl=' ' 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 } }