8000 win32: ensure content filtering occurs in longpath test · libgit2/libgit2@005c740 · GitHub
[go: up one dir, main page]

Skip to content

Commit 005c740

Browse files
committed
win32: ensure content filtering occurs in longpath test
1 parent 482e385 commit 005c740

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

tests/win32/longpath.c

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,16 @@ void test_win32_longpath__workdir_path_validated(void)
6565
}
6666

6767
#ifdef GIT_WIN32
68-
static void assert_longpath_status_and_add(git_repository* repo) {
68+
static void assert_longpath_status_and_add(git_repository *repo, const char *wddata, const char *repodata) {
6969
git_index *index;
70+
git_blob *blob;
7071
git_buf out = GIT_BUF_INIT;
72+
const git_index_entry *entry;
7173
unsigned int status_flags;
7274

7375
cl_git_pass(git_repository_workdir_path(&out, repo, LONG_FILENAME));
7476

75-
cl_git_rewritefile(out.ptr, "This is a long path.\r\n");
77+
cl_git_rewritefile(out.ptr, wddata);
7678

7779
cl_git_pass(git_status_file(&status_flags, repo, LONG_FILENAME));
7880
cl_assert_equal_i(GIT_STATUS_WT_NEW, status_flags);
@@ -83,6 +85,11 @@ static void assert_longpath_status_and_add(git_repository* repo) {
8385
cl_git_pass(git_status_file(&status_flags, repo, LONG_FILENAME));
8486
cl_assert_equal_i(GIT_STATUS_INDEX_NEW, status_flags);
8587

88+
cl_assert((entry = git_index_get_bypath(index, LONG_FILENAME, 0)) != NULL);
89+
cl_git_pass(git_blob_lookup(&blob, repo, &entry->id));
90+
cl_assert_equal_s(repodata, git_blob_rawcontent(blob));
91+
92+
git_blob_free(blob);
8693
git_index_free(index);
8794
git_buf_dispose(&out);
8895
}
@@ -95,7 +102,13 @@ void test_win32_longpath__status_and_add(void)
95102

96103
cl_repo_set_bool(repo, "core.longpaths", true);
97104

98-
assert_longpath_status_and_add(repo);
105+
/*
106+
* Doing no content filtering, we expect the data we add
107+
* to be the data in the repository.
108+
*/
109+
assert_longpath_status_and_add(repo,
110+
"This is a long path.\r\n",
111+
"This is a long path.\r\n");
99112
#endif
100113
}
101114

@@ -107,6 +120,12 @@ void test_win32_longpath__status_and_add_with_filter(void)
107120
cl_repo_set_bool(repo, "core.longpaths", true);
108121
cl_repo_set_bool(repo, "core.autocrlf", true);
109122

110-
assert_longpath_status_and_add(repo);
123+
/*
124+
* With `core.autocrlf`, we expect the data we add to have
125+
* newline conversion performed.
126+
*/
127+
assert_longpath_status_and_add(repo,
128+
"This is a long path.\r\n",
129+
"This is a long path.\n");
111130
#endif
112131
}

0 commit comments

Comments
 (0)
0