ref: d49479660dbb66cde23766084206dc1ba43e02df
parent: dc47e402e7b53c0e81478aa9560e00ffd73d8332
author: Ori Bernstein <ori@eigenstate.org>
date: Sun Dec 1 12:12:21 EST 2019
fix branch behavior: use existing branches. we used to treat creating a new branch and switching to an existing branch as the same, using the current base commit. this is wrong. now, if the branch we're switching to exists and we have no '-b' parameter, we use its current commit as the commit we switch to.
--- a/branch
+++ b/branch
@@ -14,7 +14,7 @@
stay=()
create=()
delete=()
-base=`{awk '$1=="branch"{print $2}' < /mnt/git/ctl}
+base=()
while(~ $1 -* && ! ~ $1 --){
switch($1){
case -c; create=true
@@ -30,7 +30,7 @@
if(~ $1 --) shift
if(~ $#* 0){
- echo $base
+ awk '$1=="branch"{print $2}' < /mnt/git/ctl
exit
}
@@ -42,6 +42,12 @@
new=refs/$1
if not
new=refs/heads/$1
+if (~ $#base 1)
+ base=`{git/query $base}
+if not if(test -e .git/$new)
+ base=`{git/query $new}
+if not
+ base=`{git/query HEAD}
if(! ~ $#delete 0){
rm -f .git/$new
@@ -60,6 +66,7 @@
}
if not{
commit=`{git/query $base || die 'branch does not exist:' $base}
+ echo updating $new to $commit
echo $commit > .git/$new
}
@@ -79,8 +86,10 @@
# 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)
+ if(! ~ $a $b){
rm -rf $m
+ rm -rf .git/index9/tracked/$m
+ }
if(test -f $basedir/tree/$m){
cp $basedir/tree/$m $m
walk -eq $m > .git/index9/tracked/$m
--- a/walk.c
+++ b/walk.c
@@ -89,10 +89,8 @@
goto error;
while((n = dirread(fd, &d)) > 0){
for(i = 0; i < n; i++){
- if(seen(&d[i])){
- print("seen %s\n", full);
+ if(seen(&d[i]))
continue;
- }
if(d[i].qid.type & QTDIR){
if((sub = smprint("%s%s%s", dir, sep, d[i].name)) == nil)
sysfatal("smprint: %r");