mirror of
https://github.com/git/git
synced 2024-08-25 10:45:59 +00:00
Merge branch 'ds/rev-parse-required-args' into maint
"git rev-parse" was loose in rejecting command line arguments that do not make sense, e.g. "--default" without the required value for that option. * ds/rev-parse-required-args: rev-parse: check i before using argv[i] against argc
This commit is contained in:
commit
c7b317320c
|
@ -547,15 +547,17 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!strcmp(arg, "--default")) {
|
if (!strcmp(arg, "--default")) {
|
||||||
def = argv[i+1];
|
def = argv[++i];
|
||||||
i++;
|
if (!def)
|
||||||
|
die("--default requires an argument");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!strcmp(arg, "--prefix")) {
|
if (!strcmp(arg, "--prefix")) {
|
||||||
prefix = argv[i+1];
|
prefix = argv[++i];
|
||||||
|
if (!prefix)
|
||||||
|
die("--prefix requires an argument");
|
||||||
startup_info->prefix = prefix;
|
startup_info->prefix = prefix;
|
||||||
output_prefix = 1;
|
output_prefix = 1;
|
||||||
i++;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!strcmp(arg, "--revs-only")) {
|
if (!strcmp(arg, "--revs-only")) {
|
||||||
|
@ -738,9 +740,12 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!strcmp(arg, "--resolve-git-dir")) {
|
if (!strcmp(arg, "--resolve-git-dir")) {
|
||||||
const char *gitdir = resolve_gitdir(argv[i+1]);
|
const char *gitdir = argv[++i];
|
||||||
if (!gitdir)
|
if (!gitdir)
|
||||||
die("not a gitdir '%s'", argv[i+1]);
|
die("--resolve-git-dir requires an argument");
|
||||||
|
gitdir = resolve_gitdir(gitdir);
|
||||||
|
if (!gitdir)
|
||||||
|
die("not a gitdir '%s'", argv[i]);
|
||||||
puts(gitdir);
|
puts(gitdir);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue