Skip to content

Commit 482e385

Browse files
committed
Merge remote-tracking branch 'mathworks/longpath_filter_bug' into main
2 parents 0644c2e + 0d30e7b commit 482e385

File tree

2 files changed

+28
-7
lines changed

2 files changed

+28
-7
lines changed

src/blob.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,13 @@ static int write_file_filtered(
138138
git_object_size_t *size,
139139
git_odb *odb,
140140
const char *full_path,
141-
git_filter_list *fl)
141+
git_filter_list *fl,
142+
git_repository* repo)
142143
{
143144
int error;
144145
git_buf tgt = GIT_BUF_INIT;
145146

146-
error = git_filter_list_apply_to_file(&tgt, fl, NULL, full_path);
147+
error = git_filter_list_apply_to_file(&tgt, fl, repo, full_path);
147148

148149
/* Write the file to disk if it was properly filtered */
149150
if (!error) {
@@ -238,7 +239,7 @@ int git_blob__create_from_paths(
238239
error = write_file_stream(id, odb, content_path, size);
239240
else {
240241
/* We need to apply one or more filters */
241-
error = write_file_filtered(id, &size, odb, content_path, fl);
242+
error = write_file_filtered(id, &size, odb, content_path, fl, repo);
242243

243244
git_filter_list_free(fl);
244245
}

tests/win32/longpath.c

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,12 @@ void test_win32_longpath__workdir_path_validated(void)
6464
#endif
6565
}
6666

67-
void test_win32_longpath__status_and_add(void)
68-
{
6967
#ifdef GIT_WIN32
70-
git_repository *repo = cl_git_sandbox_init("testrepo");
68+
static void assert_longpath_status_and_add(git_repository* repo) {
7169
git_index *index;
7270
git_buf out = GIT_BUF_INIT;
7371
unsigned int status_flags;
7472

75-
cl_repo_set_bool(repo, "core.longpaths", true);
7673
cl_git_pass(git_repository_workdir_path(&out, repo, LONG_FILENAME));
7774

7875
cl_git_rewritefile(out.ptr, "This is a long path.\r\n");
@@ -88,5 +85,28 @@ void test_win32_longpath__status_and_add(void)
8885

8986
git_index_free(index);
9087
git_buf_dispose(&out);
88+
}
89+
#endif
90+
91+
void test_win32_longpath__status_and_add(void)
92+
{
93+
#ifdef GIT_WIN32
94+
git_repository *repo = cl_git_sandbox_init("testrepo");
95+
96+
cl_repo_set_bool(repo, "core.longpaths", true);
97+
98+
assert_longpath_status_and_add(repo);
99+
#endif
100+
}
101+
102+
void test_win32_longpath__status_and_add_with_filter(void)
103+
{
104+
#ifdef GIT_WIN32
105+
git_repository *repo = cl_git_sandbox_init("testrepo");
106+
107+
cl_repo_set_bool(repo, "core.longpaths", true);
108+
cl_repo_set_bool(repo, "core.autocrlf", true);
109+
110+
assert_longpath_status_and_add(repo);
91111
#endif
92112
}

0 commit comments

Comments
 (0)