summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common-main.c2
-rw-r--r--exec_cmd.c10
-rw-r--r--exec_cmd.h2
-rw-r--r--git-compat-util.h4
-rw-r--r--git.c5
5 files changed, 12 insertions, 11 deletions
diff --git a/common-main.c b/common-main.c
index 44a29e8b13..c654f95551 100644
--- a/common-main.c
+++ b/common-main.c
@@ -33,7 +33,7 @@ int main(int argc, const char **argv)
git_setup_gettext();
- argv[0] = git_extract_argv0_path(argv[0]);
+ git_extract_argv0_path(argv[0]);
restore_sigpipe_to_default();
diff --git a/exec_cmd.c b/exec_cmd.c
index 9d5703a157..19ac2146d0 100644
--- a/exec_cmd.c
+++ b/exec_cmd.c
@@ -38,21 +38,17 @@ char *system_path(const char *path)
return strbuf_detach(&d, NULL);
}
-const char *git_extract_argv0_path(const char *argv0)
+void git_extract_argv0_path(const char *argv0)
{
const char *slash;
if (!argv0 || !*argv0)
- return NULL;
+ return;
slash = find_last_dir_sep(argv0);
- if (slash) {
+ if (slash)
argv0_path = xstrndup(argv0, slash - argv0);
- return slash + 1;
- }
-
- return argv0;
}
void git_set_argv_exec_path(const char *exec_path)
diff --git a/exec_cmd.h b/exec_cmd.h
index 1f6b43378b..ff0b48048a 100644
--- a/exec_cmd.h
+++ b/exec_cmd.h
@@ -4,7 +4,7 @@
struct argv_array;
extern void git_set_argv_exec_path(const char *exec_path);
-extern const char *git_extract_argv0_path(const char *path);
+extern void git_extract_argv0_path(const char *path);
extern const char *git_exec_path(void);
extern void setup_path(void);
extern const char **prepare_git_cmd(struct argv_array *out, const char **argv);
diff --git a/git-compat-util.h b/git-compat-util.h
index b4d9c2aa58..d89a78616b 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -1090,6 +1090,6 @@ struct tm *git_gmtime_r(const time_t *, struct tm *);
#define getc_unlocked(fh) getc(fh)
#endif
-#endif
-
extern int cmd_main(int, const char **);
+
+#endif
diff --git a/git.c b/git.c
index f914490e14..7acf290e23 100644
--- a/git.c
+++ b/git.c
@@ -616,6 +616,11 @@ int cmd_main(int argc, const char **argv)
cmd = argv[0];
if (!cmd)
cmd = "git-help";
+ else {
+ const char *slash = find_last_dir_sep(cmd);
+ if (slash)
+ cmd = slash + 1;
+ }
trace_command_performance(argv);