From: Junio C Hamano <junkio@cox.net>
To: Jonas Fonseca <fonseca@diku.dk>
Cc: Alex Riesen <raa.lkml@gmail.com>, git@vger.kernel.org
Subject: Re: [PATCH] revert/cherry-pick: allow the last parameter to be -h
Date: Tue, 22 May 2007 22:52:59 -0700 [thread overview]
Message-ID: <7v8xbg5bno.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <20070523053110.GA23971@diku.dk> (Jonas Fonseca's message of "Wed, 23 May 2007 07:31:11 +0200")
Jonas Fonseca <fonseca@diku.dk> writes:
> Junio C Hamano <junkio@cox.net> wrote Tue, May 22, 2007:
>> Alex Riesen <raa.lkml@gmail.com> writes:
>> ...
>> > Why should cherry-pick be different?
>>
>> Good question. FYI
>>
>> $ git rev-list --huh?
>>
>> works equally well ;-)
>
> Because it is different?
>
> $ git revert --why-must-it-be-so-hard-to-learn-git-sometimes
> fatal: Cannot find '--why-must-it-be-so-hard-to-learn-git-sometimes'
>
> Because, contrary to git-rev-list, git-revert/cherry-pick is considered
> part of the porcelain?
No, I did not notice it until now but you are right. The
command line argument parser for these commands is done somewhat
sloppily, compared to others.
How about doing something like this instead?
-- >8 --
Fix command line parameter parser of revert/cherry-pick
The parser was inconsistently done, in that it did not look at
the last command line parameter to see if it could be an unknown
option, although it was designed to notice unknown options if
they were given in positions the command expects to find them
(i.e. everything except the last parameter, which ought to be
<commit-ish>). This prevented a very natural invocation
$ git cherry-pick --help
from issuing the usage help.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
diff --git a/builtin-revert.c b/builtin-revert.c
index ea2f15b..80c348c 100644
--- a/builtin-revert.c
+++ b/builtin-revert.c
@@ -45,8 +45,10 @@ static void parse_options(int argc, const char **argv)
if (argc < 2)
usage(usage_str);
- for (i = 1; i < argc - 1; i++) {
+ for (i = 1; i < argc; i++) {
arg = argv[i];
+ if (arg[0] != '-')
+ break;
if (!strcmp(arg, "-n") || !strcmp(arg, "--no-commit"))
no_commit = 1;
else if (!strcmp(arg, "-e") || !strcmp(arg, "--edit"))
@@ -59,7 +61,8 @@ static void parse_options(int argc, const char **argv)
else if (strcmp(arg, "-r"))
usage(usage_str);
}
-
+ if (i != argc - 1)
+ usage(usage_str);
arg = argv[argc - 1];
if (get_sha1(arg, sha1))
die ("Cannot find '%s'", arg);
next prev parent reply other threads:[~2007-05-23 5:53 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-22 21:29 [PATCH] revert/cherry-pick: allow the last parameter to be -h Jonas Fonseca
2007-05-22 22:11 ` Alex Riesen
2007-05-22 22:23 ` Junio C Hamano
2007-05-23 5:31 ` Jonas Fonseca
2007-05-23 5:52 ` Junio C Hamano [this message]
2007-05-23 6:57 ` Jonas Fonseca
2007-05-23 7:04 ` Junio C Hamano
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=7v8xbg5bno.fsf@assigned-by-dhcp.cox.net \
--to=junkio@cox.net \
--cc=fonseca@diku.dk \
--cc=git@vger.kernel.org \
--cc=raa.lkml@gmail.com \
/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