mirror of
https://github.com/git/git.git
synced 2026-03-03 12:57:59 +01:00
Merge branch 'ds/bundle-uri' into next
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
This commit is contained in:
29
dir.c
29
dir.c
@@ -3946,3 +3946,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");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user