diff options
author | Alexander Kuleshov <kuleshovmail@gmail.com> | 2016-02-19 14:44:48 +0600 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-02-19 13:26:38 -0800 |
commit | f45982337aab3b3d289692027ce00b130b967ffa (patch) | |
tree | 399e9a7fb899d839a1ea52ae6932341d2fbbf048 /exec_cmd.c | |
parent | a2558fb8e1e387b630312311e1d22c95663da5d0 (diff) | |
download | git-f45982337aab3b3d289692027ce00b130b967ffa.tar.gz |
exec_cmd.c: use find_last_dir_sep() for code simplificationak/extract-argv0-last-dir-sep
We are trying to extract dirname from argv0 in the git_extract_argv0_path().
But in the same time, the <git-compat-util.h> provides find_last_dir_sep()
to get dirname from a given path. Let's use it instead of loop for the code
simplification.
Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'exec_cmd.c')
-rw-r--r-- | exec_cmd.c | 6 |
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; } |