Handle invalid argc gently
describe, git: Handle argc==0 case the same way as argc==1. merge-tree: Refuse excessive arguments. Signed-off-by: Dmitry V. Levin <ldv@altlinux.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Dmitry V. Levin committed
Sep 14, 2006 at 05:04 UTC
5b6df8e45f31c7eb26c30536448cffe1b715e1ce
3 files changed
+3
-3
describe.c
+1
-1
@@ -163,7 +163,7 @@ int main(int argc, char **argv)
163
164
setup_git_directory();
165
166
- if (i == argc)
166
+ if (argc <= i)
167
describe("HEAD", 1);
168
else
169
while (i < argc) {
git.c
+1
-1
@@ -294,7 +294,7 @@ static void handle_internal_command(int argc, const char **argv, char **envp)
294
295
int main(int argc, const char **argv, char **envp)
296
{
297
- const char *cmd = argv[0];
297
+ const char *cmd = argv[0] ? argv[0] : "git-help";
298
char *slash = strrchr(cmd, '/');
299
const char *exec_path = NULL;
300
int done_alias = 0;
merge-tree.c
+1
-1
@@ -337,7 +337,7 @@ int main(int argc, char **argv)
337
struct tree_desc t[3];
338
void *buf1, *buf2, *buf3;
339
340
- if (argc < 4)
340
+ if (argc != 4)
341
usage(merge_tree_usage);
342
343
setup_git_directory();