diff options
| author | Carlos Martín Nieto <carlosmn@github.com> | 2018-05-16 11:56:04 +0200 |
|---|---|---|
| committer | Carlos Martín Nieto <carlosmn@github.com> | 2018-05-18 14:49:08 +0200 |
| commit | 0283fc4697988d1067946e781066da5fc1397175 (patch) | |
| tree | cbc95f917e3a0ffbd5e6c84c884eccc5ebd16f2b /src/path.c | |
| parent | 397abe9832a1baa7a822f4c63fa9730a3438aa7a (diff) | |
| download | libgit2-0283fc4697988d1067946e781066da5fc1397175.tar.gz | |
path: provide a generic dogit checking function for HFS
This lets us check for other kinds of reserved files.
Diffstat (limited to 'src/path.c')
| -rw-r--r-- | src/path.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/path.c b/src/path.c index ea0a3c3f6..e770e530b 100644 --- a/src/path.c +++ b/src/path.c @@ -1561,18 +1561,31 @@ static int32_t next_hfs_char(const char **in, size_t *len) return 0; /* NULL byte -- end of string */ } -static bool verify_dotgit_hfs(const char *path, size_t len) +static bool verify_dotgit_hfs_generic(const char *path, size_t len, const char *needle, size_t needle_len) { - if (next_hfs_char(&path, &len) != '.' || - next_hfs_char(&path, &len) != 'g' || - next_hfs_char(&path, &len) != 'i' || - next_hfs_char(&path, &len) != 't' || - next_hfs_char(&path, &len) != 0) + size_t i; + char c; + + if (next_hfs_char(&path, &len) != '.') + return true; + + for (i = 0; i < needle_len; i++) { + c = next_hfs_char(&path, &len); + if (c != needle[i]) + return true; + } + + if (next_hfs_char(&path, &len) != '\0') return true; return false; } +static bool verify_dotgit_hfs(const char *path, size_t len) +{ + return verify_dotgit_hfs_generic(path, len, "git", CONST_STRLEN("git")); +} + GIT_INLINE(bool) verify_dotgit_ntfs(git_repository *repo, const char *path, size_t len) { git_buf *reserved = git_repository__reserved_names_win32; |
