Commit 2cd72b0b authored by Steffen Prohaska's avatar Steffen Prohaska Committed by Junio C Hamano

git_extract_argv0_path(): Move check for valid argv0 from caller to callee

This simplifies the calling code.
Signed-off-by: default avatarSteffen Prohaska <prohaska@zib.de>
Acked-by: default avatarJohannes Sixt <j6t@kdbg.org>
Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
parent 4dd47c3b
......@@ -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--;
......
......@@ -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";
/*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment