diff options
| author | Junio C Hamano <gitster@pobox.com> | 2020-04-22 13:42:44 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2020-04-22 13:42:44 -0700 |
| commit | d01b722b7a077202c82902f49c48cb8081c696ef (patch) | |
| tree | 0a72203d0a9f8abd6f6efbaa9e87cd68b946604f /compat/win32/path-utils.h | |
| parent | Merge branch 'dr/midx-avoid-int-underflow' (diff) | |
| parent | run-command: trigger PATH lookup properly on Cygwin (diff) | |
| download | git-d01b722b7a077202c82902f49c48cb8081c696ef.tar.gz git-d01b722b7a077202c82902f49c48cb8081c696ef.zip | |
Merge branch 'ak/run-command-on-cygwin-fix'
Utitiles run via the run_command() API were not spawned correctly
on Cygwin, when the paths to them are given as a full path with
backslashes.
* ak/run-command-on-cygwin-fix:
run-command: trigger PATH lookup properly on Cygwin
Diffstat (limited to 'compat/win32/path-utils.h')
| -rw-r--r-- | compat/win32/path-utils.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/compat/win32/path-utils.h b/compat/win32/path-utils.h index f2e70872cd..bba2b64408 100644 --- a/compat/win32/path-utils.h +++ b/compat/win32/path-utils.h @@ -20,6 +20,17 @@ static inline char *win32_find_last_dir_sep(const char *path) return ret; } #define find_last_dir_sep win32_find_last_dir_sep +static inline int win32_has_dir_sep(const char *path) +{ + /* + * See how long the non-separator part of the given path is, and + * if and only if it covers the whole path (i.e. path[len] is NUL), + * there is no separator in the path---otherwise there is a separator. + */ + size_t len = strcspn(path, "/\\"); + return !!path[len]; +} +#define has_dir_sep(path) win32_has_dir_sep(path) int win32_offset_1st_component(const char *path); #define offset_1st_component win32_offset_1st_component |
