Skip to content

Commit

Permalink
Merge branch 'jk/common-main'
Browse files Browse the repository at this point in the history
Fix for a small regression in a topic already in 'master'.

* jk/common-main:
  common-main: stop munging argv[0] path
  • Loading branch information
gitster committed Nov 29, 2016
2 parents 061eeff + 6854a8f commit 95c2b13
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion common-main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
10 changes: 3 additions & 7 deletions exec_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion exec_cmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions git.c
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,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);

Expand Down

0 comments on commit 95c2b13

Please sign in to comment.