Skip to content

Commit 6cf9a0b

Browse files
committed
Refactor shared code in longpath test.
1 parent 26bf94c commit 6cf9a0b

File tree

1 file changed

+12
-22
lines changed

1 file changed

+12
-22
lines changed

tests/win32/longpath.c

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

67-
void test_win32_longpath__status_and_add(void)
68-
{
69-
#ifdef GIT_WIN32
70-
git_repository *repo = cl_git_sandbox_init("testrepo");
67+
static void assert_longpath_status_and_add(git_repository* repo) {
7168
git_index *index;
7269
git_buf out = GIT_BUF_INIT;
7370
unsigned int status_flags;
7471

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

7874
cl_git_rewritefile(out.ptr, "This is a long path.\r\n");
@@ -88,33 +84,27 @@ void test_win32_longpath__status_and_add(void)
8884

8985
git_index_free(index);
9086
git_buf_dispose(&out);
91-
#endif
9287
}
9388

94-
void test_win32_longpath__status_and_add_with_filter(void)
89+
void test_win32_longpath__status_and_add(void)
9590
{
9691
#ifdef GIT_WIN32
9792
git_repository *repo = cl_git_sandbox_init("testrepo");
98-
git_index *index;
99-
git_buf out = GIT_BUF_INIT;
100-
unsigned int status_flags;
10193

10294
cl_repo_set_bool(repo, "core.longpaths", true);
103-
cl_repo_set_bool(repo, "core.autocrlf", true);
104-
cl_git_pass(git_repository_workdir_path(&out, repo, LONG_FILENAME));
10595

106-
cl_git_rewritefile(out.ptr, "This is a long path.\r\n");
107-
108-
cl_git_pass(git_status_file(&status_flags, repo, LONG_FILENAME));
109-
cl_assert_equal_i(GIT_STATUS_WT_NEW, status_flags);
96+
assert_longpath_status_and_add(repo);
97+
#endif
98+
}
11099

111-
cl_git_pass(git_repository_index(&index, repo));
112-
cl_git_pass(git_index_add_bypath(index, LONG_FILENAME));
100+
void test_win32_longpath__status_and_add_with_filter(void)
101+
{
102+
#ifdef GIT_WIN32
103+
git_repository *repo = cl_git_sandbox_init("testrepo");
113104

114-
cl_git_pass(git_status_file(&status_flags, repo, LONG_FILENAME));
115-
cl_assert_equal_i(GIT_STATUS_INDEX_NEW, status_flags);
105+
cl_repo_set_bool(repo, "core.longpaths", true);
106+
cl_repo_set_bool(repo, "core.autocrlf", true);
116107

117-
git_index_free(index);
118-
git_buf_dispose(&out);
108+
assert_longpath_status_and_add(repo);
119109
#endif
120110
}

0 commit comments

Comments
 (0)