shithub: git9

Download patch

ref: 27f60592bfbab953dc68627afd5b36ed196c0157
parent: 7e4b4a3dcf713b5ae217b23b25bb4d0d5a9a7e6d
author: Ori Bernstein <ori@eigenstate.org>
date: Mon Nov 25 21:09:44 EST 2019

fix branch when we need to create new files

--- a/branch
+++ b/branch
@@ -69,16 +69,22 @@
 
 if(! ~ $#modified 0){
 	basedir=`{git/query -p $base}
-	# Modifications can turn a file into
-	# a directory, so we need to walk to
-	# check the blobs out correctly.
 	for(m in $modified){
 		d=`{basename -d $m}
 		mkdir -p $d
 		mkdir -p .git/index9/tracked/$d
-		if(test -f $m)
+		# Modifications can turn a file into
+		# a directory, or vice versa, so we
+		# need to delete and copy the files
+		# over. If we're checking out a
+		a=`{test -f $m && echo file || echo dir}
+		b=`{test -f $basedir/tree/$m && echo file || echo dir}
+		if($a != $b)
+			rm -rf $m
+		if(test -f $basedir/tree/$m){
 			cp  $basedir/tree/$m $m
-		walk -eq $m > .git/index9/tracked/$m
+			walk -eq $m > .git/index9/tracked/$m
+		}
 	}
 }
 if(! ~ $#deleted 0){