Skip to content

Commit

Permalink
git_extract_argv0_path(): Move check for valid argv0 from caller to c…
Browse files Browse the repository at this point in the history
…allee

This simplifies the calling code.

Signed-off-by: Steffen Prohaska <prohaska@zib.de>
Acked-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Steffen Prohaska authored and Junio C Hamano committed Jan 26, 2009
1 parent 4dd47c3 commit 2cd72b0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 5 additions & 1 deletion exec_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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--;
Expand Down
5 changes: 2 additions & 3 deletions git.c
Original file line number Diff line number Diff line change
Expand Up @@ -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";

/*
Expand Down

0 comments on commit 2cd72b0

Please sign in to comment.