@@ -1634,13 +1634,40 @@ static bool is_filesystem_case_insensitive(const char *gitdir_path)
16341634 return is_insensitive ;
16351635}
16361636
1637- static bool are_symlinks_supported (const char * wd_path )
1637+ /*
1638+ * Return a configuration object with only the global and system
1639+ * configurations; no repository-level configuration.
1640+ */
1641+ static int load_global_config (git_config * * config )
16381642{
1639- git_config * config = NULL ;
16401643 git_buf global_buf = GIT_BUF_INIT ;
16411644 git_buf xdg_buf = GIT_BUF_INIT ;
16421645 git_buf system_buf = GIT_BUF_INIT ;
16431646 git_buf programdata_buf = GIT_BUF_INIT ;
1647+ int error ;
1648+
1649+ git_config_find_global (& global_buf );
1650+ git_config_find_xdg (& xdg_buf );
1651+ git_config_find_system (& system_buf );
1652+ git_config_find_programdata (& programdata_buf );
1653+
1654+ error = load_config (config , NULL ,
1655+ path_unless_empty (& global_buf ),
1656+ path_unless_empty (& xdg_buf ),
1657+ path_unless_empty (& system_buf ),
1658+ path_unless_empty (& programdata_buf ));
1659+
1660+ git_buf_dispose (& global_buf );
1661+ git_buf_dispose (& xdg_buf );
1662+ git_buf_dispose (& system_buf );
1663+ git_buf_dispose (& programdata_buf );
1664+
1665+ return error ;
1666+ }
1667+
1668+ static bool are_symlinks_supported (const char * wd_path )
1669+ {
1670+ git_config * config = NULL ;
16441671 int symlinks = 0 ;
16451672
16461673 /*
@@ -1651,30 +1678,16 @@ static bool are_symlinks_supported(const char *wd_path)
16511678 * _not_ set, then we do not test or enable symlink support.
16521679 */
16531680#ifdef GIT_WIN32
1654- git_config_find_global (& global_buf );
1655- git_config_find_xdg (& xdg_buf );
1656- git_config_find_system (& system_buf );
1657- git_config_find_programdata (& programdata_buf );
1658-
1659- if (load_config (& config , NULL ,
1660- path_unless_empty (& global_buf ),
1661- path_unless_empty (& xdg_buf ),
1662- path_unless_empty (& system_buf ),
1663- path_unless_empty (& programdata_buf )) < 0 )
1664- goto done ;
1665-
1666- if (git_config_get_bool (& symlinks , config , "core.symlinks" ) < 0 || !symlinks )
1681+ if (load_global_config (& config ) < 0 ||
1682+ git_config_get_bool (& symlinks , config , "core.symlinks" ) < 0 ||
1683+ !symlinks )
16671684 goto done ;
16681685#endif
16691686
16701687 if (!(symlinks = git_path_supports_symlinks (wd_path )))
16711688 goto done ;
16721689
16731690done :
1674- git_buf_dispose (& global_buf );
1675- git_buf_dispose (& xdg_buf );
1676- git_buf_dispose (& system_buf );
1677- git_buf_dispose (& programdata_buf );
16781691 git_config_free (config );
16791692 return symlinks != 0 ;
16801693}
0 commit comments