* [9front] git: consistent args checking
@ 2021-11-04 22:33 Kyle Milz
0 siblings, 0 replies; only message in thread
From: Kyle Milz @ 2021-11-04 22:33 UTC (permalink / raw)
To: 9front
[-- 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)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-11-04 22:41 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-04 22:33 [9front] git: consistent args checking Kyle Milz
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).