shithub: git9

Download patch

ref: a24870e98c772b11ea24b64ee2452cc349c5aee6
parent: b4721715066c1a28d0ef2b29b97652316959c101
author: Ori Bernstein <[email protected]>
date: Fri Jan 3 23:44:05 EST 2020

clean up junk repo on clone failure

--- a/clone
+++ b/clone
@@ -1,4 +1,4 @@
-#!/bin/rc -e
+#!/bin/rc
 rfork en
 . /sys/lib/git/common.rc
 
@@ -18,6 +18,7 @@
 	die 'repository already exists:' $local
 
 fn clone{
+	flag +e
 	mkdir -p $local/.git
 	mkdir -p $local/.git/objects/pack/
 	mkdir -p $local/.git/refs/heads/
@@ -59,7 +60,7 @@
 				print headhash > ".git/HEAD"
 			}
 		}
-	'} |[3] tr '\x0d' '\x0a' || die $status
+	'} |[3] tr '\x0d' '\x0a' || die 'could not clone repository'
 
 	tree=/mnt/git/branch/heads/master/tree
 	echo checking out repository...
@@ -82,4 +83,10 @@
 	}
 }
 
-clone
+@{clone}
+st=$status
+if(! ~ $st ''){
+	echo failed to clone $remote: cleaning $local >[1=2]
+	rm -rf $local
+	exit $st
+}