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>
maint
Dmitry V. Levin 2006-09-14 05:04:09 +04:00 committed by Junio C Hamano
parent 7977f0ea53
commit 5b6df8e45f
3 changed files with 3 additions and 3 deletions

View File

@ -163,7 +163,7 @@ int main(int argc, char **argv)


setup_git_directory(); setup_git_directory();


if (i == argc) if (argc <= i)
describe("HEAD", 1); describe("HEAD", 1);
else else
while (i < argc) { while (i < argc) {

2
git.c
View File

@ -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) 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, '/'); char *slash = strrchr(cmd, '/');
const char *exec_path = NULL; const char *exec_path = NULL;
int done_alias = 0; int done_alias = 0;

View File

@ -337,7 +337,7 @@ int main(int argc, char **argv)
struct tree_desc t[3]; struct tree_desc t[3];
void *buf1, *buf2, *buf3; void *buf1, *buf2, *buf3;


if (argc < 4) if (argc != 4)
usage(merge_tree_usage); usage(merge_tree_usage);


setup_git_directory(); setup_git_directory();