summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurence McGlashan <laurence.mcglashan@gmail.com>2021-09-14 12:19:54 +0100
committerLaurence McGlashan <laurence.mcglashan@gmail.com>2021-09-14 12:19:54 +0100
commit26bf94c07b444a10108086174513e50e42fb9d4c (patch)
tree2c8735dc56946576689d37cae236fe5cfbdfd686
parentf1b89a201e9329e6df48f8d6cf320781570c936a (diff)
downloadlibgit2-26bf94c07b444a10108086174513e50e42fb9d4c.tar.gz
If longpaths is true and filters are enabled, pass git_repository through the filtering code to ensure the cached longpath setting is returned.
Fixes: #6054
-rw-r--r--src/blob.c7
-rw-r--r--tests/win32/longpath.c28
2 files changed, 32 insertions, 3 deletions
diff --git a/src/blob.c b/src/blob.c
index 01ebf075e..79096ee95 100644
--- a/src/blob.c
+++ b/src/blob.c
@@ -138,12 +138,13 @@ static int write_file_filtered(
git_object_size_t *size,
git_odb *odb,
const char *full_path,
- git_filter_list *fl)
+ git_filter_list *fl,
+ git_repository* repo)
{
int error;
git_buf tgt = GIT_BUF_INIT;
- error = git_filter_list_apply_to_file(&tgt, fl, NULL, full_path);
+ error = git_filter_list_apply_to_file(&tgt, fl, repo, full_path);
/* Write the file to disk if it was properly filtered */
if (!error) {
@@ -238,7 +239,7 @@ int git_blob__create_from_paths(
error = write_file_stream(id, odb, content_path, size);
else {
/* We need to apply one or more filters */
- error = write_file_filtered(id, &size, odb, content_path, fl);
+ error = write_file_filtered(id, &size, odb, content_path, fl, repo);
git_filter_list_free(fl);
}
diff --git a/tests/win32/longpath.c b/tests/win32/longpath.c
index ebfcc4d0d..4bc8a837d 100644
--- a/tests/win32/longpath.c
+++ b/tests/win32/longpath.c
@@ -90,3 +90,31 @@ void test_win32_longpath__status_and_add(void)
git_buf_dispose(&out);
#endif
}
+
+void test_win32_longpath__status_and_add_with_filter(void)
+{
+#ifdef GIT_WIN32
+ git_repository *repo = cl_git_sandbox_init("testrepo");
+ git_index *index;
+ git_buf out = GIT_BUF_INIT;
+ unsigned int status_flags;
+
+ cl_repo_set_bool(repo, "core.longpaths", true);
+ cl_repo_set_bool(repo, "core.autocrlf", true);
+ cl_git_pass(git_repository_workdir_path(&out, repo, LONG_FILENAME));
+
+ cl_git_rewritefile(out.ptr, "This is a long path.\r\n");
+
+ cl_git_pass(git_status_file(&status_flags, repo, LONG_FILENAME));
+ cl_assert_equal_i(GIT_STATUS_WT_NEW, status_flags);
+
+ cl_git_pass(git_repository_index(&index, repo));
+ cl_git_pass(git_index_add_bypath(index, LONG_FILENAME));
+
+ cl_git_pass(git_status_file(&status_flags, repo, LONG_FILENAME));
+ cl_assert_equal_i(GIT_STATUS_INDEX_NEW, status_flags);
+
+ git_index_free(index);
+ git_buf_dispose(&out);
+#endif
+}