diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2023-03-24 11:35:52 +0100 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2023-03-24 12:07:28 +0100 |
commit | 5f4209de650cc8247a350f0c97c1897ddbc90125 (patch) | |
tree | d51abc067f96cbafc73558c93fbc9b966766d457 /src | |
parent | ed3dae4478b45229c80177122346985d6042c250 (diff) | |
download | justbuild-5f4209de650cc8247a350f0c97c1897ddbc90125.tar.gz |
libgit2: Remove use of deprecated functions...
...and enforce this through the build description.
Diffstat (limited to 'src')
-rw-r--r-- | src/other_tools/git_operations/git_config_settings.cpp | 38 |
1 files changed, 18 insertions, 20 deletions
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<git_config> 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<git_config> 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<git_config> 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(); |