rev-parse: put all options under the "-" check
The option-parsing loop of rev-parse checks whether the first character of an arg is "-". If so, then it enters a series of conditionals checking for individual options. But some options are inexplicably outside of that outer conditional. This doesn't produce the wrong behavior; the conditional is actually redundant with the individual option checks, and it's really only its fallback "continue" that we care about. But we should at least be consistent. One obvious alternative is that we could get rid of the conditional entirely. But we'll be using the extra block it provides in the next patch. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
e05e2ae8fe
commit
9033addfa6
@ -652,6 +652,14 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
|
|||||||
did_repo_setup = 1;
|
did_repo_setup = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (*arg == '-') {
|
||||||
|
if (!strcmp(arg, "--")) {
|
||||||
|
as_is = 2;
|
||||||
|
/* Pass on the "--" if we show anything but files.. */
|
||||||
|
if (filter & (DO_FLAGS | DO_REVS))
|
||||||
|
show_file(arg, 0);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (!strcmp(arg, "--git-path")) {
|
if (!strcmp(arg, "--git-path")) {
|
||||||
if (!argv[i + 1])
|
if (!argv[i + 1])
|
||||||
die("--git-path requires an argument");
|
die("--git-path requires an argument");
|
||||||
@ -675,15 +683,6 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
|
|||||||
show(arg);
|
show(arg);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*arg == '-') {
|
|
||||||
if (!strcmp(arg, "--")) {
|
|
||||||
as_is = 2;
|
|
||||||
/* Pass on the "--" if we show anything but files.. */
|
|
||||||
if (filter & (DO_FLAGS | DO_REVS))
|
|
||||||
show_file(arg, 0);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!strcmp(arg, "--default")) {
|
if (!strcmp(arg, "--default")) {
|
||||||
def = argv[++i];
|
def = argv[++i];
|
||||||
if (!def)
|
if (!def)
|
||||||
|
Loading…
Reference in New Issue
Block a user