diff options
author | Russell Belfer <rb@github.com> | 2014-04-14 15:59:48 -0700 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2014-04-14 15:59:48 -0700 |
commit | a9528b8fdd627e11b9dee099a10fa7697380b3e7 (patch) | |
tree | e7a54e8f5694d6cb37223e480bdab7e5bb104a65 /tests/clar_libgit2.c | |
parent | 289e31cd24f80fa8ed77e40eeb9295964256cb6a (diff) | |
download | libgit2-a9528b8fdd627e11b9dee099a10fa7697380b3e7.tar.gz |
Fix core.excludesfile named .gitignorerb/fix-leading-slash-ignores
Ignore rules with slashes in them are matched using FNM_PATHNAME
and use the path to the .gitignore file from the root of the
repository along with the path fragment (including slashes) in
the ignore file itself. Unfortunately, the relative path to the
.gitignore file was being applied to the global core.excludesfile
if that was also named ".gitignore".
This fixes that with more precise matching and includes test for
ignore rules with leading slashes (which were the primary example
of this being broken in the real world).
This also backports an improvement to the file context logic from
the threadsafe-iterators branch where we don't rely on mutating
the key of the attribute file name to generate the context path.
Diffstat (limited to 'tests/clar_libgit2.c')
-rw-r--r-- | tests/clar_libgit2.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/clar_libgit2.c b/tests/clar_libgit2.c index 9b062ef78..90e53c5e6 100644 --- a/tests/clar_libgit2.c +++ b/tests/clar_libgit2.c @@ -490,3 +490,24 @@ void clar__assert_equal_file( clar__assert_equal(file, line, "mismatched file length", 1, "%"PRIuZ, (size_t)expected_bytes, (size_t)total_bytes); } + +void cl_fake_home(git_buf *restore) +{ + git_buf path = GIT_BUF_INIT; + + cl_git_pass(git_libgit2_opts( + GIT_OPT_GET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, restore)); + + cl_must_pass(p_mkdir("home", 0777)); + cl_git_pass(git_path_prettify(&path, "home", NULL)); + cl_git_pass(git_libgit2_opts( + GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, path.ptr)); + git_buf_free(&path); +} + +void cl_fake_home_cleanup(git_buf *restore) +{ + cl_git_pass(git_libgit2_opts( + GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, restore->ptr)); + git_buf_free(restore); +} |