shithub: git9

ref: 26f165c02bff58b15564e77309a5e147ecda388c
dir: /revert/

View raw version
#!/bin/rc
rfork e
. /sys/lib/git/common.rc

usage='
	git/revert [-c query] file [...]
		-c        revert to commit "query" (default: HEAD)
'

rel=`{pwd}
gitup

commit=/mnt/git/HEAD
while(~ $1 -* && ! ~ $1 --){
	switch($1){
	case -c;
		commit=`{git/query -p $2}
		shift
	case *;
		usage
	}
	shift
}

rel=`{echo $rel | sed 's@^'$gitroot'/?@@'}
if(~ $#rel 0)
	rel=''

for(f in `$nl{cd $commit/tree/ && walk -f ./$rel/$*})
	cp -- $commit/tree/$f $f