From: Kyle Milz <krwmilz@gmail.com>
To: 9front@9front.org
Subject: [9front] git: consistent args checking
Date: Thu, 4 Nov 2021 15:33:28 -0700 [thread overview]
Message-ID: <YYRfuK7uqEWXyuMq@imac.0x30.net> (raw)
[-- Attachment #1: git_args_checking.diff --]
[-- Type: text/plain, Size: 1312 bytes --]
hi,
i audited the rc based git tools for similar bugs as the last.
i found no more bugs but i wanted to make the error checking
consistent for the tools that use a trivial number of args.
args required:
- git/add: > 1
- git/merge: 1
- git/push: 0
diff e2e4a46f26ff7268a696a45d82414fb992b648d5 uncommitted
--- a/sys/src/cmd/git/add
+++ b/sys/src/cmd/git/add
@@ -5,7 +5,8 @@
gitup
flagfmt='r:remove'; args='file ...'
-eval `''{aux/getflags $*} || exec aux/usage
+if(! eval `''{aux/getflags $*} || ~ $#* 0)
+ exec aux/usage
add='tracked'
del='removed'
@@ -13,8 +14,6 @@
add='removed'
del='tracked'
}
-if(~ $#* 0)
- exec aux/usage
paths=`$nl{cleanname -d $gitrel $* | drop $gitroot}
if(~ $add tracked)
--- a/sys/src/cmd/git/merge
+++ b/sys/src/cmd/git/merge
@@ -19,9 +19,7 @@
gitup
flagfmt=''; args='theirs'
-eval `''{aux/getflags $*} || exec aux/usage
-
-if(! ~ $#* 1)
+if (! eval `''{aux/getflags $*} || ! ~ $#* 1)
exec aux/usage
theirs=`{git/query $1}
--- a/sys/src/cmd/git/push
+++ b/sys/src/cmd/git/push
@@ -6,8 +6,7 @@
flagfmt='a:pushall, b:branch branch, f:force, d:debug,
r:remove remove, u:upstream upstream' args=''
-eval `''{aux/getflags $*} || exec aux/usage
-if(! ~ $#* 0)
+if (! eval `''{aux/getflags $*} || ! ~ $#* 0)
exec aux/usage
if(~ $pushall 1)
reply other threads:[~2021-11-04 22:41 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YYRfuK7uqEWXyuMq@imac.0x30.net \
--to=krwmilz@gmail.com \
--cc=9front@9front.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).