@@ -35,6 +35,8 @@ void test_config_include__absolute(void)
3535
3636 cl_git_pass (git_config_get_string_buf (& buf , cfg , "foo.bar.baz" ));
3737 cl_assert_equal_s ("huzzah" , git_buf_cstr (& buf ));
38+
39+ cl_git_pass (p_unlink ("config-include-absolute" ));
3840}
3941
4042void test_config_include__homedir (void )
@@ -48,6 +50,8 @@ void test_config_include__homedir(void)
4850 cl_assert_equal_s ("huzzah" , git_buf_cstr (& buf ));
4951
5052 cl_sandbox_set_search_path_defaults ();
53+
54+ cl_git_pass (p_unlink ("config-include-homedir" ));
5155}
5256
5357/* We need to pretend that the variables were defined where the file was included */
@@ -66,6 +70,9 @@ void test_config_include__ordering(void)
6670 git_buf_clear (& buf );
6771 cl_git_pass (git_config_get_string_buf (& buf , cfg , "foo.bar.baz" ));
6872 cl_assert_equal_s ("huzzah" , git_buf_cstr (& buf ));
73+
74+ cl_git_pass (p_unlink ("included" ));
75+ cl_git_pass (p_unlink ("including" ));
6976}
7077
7178/* We need to pretend that the variables were defined where the file was included */
@@ -76,8 +83,18 @@ void test_config_include__depth(void)
7683
7784 cl_git_fail (git_config_open_ondisk (& cfg , "a" ));
7885
79- p_unlink ("a" );
80- p_unlink ("b" );
86+ cl_git_pass (p_unlink ("a" ));
87+ cl_git_pass (p_unlink ("b" ));
88+ }
89+
90+ void test_config_include__empty_path_sanely_handled (void )
91+ {
92+ cl_git_mkfile ("a" , "[include]\npath" );
93+ cl_git_pass (git_config_open_ondisk (& cfg , "a" ));
94+ cl_git_pass (git_config_get_string_buf (& buf , cfg , "include.path" ));
95+ cl_assert_equal_s ("" , git_buf_cstr (& buf ));
96+
97+ cl_git_pass (p_unlink ("a" ));
8198}
8299
83100void test_config_include__missing (void )
@@ -89,6 +106,8 @@ void test_config_include__missing(void)
89106 cl_assert (giterr_last () == NULL );
90107 cl_git_pass (git_config_get_string_buf (& buf , cfg , "foo.bar" ));
91108 cl_assert_equal_s ("baz" , git_buf_cstr (& buf ));
109+
110+ cl_git_pass (p_unlink ("including" ));
92111}
93112
94113void test_config_include__missing_homedir (void )
@@ -103,6 +122,7 @@ void test_config_include__missing_homedir(void)
103122 cl_assert_equal_s ("baz" , git_buf_cstr (& buf ));
104123
105124 cl_sandbox_set_search_path_defaults ();
125+ cl_git_pass (p_unlink ("including" ));
106126}
107127
108128#define replicate10 (s ) s s s s s s s s s s
@@ -122,6 +142,10 @@ void test_config_include__depth2(void)
122142 git_buf_clear (& buf );
123143 cl_git_pass (git_config_get_string_buf (& buf , cfg , "foo.bar2" ));
124144 cl_assert_equal_s ("baz2" , git_buf_cstr (& buf ));
145+
146+ cl_git_pass (p_unlink ("top-level" ));
147+ cl_git_pass (p_unlink ("middle" ));
148+ cl_git_pass (p_unlink ("bottom" ));
125149}
126150
127151void test_config_include__removing_include_removes_values (void )
@@ -132,6 +156,9 @@ void test_config_include__removing_include_removes_values(void)
132156 cl_git_pass (git_config_open_ondisk (& cfg , "top-level" ));
133157 cl_git_mkfile ("top-level" , "" );
134158 cl_git_fail (git_config_get_string_buf (& buf , cfg , "foo.bar" ));
159+
160+ cl_git_pass (p_unlink ("top-level" ));
161+ cl_git_pass (p_unlink ("included" ));
135162}
136163
137164void test_config_include__rewriting_include_refreshes_values (void )
@@ -145,6 +172,10 @@ void test_config_include__rewriting_include_refreshes_values(void)
145172 cl_git_fail (git_config_get_string_buf (& buf , cfg , "foo.bar" ));
146173 cl_git_pass (git_config_get_string_buf (& buf , cfg , "first.other" ));
147174 cl_assert_equal_s (buf .ptr , "value" );
175+
176+ cl_git_pass (p_unlink ("top-level" ));
177+ cl_git_pass (p_unlink ("first" ));
178+ cl_git_pass (p_unlink ("second" ));
148179}
149180
150181void test_config_include__included_variables_cannot_be_deleted (void )
@@ -154,13 +185,20 @@ void test_config_include__included_variables_cannot_be_deleted(void)
154185
155186 cl_git_pass (git_config_open_ondisk (& cfg , "top-level" ));
156187 cl_git_fail (git_config_delete_entry (cfg , "foo.bar" ));
188+
189+ cl_git_pass (p_unlink ("top-level" ));
190+ cl_git_pass (p_unlink ("included" ));
157191}
158192
159193void test_config_include__included_variables_cannot_be_modified (void )
160194{
161195 cl_git_mkfile ("top-level" , "[include]\npath = included\n" );
196+
162197 cl_git_mkfile ("included" , "[foo]\nbar = value" );
163198
164199 cl_git_pass (git_config_open_ondisk (& cfg , "top-level" ));
165200 cl_git_fail (git_config_set_string (cfg , "foo.bar" , "other-value" ));
201+
202+ cl_git_pass (p_unlink ("top-level" ));
203+ cl_git_pass (p_unlink ("included" ));
166204}
0 commit comments