shithub: git9

Download patch

ref: befc2738356f9029f6631bef93d68e3f0d65d5ef
parent: 34bdfecb51c9948156b41c4774e8cd500cda2180
author: Ori Bernstein <[email protected]>
date: Tue Oct 22 21:44:11 EDT 2019

Clean up git/branch script.

--- a/branch
+++ b/branch
@@ -21,8 +21,8 @@
 '
 stay=()
 create=()
-update=()
 delete=()
+update=()
 base=`{awk '$1=="branch"{print $2}' < /mnt/git/ctl}
 while(~ $1 -* && ! ~ $1 --){
 	switch($1){
@@ -29,8 +29,8 @@
 	case -c; create=true
 	case -s; stay=true
 	case -b; shift; base=$1
-	case -u; update=true
 	case -d; delete=true
+	case -u; update=true
 	case *
 		usage
 	}
@@ -57,12 +57,17 @@
 	exit
 }
 
+if(~ $#update 0 && test -f .git/$new){
+	echo branch $1 already exists
+	exit already-got-one
+}
+
 if(! git/walk -q `{git/query -c HEAD $base | sed 's/^..//'}){
-	echo remote changes would clobber local changes >[1=2]
+	echo branch update would clobber changes >[1=2]
 	exit dirty
 }
 
-if(~ $#create 0){
+if(! ~ $#create 0){
 	if(! test -e .git/$new){
 		echo branch $new: does not exist >[1=2]
 		exit noexist
@@ -69,26 +74,18 @@
 	}
 }
 if not{
-	if(~ $#update 0 && test -e .git/$new){
-		echo could not create $1: already exists >[1=2]
-		exit exists
-	}
-	branched=()
-	remotes=`$nl{cd .git/refs/remotes && ls}
 	commit=`{git/query $base}
 	st=$status
 	if(! ~ $st ''){
 		echo could not find branch $base':' $st >[1=2]
 		exit notfound
-	}	
+	}
 	echo $commit > .git/$new
 }
 
 
-modified=`$nl{git/query -c HEAD $new | grep '^[+!@]' | sed 's/^..//'}
+modified=`$nl{git/query -c HEAD $new | grep '^[^-]' | sed 's/^..//'}
 deleted=`$nl{git/query -c HEAD $new | grep '^-' | sed 's/^..//'}
-
-echo $deleted
 
 if(! ~ $#stay 0)
 	exit
--- a/pull
+++ b/pull
@@ -104,4 +104,4 @@
 echo $local':' `{git/query $local} '=>' `{git/query $remote}  >[1=2]
 if(! ~ $#incoming 0)
 	git/log -q $local'..'$remote
-git/branch -u -b $remote $local
+git/branch -b $remote $local
--- a/query.c
+++ b/query.c
@@ -44,7 +44,6 @@
 		bp = b->tree->ent;
 		be = bp + b->tree->nent;
 		while(ap != ae && bp != be){
-			print("cmp %s %s\n", ap->name, bp->name);
 			c = strcmp(ap->name, bp->name);
 			if(c == 0){
 				if(ap->mode == bp->mode && hasheq(&ap->h, &bp->h))
--- a/revert
+++ /dev/null
@@ -1,28 +1,0 @@
-#!/bin/rc
-
-commit=/mnt/git/HEAD
-pfx=`{pwd}
-while(~ $1 -* && ! ~ $1 --){
-	switch($1){
-	case -c;
-		commit=`{git/query -p $2};
-		shift
-	case *;
-		echo usage: $0 [-c commit] files...
-		exit usage
-	}
-	shift
-}
-
-if(! cd `{git/conf -r}){
-	echo not a git repository >[1=2]
-	exit notgit
-}
-pfx=`{echo $pfx | sed 's@^'^`{pwd}^'@@g'}
-if(~ $#pfx 0)
-	pfx=''
-git/fs
-
-for(f in `{walk -f $*})
-	cp -- $commit/tree/$pfx/$f ./$pfx/$f
-