@@ -35,6 +35,7 @@ void test_index_crlf__cleanup(void)
3535
3636struct compare_data
3737{
38+ const char * systype ;
3839 const char * dirname ;
3940 const char * safecrlf ;
4041 const char * autocrlf ;
@@ -50,11 +51,14 @@ static int add_and_check_file(void *payload, git_buf *actual_path)
5051 char * basename ;
5152 const git_index_entry * entry ;
5253 git_blob * blob ;
54+ bool failed = true;
5355
5456 basename = git_path_basename (actual_path -> ptr );
5557
56- if (!strcmp (basename , ".git" ) || !strcmp (basename , ".gitattributes" ))
57- return 0 ;
58+ if (!strcmp (basename , ".git" ) || !strcmp (basename , ".gitattributes" )) {
59+ failed = false;
60+ goto done ;
61+ }
5862
5963 cl_git_pass (git_buf_joinpath (& expected_path , cd -> dirname , basename ));
6064
@@ -68,16 +72,19 @@ static int add_and_check_file(void *payload, git_buf *actual_path)
6872 cl_git_pass (git_blob_lookup (& blob , g_repo , & entry -> id ));
6973
7074 cl_git_pass (git_futils_readbuffer (& expected_contents , expected_path .ptr ));
71- cl_assert_equal_s (expected_contents , git_blob_rawcontent (blob ));
75+
76+ if (strcmp (expected_contents .ptr , git_blob_rawcontent (blob )) != 0 )
77+ goto done ;
7278
7379 git_blob_free (blob );
7480 } else if (git_path_isfile (expected_path_fail .ptr )) {
7581 cl_git_pass (git_futils_readbuffer (& expected_contents , expected_path_fail .ptr ));
7682 git_buf_rtrim (& expected_contents );
7783
78- cl_git_fail (git_index_add_bypath (g_index , basename ));
79- cl_assert_equal_i (GITERR_FILTER , giterr_last ()-> klass );
80- cl_assert_equal_s (expected_contents .ptr , giterr_last ()-> message );
84+ if (git_index_add_bypath (g_index , basename ) == 0 ||
85+ giterr_last ()-> klass != GITERR_FILTER ||
86+ strcmp (expected_contents .ptr , giterr_last ()-> message ) != 0 )
87+ goto done ;
8188 } else {
8289 cl_fail ("unexpected index failure" );
8390 }
@@ -101,13 +108,21 @@ static int add_and_check_file(void *payload, git_buf *actual_path)
101108 return 0 ;
102109}
103110
111+ static const char * system_type (void )
112+ {
113+ if (GIT_EOL_NATIVE == GIT_EOL_CRLF )
114+ return "windows" ;
115+ else
116+ return "posix" ;
117+ }
118+
104119static void test_add_index (const char * safecrlf , const char * autocrlf , const char * attrs )
105120{
106121 git_buf attrbuf = GIT_BUF_INIT ;
107122 git_buf expected_dirname = GIT_BUF_INIT ;
108123 git_buf sandboxname = GIT_BUF_INIT ;
109124 git_buf reponame = GIT_BUF_INIT ;
110- struct compare_data compare_data = { NULL , safecrlf , autocrlf , attrs };
125+ struct compare_data compare_data = { system_type (), NULL , safecrlf , autocrlf , attrs };
111126 const char * c ;
112127
113128 git_buf_puts (& reponame , "crlf" );
@@ -139,7 +154,9 @@ static void test_add_index(const char *safecrlf, const char *autocrlf, const cha
139154
140155 cl_git_pass (git_index_clear (g_index ));
141156
142- git_buf_joinpath (& expected_dirname , "crlf_data" , "posix_to_odb" );
157+ git_buf_joinpath (& expected_dirname , "crlf_data" , system_type ());
158+ git_buf_puts (& expected_dirname , "_to_odb" );
159+
143160 git_buf_joinpath (& expected_fixture , expected_dirname .ptr , sandboxname .ptr );
144161 cl_fixture_sandbox (expected_fixture .ptr );
145162
0 commit comments