]> git.lizzy.rs Git - plan9front.git/commitdiff
git/branch: make '-n' use HEAD when '-b' unspecified
authorOri Bernstein <ori@eigenstate.org>
Fri, 13 Aug 2021 05:16:50 +0000 (05:16 +0000)
committerOri Bernstein <ori@eigenstate.org>
Fri, 13 Aug 2021 05:16:50 +0000 (05:16 +0000)
This brings the behavior in line with the manual page,
and makes things less surprising for users.

sys/src/cmd/git/branch

index 6693d7c4ffb524f3988e1a2c7244844c28e3266c..4646c32709f71310b20780cdf2c8d5c6bf1f52e2 100755 (executable)
@@ -32,7 +32,7 @@ if not
 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(~ $#newbr 0){
        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 @@ if(! ~ $#deleted 0){
 }
 
 echo ref: $new > .git/HEAD
+echo $new: `{git/query $new}
 exit ''