summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Dmitry V. Levin <ldv@altlinux.org>2006-09-14 05:04:09 +0400
committerLibravatar Junio C Hamano <junkio@cox.net>2006-09-14 11:48:11 -0700
commit5b6df8e45f31c7eb26c30536448cffe1b715e1ce (patch)
tree07277e193c5db09b3f9715bdc6d0a9ff1d294821
parentAdd "-h/-H" parsing to "git grep" (diff)
downloadtgif-5b6df8e45f31c7eb26c30536448cffe1b715e1ce.tar.xz
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>
-rw-r--r--describe.c2
-rw-r--r--git.c2
-rw-r--r--merge-tree.c2
3 files changed, 3 insertions, 3 deletions
diff --git a/describe.c b/describe.c
index 5ed052d3a1..ab192f83ae 100644
--- a/describe.c
+++ b/describe.c
@@ -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 47c85e10d1..8c182a5f55 100644
--- 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;
diff --git a/merge-tree.c b/merge-tree.c
index c154dcfc02..692ede0e3d 100644
--- a/merge-tree.c
+++ b/merge-tree.c
@@ -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();