From: Steffen Prohaska Date: Sun, 18 Jan 2009 12:00:11 +0000 (+0100) Subject: git_extract_argv0_path(): Move check for valid argv0 from caller to callee X-Git-Tag: v1.6.2-rc0~48^2~4 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=2cd72b0b290e40fb4d6a925ce26603503f01aa09;p=git.git git_extract_argv0_path(): Move check for valid argv0 from caller to callee This simplifies the calling code. Signed-off-by: Steffen Prohaska Acked-by: Johannes Sixt Signed-off-by: Junio C Hamano --- diff --git a/exec_cmd.c b/exec_cmd.c index e508f1e66..f8f416b64 100644 --- a/exec_cmd.c +++ b/exec_cmd.c @@ -22,7 +22,11 @@ const char *system_path(const char *path) const char *git_extract_argv0_path(const char *argv0) { - const char *slash = argv0 + strlen(argv0); + const char *slash; + + if (!argv0 || !*argv0) + return NULL; + slash = argv0 + strlen(argv0); while (argv0 <= slash && !is_dir_sep(*slash)) slash--; diff --git a/git.c b/git.c index bf21e21ce..320cb4356 100644 --- a/git.c +++ b/git.c @@ -444,9 +444,8 @@ int main(int argc, const char **argv) { const char *cmd; - if (argv[0] && *argv[0]) - cmd = git_extract_argv0_path(argv[0]); - else + cmd = git_extract_argv0_path(argv[0]); + if (!cmd) cmd = "git-help"; /*