shithub: git9

Download patch

ref: 34bdfecb51c9948156b41c4774e8cd500cda2180
parent: 4eda12bdbcc8fe7acc4a2a81499ff853e64b1c4a
author: Ori Bernstein <ori@eigenstate.org>
date: Tue Oct 22 19:42:04 EDT 2019

Add git/revert: just a fancy wrapper around cp.

diff: cannot open a/test//null: file does not exist: 'a/test//null'
--- a/mkfile
+++ b/mkfile
@@ -23,6 +23,7 @@
 	merge\
 	pull\
 	push\
+	revert
 
 OFILES=\
 	objset.$O\
--- /dev/null
+++ b/revert
@@ -1,0 +1,28 @@
+#!/bin/rc
+
+commit=/mnt/git/HEAD
+pfx=`{pwd}
+while(~ $1 -* && ! ~ $1 --){
+	switch($1){
+	case -c;
+		commit=`{git/query -p $2};
+		shift
+	case *;
+		echo usage: $0 [-c commit] files...
+		exit usage
+	}
+	shift
+}
+
+if(! cd `{git/conf -r}){
+	echo not a git repository >[1=2]
+	exit notgit
+}
+pfx=`{echo $pfx | sed 's@^'^`{pwd}^'@@g'}
+if(~ $#pfx 0)
+	pfx=''
+git/fs
+
+for(f in `{walk -f $*})
+	cp -- $commit/tree/$pfx/$f ./$pfx/$f
+