]> Kevux Git Server - rit/commitdiff
Handle invalid argc gently
authorDmitry V. Levin <ldv@altlinux.org>
Thu, 14 Sep 2006 01:04:09 +0000 (05:04 +0400)
committerJunio C Hamano <junkio@cox.net>
Thu, 14 Sep 2006 18:48:11 +0000 (11:48 -0700)
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>
describe.c
git.c
merge-tree.c

index 5ed052d..ab192f8 100644 (file)
@@ -163,7 +163,7 @@ int main(int argc, char **argv)
 
        setup_git_directory();
 
-       if (i == argc)
+       if (argc <= i)
                describe("HEAD", 1);
        else
                while (i < argc) {
diff --git a/git.c b/git.c
index 47c85e1..8c182a5 100644 (file)
--- a/git.c
+++ b/git.c
@@ -294,7 +294,7 @@ static void handle_internal_command(int argc, const char **argv, char **envp)
 
 int main(int argc, const char **argv, char **envp)
 {
-       const char *cmd = argv[0];
+       const char *cmd = argv[0] ? argv[0] : "git-help";
        char *slash = strrchr(cmd, '/');
        const char *exec_path = NULL;
        int done_alias = 0;
index c154dcf..692ede0 100644 (file)
@@ -337,7 +337,7 @@ int main(int argc, char **argv)
        struct tree_desc t[3];
        void *buf1, *buf2, *buf3;
 
-       if (argc < 4)
+       if (argc != 4)
                usage(merge_tree_usage);
 
        setup_git_directory();