summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2022-06-03 21:30:34 (GMT)
committerJunio C Hamano <gitster@pobox.com>2022-06-03 21:30:34 (GMT)
commitb3b2ddced295c26134568cf879488a921a352865 (patch)
tree2933bae2dd17545280f0bdcf38eca1e03d93d3bf /dir.c
parent83937e9592832408670da38bfe6e96c90ad63521 (diff)
parent89c6e450fe4a919ecb6fa698005a935531c732cf (diff)
downloadgit-b3b2ddced295c26134568cf879488a921a352865.zip
git-b3b2ddced295c26134568cf879488a921a352865.tar.gz
git-b3b2ddced295c26134568cf879488a921a352865.tar.bz2
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.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/dir.c b/dir.c
index 3633c08..6ca2ef5 100644
--- a/dir.c
+++ b/dir.c
@@ -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");
+}