summaryrefslogtreecommitdiff
path: root/builtin/rev-parse.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2014-02-27 22:01:23 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-02-27 22:01:23 (GMT)
commit28006fb046ddeaf15f8fe9c7cf2a122e2091451b (patch)
treec5ef16266723aa3d78d85b7ab8bec15168e1b0ec /builtin/rev-parse.c
parent1e745453fee88b3322b8be05548220c31cf654cd (diff)
parenta43219f2aaa39fbc53ba0aee2481e1cca3c0e649 (diff)
downloadgit-28006fb046ddeaf15f8fe9c7cf2a122e2091451b.zip
git-28006fb046ddeaf15f8fe9c7cf2a122e2091451b.tar.gz
git-28006fb046ddeaf15f8fe9c7cf2a122e2091451b.tar.bz2
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
Diffstat (limited to 'builtin/rev-parse.c')
-rw-r--r--builtin/rev-parse.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index aaeb611..45901df 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -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;
}