mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-03 14:12:22 +00:00
allow (ignore) bare slash in gitignore
This commit is contained in:
parent
17776314c8
commit
2d160ef782
@ -397,7 +397,8 @@ int git_attr_fnmatch__parse(
|
|||||||
|
|
||||||
*base = scan;
|
*base = scan;
|
||||||
|
|
||||||
spec->length = scan - pattern;
|
if ((spec->length = scan - pattern) == 0)
|
||||||
|
return GIT_ENOTFOUND;
|
||||||
|
|
||||||
if (pattern[spec->length - 1] == '/') {
|
if (pattern[spec->length - 1] == '/') {
|
||||||
spec->length--;
|
spec->length--;
|
||||||
|
@ -194,6 +194,11 @@ char *git_pool_strndup(git_pool *pool, const char *str, size_t n)
|
|||||||
|
|
||||||
assert(pool && str && pool->item_size == sizeof(char));
|
assert(pool && str && pool->item_size == sizeof(char));
|
||||||
|
|
||||||
|
if (n + 1 == 0) {
|
||||||
|
giterr_set_oom();
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if ((ptr = git_pool_malloc(pool, (uint32_t)(n + 1))) != NULL) {
|
if ((ptr = git_pool_malloc(pool, (uint32_t)(n + 1))) != NULL) {
|
||||||
memcpy(ptr, str, n);
|
memcpy(ptr, str, n);
|
||||||
*(((char *)ptr) + n) = '\0';
|
*(((char *)ptr) + n) = '\0';
|
||||||
|
@ -34,6 +34,27 @@ void test_attr_ignore__honor_temporary_rules(void)
|
|||||||
assert_is_ignored(true, "NewFolder/NewFolder/File.txt");
|
assert_is_ignored(true, "NewFolder/NewFolder/File.txt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void test_attr_ignore__allow_root(void)
|
||||||
|
{
|
||||||
|
cl_git_rewritefile("attr/.gitignore", "/");
|
||||||
|
|
||||||
|
assert_is_ignored(false, "File.txt");
|
||||||
|
assert_is_ignored(false, "NewFolder");
|
||||||
|
assert_is_ignored(false, "NewFolder/NewFolder");
|
||||||
|
assert_is_ignored(false, "NewFolder/NewFolder/File.txt");
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_attr_ignore__ignore_root(void)
|
||||||
|
{
|
||||||
|
cl_git_rewritefile("attr/.gitignore", "/\n\n/NewFolder\n/NewFolder/NewFolder");
|
||||||
|
|
||||||
|
assert_is_ignored(false, "File.txt");
|
||||||
|
assert_is_ignored(true, "NewFolder");
|
||||||
|
assert_is_ignored(true, "NewFolder/NewFolder");
|
||||||
|
assert_is_ignored(true, "NewFolder/NewFolder/File.txt");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void test_attr_ignore__skip_gitignore_directory(void)
|
void test_attr_ignore__skip_gitignore_directory(void)
|
||||||
{
|
{
|
||||||
cl_git_rewritefile("attr/.git/info/exclude", "/NewFolder\n/NewFolder/NewFolder");
|
cl_git_rewritefile("attr/.git/info/exclude", "/NewFolder\n/NewFolder/NewFolder");
|
||||||
|
@ -133,3 +133,13 @@ void test_core_pool__free_list(void)
|
|||||||
|
|
||||||
git_pool_clear(&p);
|
git_pool_clear(&p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void test_core_pool__strndup_limit(void)
|
||||||
|
{
|
||||||
|
git_pool p;
|
||||||
|
|
||||||
|
cl_git_pass(git_pool_init(&p, 1, 100));
|
||||||
|
cl_assert(git_pool_strndup(&p, "foo", -1) == NULL);
|
||||||
|
git_pool_clear(&p);
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user