diff options
author | Junio C Hamano <gitster@pobox.com> | 2022-06-03 14:30:34 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-06-03 14:30:34 -0700 |
commit | b3b2ddced295c26134568cf879488a921a352865 (patch) | |
tree | 2933bae2dd17545280f0bdcf38eca1e03d93d3bf /dir.c | |
parent | 83937e9592832408670da38bfe6e96c90ad63521 (diff) | |
parent | 89c6e450fe4a919ecb6fa698005a935531c732cf (diff) | |
download | git-b3b2ddced295c26134568cf879488a921a352865.tar.gz |
Merge branch 'ds/bundle-uri'
Preliminary code refactoring around transport and bundle code.
* ds/bundle-uri:
bundle.h: make "fd" version of read_bundle_header() public
remote: allow relative_url() to return an absolute url
remote: move relative_url()
http: make http_get_file() external
fetch-pack: move --keep=* option filling to a function
fetch-pack: add a deref_without_lazy_fetch_extended()
dir API: add a generalized path_match_flags() function
connect.c: refactor sending of agent & object-format
Diffstat (limited to 'dir.c')
-rw-r--r-- | dir.c | 29 |
1 files changed, 29 insertions, 0 deletions
@@ -3955,3 +3955,32 @@ void relocate_gitdir(const char *path, const char *old_git_dir, const char *new_ connect_work_tree_and_git_dir(path, new_git_dir, 0); } + +int path_match_flags(const char *const str, const enum path_match_flags flags) +{ + const char *p = str; + + if (flags & PATH_MATCH_NATIVE && + flags & PATH_MATCH_XPLATFORM) + BUG("path_match_flags() must get one match kind, not multiple!"); + else if (!(flags & PATH_MATCH_KINDS_MASK)) + BUG("path_match_flags() must get at least one match kind!"); + + if (flags & PATH_MATCH_STARTS_WITH_DOT_SLASH && + flags & PATH_MATCH_STARTS_WITH_DOT_DOT_SLASH) + BUG("path_match_flags() must get one platform kind, not multiple!"); + else if (!(flags & PATH_MATCH_PLATFORM_MASK)) + BUG("path_match_flags() must get at least one platform kind!"); + + if (*p++ != '.') + return 0; + if (flags & PATH_MATCH_STARTS_WITH_DOT_DOT_SLASH && + *p++ != '.') + return 0; + + if (flags & PATH_MATCH_NATIVE) + return is_dir_sep(*p); + else if (flags & PATH_MATCH_XPLATFORM) + return is_xplatform_dir_sep(*p); + BUG("unreachable"); +} |