mirror of
https://github.com/git/git.git
synced 2024-10-30 05:47:53 +01:00
Merge branch 'ds/rev-parse-required-args'
"git rev-parse --default" without the required option argument did not diagnose it as an error. * ds/rev-parse-required-args: rev-parse: check i before using argv[i] against argc
This commit is contained in:
commit
28006fb046
1 changed files with 11 additions and 6 deletions
|
@ -547,15 +547,17 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
|
|||
continue;
|
||||
}
|
||||
if (!strcmp(arg, "--default")) {
|
||||
def = argv[i+1];
|
||||
i++;
|
||||
def = argv[++i];
|
||||
if (!def)
|
||||
die("--default requires an argument");
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(arg, "--prefix")) {
|
||||
prefix = argv[i+1];
|
||||
prefix = argv[++i];
|
||||
if (!prefix)
|
||||
die("--prefix requires an argument");
|
||||
startup_info->prefix = prefix;
|
||||
output_prefix = 1;
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(arg, "--revs-only")) {
|
||||
|
@ -738,9 +740,12 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
|
|||
continue;
|
||||
}
|
||||
if (!strcmp(arg, "--resolve-git-dir")) {
|
||||
const char *gitdir = resolve_gitdir(argv[i+1]);
|
||||
const char *gitdir = argv[++i];
|
||||
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);
|
||||
continue;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue