File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -171,7 +171,7 @@ int git_sysdir_set(git_sysdir_t which, const char *search_path)
171171 expand_path = strstr (search_path , PATH_MAGIC );
172172
173173 /* reset the default if this path has been cleared */
174- if (!search_path || expand_path )
174+ if (!search_path )
175175 git_sysdir__dirs [which ].guess (& git_sysdir__dirs [which ].buf );
176176
177177 /* if $PATH is not referenced, then just set the path */
Original file line number Diff line number Diff line change @@ -298,3 +298,24 @@ void test_core_env__2(void)
298298 git_buf_free (& path );
299299 git_buf_free (& found );
300300}
301+
302+ void test_core_env__substitution (void )
303+ {
304+ git_buf buf = GIT_BUF_INIT , expected = GIT_BUF_INIT ;
305+
306+ /* Set it to something non-default so we have controllable values */
307+ cl_git_pass (git_libgit2_opts (GIT_OPT_SET_SEARCH_PATH , GIT_CONFIG_LEVEL_GLOBAL , "/tmp/a" ));
308+ cl_git_pass (git_libgit2_opts (GIT_OPT_GET_SEARCH_PATH , GIT_CONFIG_LEVEL_GLOBAL , & buf ));
309+ cl_assert_equal_s ("/tmp/a" , buf .ptr );
310+
311+ git_buf_clear (& buf );
312+ cl_git_pass (git_buf_join (& buf , GIT_PATH_LIST_SEPARATOR , "$PATH" , "/tmp/b" ));
313+ cl_git_pass (git_libgit2_opts (GIT_OPT_SET_SEARCH_PATH , GIT_CONFIG_LEVEL_GLOBAL , buf .ptr ));
314+ cl_git_pass (git_libgit2_opts (GIT_OPT_GET_SEARCH_PATH , GIT_CONFIG_LEVEL_GLOBAL , & buf ));
315+
316+ cl_git_pass (git_buf_join (& expected , GIT_PATH_LIST_SEPARATOR , "/tmp/a" , "/tmp/b" ));
317+ cl_assert_equal_s (expected .ptr , buf .ptr );
318+
319+ git_buf_free (& expected );
320+ git_buf_free (& buf );
321+ }
You can’t perform that action at this time.
0 commit comments