ref: 8fb116e331e879f493fccef746d43ba12f6fb072
dir: /branch/
#!/bin/rc -e rfork en . /sys/lib/git/common.rc usage=' git/branch [-cdsu] [-b base] [new] -b base base new branch on "base" (default: current branch) -d delete a branch -s create a branch but stay on current one ' gitup stay=() create=() delete=() base=`{awk '$1=="branch"{print $2}' < /mnt/git/ctl} while(~ $1 -* && ! ~ $1 --){ switch($1){ case -c; create=true case -s; stay=true case -b; shift; base=$1 case -d; delete=true case -u; update=true case * usage } shift } if(~ $1 --) shift if(~ $#* 0){ echo $base exit } if(! ~ $#* 1) usage if(~ $1 refs/heads/*) new=$1 if not if(~ $1 heads/*) new=refs/$1 if not new=refs/heads/$1 if(! ~ $#delete 0){ rm -f .git/$new exit } modified=`$nl{git/query -c HEAD $base | grep '^[^-]' | sed 's/^..//'} deleted=`$nl{git/query -c HEAD $base | grep '^-' | sed 's/^..//'} if(! git/walk -q $modified $deleted) die 'uncommited changes' if(! ~ $#create 0){ if(! test -e .git/$new) die 'branch does not exist:' $new } if not{ commit=`{git/query $base || die 'branch does not exist:' $base} echo $commit > .git/$new } if(! ~ $#stay 0) exit 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) cp $basedir/tree/$m $m walk -eq $m > .git/index9/tracked/$m } } if(! ~ $#deleted 0){ rm -f $deleted rm -f .git/index9/tracked/$deleted } echo ref: $new > .git/HEAD