summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--exec_cmd.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/exec_cmd.c b/exec_cmd.c
index e85f0fd8d8..680b257cd5 100644
--- a/exec_cmd.c
+++ b/exec_cmd.c
@@ -43,12 +43,10 @@ const char *git_extract_argv0_path(const char *argv0)
if (!argv0 || !*argv0)
return NULL;
- slash = argv0 + strlen(argv0);
- while (argv0 <= slash && !is_dir_sep(*slash))
- slash--;
+ slash = find_last_dir_sep(argv0);
- if (slash >= argv0) {
+ if (slash) {
argv0_path = xstrndup(argv0, slash - argv0);
return slash + 1;
}