9front - general discussion about 9front
 help / color / mirror / Atom feed
* [9front] Git/revert abs path handling
@ 2021-06-18  9:26 Alex Musolino
  2021-06-18 10:50 ` kvik
  0 siblings, 1 reply; 4+ messages in thread
From: Alex Musolino @ 2021-06-18  9:26 UTC (permalink / raw)
  To: 9front

I noticed that git/revert doesn't work if you supply it absolute path
names and your cwd is not /.  The following patch does the trick for
me.

--- //.git/fs/object/b3215c807556cdaaa0f949f1fb3f97c484ffd1da/tree/sys/src/cmd/git/revert
+++ sys/src/cmd/git/revert
@@ -2,6 +2,21 @@
 rfork en
 . /sys/lib/git/common.rc
 
+fn treewalk{@{
+	if(cd $1/tree){
+		shift
+		for(p){
+			switch($p){
+			case /*
+				wargs=($wargs ./$p)
+			case *
+				wargs=($wargs ./$gitrel/$p)
+			}
+		}
+		walk -f $wargs
+	}
+}}
+
 gitup
 
 flagfmt='c:query query' args='file ...'
@@ -11,9 +26,9 @@
 if(~ $#query 1)
 	commit=`{git/query -p $query}
 
-for(f in `$nl{cd $commit/tree/ && walk -f ./$gitrel/$*}){
-	mkdir -p `{basename -d $f}
-	cp -- $commit/tree/$f $f
-	git/add $f
+for(f in `$nl{treewalk $commit $*}){
+	mkdir -p `{basename -d /$f}
+	cp -- $commit/tree/$f /$f
+	git/add /$f
 }
 exit ''


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-06-20 22:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-18  9:26 [9front] Git/revert abs path handling Alex Musolino
2021-06-18 10:50 ` kvik
2021-06-20 11:35   ` Alex Musolino
2021-06-20 13:25     ` ori

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).