shithub: plan9front

Download patch

ref: da085a2d4cca788686b8f68b2555040cf29dc16c
parent: 2af46e406bbd443ae10025777247798a685afc3c
author: Ori Bernstein <ori@eigenstate.org>
date: Fri Aug 13 01:16:50 EDT 2021

git/branch: make '-n' use HEAD when '-b' unspecified

This brings the behavior in line with the manual page,
and makes things less surprising for users.

--- a/sys/src/cmd/git/branch	Thu Aug 12 21:27:17 2021
+++ b/sys/src/cmd/git/branch	Fri Aug 13 01:16:50 2021
@@ -32,7 +32,7 @@
 orig=`{git/query HEAD}
 if (~ $#baseref 1)
 	base=`{git/query $baseref} || exit 'bad base'
-if not if(test -e .git/$new)
+if not if(~ $#newbr 0)
 	base=`{git/query $new}
 if not
 	base=`{git/query HEAD}
@@ -41,7 +41,6 @@
 	if(! ~ $#baseref 0)
 		die update would clobber $branch with $baseref
 	baseref=`$nl{echo -n $new | sed s@refs/heads/@refs/remotes/origin/@}
-	echo $baseref
 	if(! test -e .git/$new)
 		if(! base=`{git/query $baseref})
 			die could not find branch $branch
@@ -119,4 +118,5 @@
 }
 
 echo ref: $new > .git/HEAD
+echo $new: `{git/query $new}
 exit ''