tcodereview: fix a few bugs - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 32f3c4ade43dd87e75c083a827460b864b9476ba
 (DIR) parent 95fee1d42e537209727d9493d1ea3784a8af310a
 (HTM) Author: Russ Cox <rsc@swtch.com>
       Date:   Sun, 16 Nov 2014 21:28:05 -0500
       
       codereview: fix a few bugs
       
       Change-Id: Ifd9fda05e15c9e1e106ffd4e30e1dafe8423cdf4
       
       Diffstat:
         M bin/codereview                      |      17 +++++++++--------
       
       1 file changed, 9 insertions(+), 8 deletions(-)
       ---
 (DIR) diff --git a/bin/codereview b/bin/codereview
       t@@ -46,23 +46,24 @@ case pending
        
        case create
                shift
       -        if(! ~ $#* 1) {
       +        if(~ $#* 0) {
                        echo 'usage: codereview create branchname' >[1=2]
                        exit usage
                }
                branch=$1
       -        if(! git branch -l | 9 grep '\* master$') {
       +        shift
       +        if(! git branch -l | 9 grep '\* master$' >/dev/null) {
                        echo 'codereview: create not on master branch; use codereview commit' >[1=2]
                        exit master
                }
                if($show) {
                        echo '% git branch '$branch' && git commit || git branch -d '$branch >[1=2]
                }
       -        git branch $branch && git commit $* || git branch -d $branch
       +        git branch $branch && git checkout $branch && git commit $* || git branch -d $branch
        
        case commit
                shift
       -        if(git branch -l | 9 grep '\* master$') {
       +        if(git branch -l | 9 grep '\* master$' >/dev/null) {
                        echo 'codereview: commit on master branch; use codereview create <branchname>' >[1=2]
                        exit master
                }
       t@@ -75,7 +76,7 @@ case commit
                exit $status
        
        case upload
       -        if(git branch -l | 9 grep '\* master$') {
       +        if(git branch -l | 9 grep '\* master$' >/dev/null) {
                        echo 'codereview: upload on master branch' >[1=2]
                        exit master
                }
       t@@ -110,7 +111,7 @@ case sync
                }
        
                # Exactly this commit in master. Fast-forward from master and delete this branch.
       -        if(git branch -r --contains HEAD | 9 grep '^ *origin/master$') {
       +        if(git branch -r --contains HEAD | 9 grep '^ *origin/master$' >/dev/null) {
                        $git checkout -q master
                        $git merge -q --ff-only origin/master
                        $git branch -q -d $branch
       t@@ -123,7 +124,7 @@ case sync
                        exit changeid
                }
        
       -        if(git log --grep 'Change-Id: '$changeid origin/master | 9 grep .) {
       +        if(git log --grep 'Change-Id: '$changeid origin/master | 9 grep . >/dev/null) {
                        # Something like this got submitted.
                        $git checkout -q master
                        $git merge -q --ff-only origin/master
       t@@ -132,7 +133,7 @@ case sync
                        exit 1
                }
                
       -        if(git branch -r --contains master | 9 grep '^ *origin/master$')
       +        if(git branch -r --contains master | 9 grep '^ *origin/master$' >/dev/null)
                        $git branch -f master origin/master
                $git rebase -q origin/master