shithub: riscv

Download patch

ref: 99db038e2825266e84ddb381718f3d047dc6d733
parent: faa625a1d5ab47ac0438b2cea5b2bde1ea747b8b
author: Ori Bernstein <ori@eigenstate.org>
date: Tue Aug 22 01:06:25 EDT 2023

git/clone: correctly handle cloning repos with '/' in the remote ref

--- a/sys/src/cmd/git/clone
+++ b/sys/src/cmd/git/clone
@@ -67,7 +67,7 @@
 				refdir = headref;
 				gsub("/?[^/]*/?$", "", refdir)
 				gsub("^refs/remotes/origin", "refs/heads", headref)
-				system("mkdir -p .git/"refdir);
+				system("mkdir -p `{basename -d .git/"headref"}");
 				system("cp .git/" remote " .git/" headref)
 				print "ref: " headref > ".git/HEAD"
 			}else if(headhash != ""){
@@ -82,6 +82,7 @@
 	rbranch=`{echo $lbranch | subst 'heads' 'remotes/origin'}
 	echo checking out repository...
 	if(test -f .git/refs/$rbranch){
+		mkdir -p `{basename -d .git/refs/$lbranch}
 		cp .git/refs/$rbranch .git/refs/$lbranch
 		git/fs
 		@ {builtin cd $tree && tar cif /fd/1 .} | @ {tar xf /fd/0} \
@@ -100,6 +101,7 @@
 
 fn sigint {
 	echo cancelled clone $remote: cleaning $local >[1=2]
+	unmount $local/.git/fs >[2]/dev/null
 	rm -rf $local
 	exit interrupted
 }
@@ -108,6 +110,7 @@
 st=$status
 if(! ~ $st ''){
 	echo failed to clone $remote: cleaning $local >[1=2]
+	unmount $local/.git/fs >[2]/dev/null
 	rm -rf $local
 	exit $st
 }