From 5f4209de650cc8247a350f0c97c1897ddbc90125 Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Fri, 24 Mar 2023 11:35:52 +0100 Subject: libgit2: Remove use of deprecated functions... ...and enforce this through the build description. --- .../git_operations/git_config_settings.cpp | 38 ++++++++++------------ 1 file changed, 18 insertions(+), 20 deletions(-) (limited to 'src/other_tools/git_operations/git_config_settings.cpp') diff --git a/src/other_tools/git_operations/git_config_settings.cpp b/src/other_tools/git_operations/git_config_settings.cpp index 4423cfff..a6291c4b 100644 --- a/src/other_tools/git_operations/git_config_settings.cpp +++ b/src/other_tools/git_operations/git_config_settings.cpp @@ -298,8 +298,7 @@ auto GitConfigSettings::GetProxySettings(std::shared_ptr const& cfg, for (auto const& elem : matches) { if (git_config_parse_path(&tmp_buf, elem.second.c_str()) == 0) { - if (git_buf_contains_nul(&tmp_buf) == 0 and - tmp_buf.size == 0) { + if (tmp_buf.size == 0) { // cleanup memory git_buf_dispose(&tmp_buf); return ProxyInfo{std::nullopt}; @@ -314,31 +313,28 @@ auto GitConfigSettings::GetProxySettings(std::shared_ptr const& cfg, if (git_config_parse_path( &tmp_buf, matches.begin()->second.c_str()) == 0) { - if (git_buf_contains_nul(&tmp_buf) == 0) { - auto tmp_str = std::string(tmp_buf.ptr); - // cleanup memory - git_buf_dispose(&tmp_buf); - // get proxy url in standard form - auto proxy_info = - GetProxyAsPermissiveUrl(tmp_str); - if (not proxy_info) { - // unexpected behavior - (*logger)( - "While getting proxy " - "settings:\npermissive parsing of " - "remote-specific proxy URL failed", - true /*fatal*/); - return std::nullopt; - } - return proxy_info.value(); + auto tmp_str = std::string(tmp_buf.ptr); + // cleanup memory + git_buf_dispose(&tmp_buf); + // get proxy url in standard form + auto proxy_info = GetProxyAsPermissiveUrl(tmp_str); + if (not proxy_info) { + // unexpected behavior + (*logger)( + "While getting proxy " + "settings:\npermissive parsing of " + "remote-specific proxy URL failed", + true /*fatal*/); + return std::nullopt; } + return proxy_info.value(); } } // check the generic "http.proxy" gitconfig entry; // ignore errors if (git_config_get_string_buf( &tmp_buf, cfg.get(), R"(http.proxy)") == 0) { - if (git_buf_contains_nul(&tmp_buf) == 0) { + if (tmp_buf.size > 0) { auto tmp_str = std::string(tmp_buf.ptr); // cleanup memory git_buf_dispose(&tmp_buf); @@ -354,6 +350,8 @@ auto GitConfigSettings::GetProxySettings(std::shared_ptr const& cfg, } return proxy_info.value(); } + // cleanup memory + git_buf_dispose(&tmp_buf); } // check proxy envariables depending on the scheme auto url_scheme = parsed_url.value()->GetScheme(); -- cgit v1.2.3