From: Paul Mackerras <paulus@samba.org>
To: git@vger.kernel.org
Subject: [PATCH] trivial argument parsing patches
Date: Fri, 15 Apr 2005 21:28:01 +1000 [thread overview]
Message-ID: <16991.42305.118284.139777@cargo.ozlabs.ibm.com> (raw)
In perusing the git code, I noticed some errors in argument parsing,
which the patch below fixes. The show-diff error (checking argv[1]
each time around the loop) probably doesn't actually cause any real
problem, but it could be confusing for a novice if "show-diff x"
produces an error but "show-diff -s x" doesn't (and ignores the extra
argument).
Signed-off-by: Paul Mackerras <paulus@samba.org>
rev-tree.c: 7bf9e9a92f528485360f374239809714ce7a19f5
--- rev-tree.c
+++ rev-tree.c 2005-04-15 21:17:16.000000000 +1000
@@ -189,8 +189,8 @@
char *arg = argv[i];
if (!strcmp(arg, "--cache")) {
- read_cache_file(argv[2]);
i++;
+ read_cache_file(argv[i]);
continue;
}
show-diff.c: a531ca4078525d1c8dcf84aae0bfa89fed6e5d96
--- show-diff.c
+++ show-diff.c 2005-04-15 21:22:28.000000000 +1000
@@ -61,12 +61,10 @@
int entries = read_cache();
int i;
- while (argc-- > 1) {
- if (!strcmp(argv[1], "-s")) {
- silent = 1;
- continue;
- }
- usage("show-diff [-s]");
+ if (argc > 1) {
+ if (argc > 2 || strcmp(argv[1], "-s"))
+ usage("show-diff [-s]");
+ silent = 1;
}
if (entries < 0) {
reply other threads:[~2005-04-15 11:24 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=16991.42305.118284.139777@cargo.ozlabs.ibm.com \
--to=paulus@samba.org \
--cc=git@vger.kernel.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