diff options
author | Russell Belfer <rb@github.com> | 2014-04-15 02:59:48 +0400 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2014-04-15 02:59:48 +0400 |
commit | a9528b8fdd627e11b9dee099a10fa7697380b3e7 (patch) | |
tree | e7a54e8f5694d6cb37223e480bdab7e5bb104a65 /tests/attr | |
parent | 289e31cd24f80fa8ed77e40eeb9295964256cb6a (diff) |
Fix core.excludesfile named .gitignore
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/attr')
-rw-r--r-- | tests/attr/ignore.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/tests/attr/ignore.c b/tests/attr/ignore.c index 4ed92387c..a83c5bd74 100644 --- a/tests/attr/ignore.c +++ b/tests/attr/ignore.c @@ -130,22 +130,18 @@ void test_attr_ignore__skip_gitignore_directory(void) void test_attr_ignore__expand_tilde_to_homedir(void) { - git_buf path = GIT_BUF_INIT; + git_buf cleanup = GIT_BUF_INIT; git_config *cfg; assert_is_ignored(false, "example.global_with_tilde"); - /* construct fake home with fake global excludes */ - - 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)); + cl_fake_home(&cleanup); - cl_git_mkfile("home/globalexcludes", "# found me\n*.global_with_tilde\n"); + /* construct fake home with fake global excludes */ + cl_git_mkfile("home/globalexclude", "# found me\n*.global_with_tilde\n"); cl_git_pass(git_repository_config(&cfg, g_repo)); - cl_git_pass(git_config_set_string(cfg, "core.excludesfile", "~/globalexcludes")); + cl_git_pass(git_config_set_string(cfg, "core.excludesfile", "~/globalexclude")); git_config_free(cfg); git_attr_cache_flush(g_repo); /* must reset to pick up change */ @@ -154,8 +150,9 @@ void test_attr_ignore__expand_tilde_to_homedir(void) cl_git_pass(git_futils_rmdir_r("home", NULL, GIT_RMDIR_REMOVE_FILES)); - cl_git_pass(git_libgit2_opts( - GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, NULL)); + cl_fake_home_cleanup(&cleanup); - git_buf_free(&path); + git_attr_cache_flush(g_repo); /* must reset to pick up change */ + + assert_is_ignored(false, "example.global_with_tilde"); } |