diff options
author | Maksim Denisov <denisov.maksim@huawei.com> | 2024-10-02 12:27:42 +0200 |
---|---|---|
committer | Maksim Denisov <denisov.maksim@huawei.com> | 2024-10-07 13:37:39 +0200 |
commit | f56805ddde51ffcfdd6123300b6c049764a86980 (patch) | |
tree | 0b18734f5a60bddec7bb44c32b4027529de056e8 /src/other_tools/git_operations/git_repo_remote.cpp | |
parent | e2555394980ab4d1d8b938fec0ad8d246d7745b4 (diff) | |
download | justbuild-f56805ddde51ffcfdd6123300b6c049764a86980.tar.gz |
Replace manual new allocations for git_strarray with std::vectors
...and remove unused code from git_utils
Diffstat (limited to 'src/other_tools/git_operations/git_repo_remote.cpp')
-rw-r--r-- | src/other_tools/git_operations/git_repo_remote.cpp | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/src/other_tools/git_operations/git_repo_remote.cpp b/src/other_tools/git_operations/git_repo_remote.cpp index 810df860..b9b9cc93 100644 --- a/src/other_tools/git_operations/git_repo_remote.cpp +++ b/src/other_tools/git_operations/git_repo_remote.cpp @@ -361,20 +361,16 @@ auto GitRepoRemote::FetchFromRemote(std::shared_ptr<git_config> cfg, fetch_opts.update_fetchhead = 0; // setup fetch refspecs array - git_strarray refspecs_array_obj{}; + GitStrArray refspecs_array_obj; if (branch) { // make sure we check for tags as well - std::string tag = fmt::format("+refs/tags/{}", *branch); - std::string head = fmt::format("+refs/heads/{}", *branch); - PopulateStrarray(&refspecs_array_obj, {tag, head}); + refspecs_array_obj.AddEntry(fmt::format("+refs/tags/{}", *branch)); + refspecs_array_obj.AddEntry(fmt::format("+refs/heads/{}", *branch)); } - auto refspecs_array = - std::unique_ptr<git_strarray, decltype(&strarray_deleter)>( - &refspecs_array_obj, strarray_deleter); + auto const refspecs_array = refspecs_array_obj.Get(); if (git_remote_fetch( - remote.get(), refspecs_array.get(), &fetch_opts, nullptr) != - 0) { + remote.get(), &refspecs_array, &fetch_opts, nullptr) != 0) { (*logger)( fmt::format("Fetching{} in git repository {} failed " "with:\n{}", |