Made git branch iteration more compact.

This commit is contained in:
tastytea 2020-07-01 22:10:58 +02:00
parent 09e31b676c
commit 9d043bec3f
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07

View File

@ -19,10 +19,10 @@
#include "fs-compat.hpp"
#include "json.hpp"
#include <cstdint>
#include <fstream>
#include <git2.h>
#include <cstdint>
#include <fstream>
#include <stdexcept>
#include <string>
#include <string_view>
@ -82,7 +82,7 @@ uint64_t get_last_id()
uint64_t id{0};
git_branch_iterator *it;
if (git_branch_iterator_new(&it, _repo, GIT_BRANCH_ALL) == 0)
if (git_branch_iterator_new(&it, _repo, GIT_BRANCH_REMOTE) == 0)
{
git_reference *ref;
git_branch_t type;
@ -90,9 +90,8 @@ uint64_t get_last_id()
{
const char *out{nullptr};
git_branch_name(&out, ref);
if (type == GIT_BRANCH_REMOTE)
{
const string branch_name{out};
size_t pos{branch_name.find(branch_prefix)};
if (pos != string::npos)
{
@ -103,7 +102,6 @@ uint64_t get_last_id()
id = newid;
}
}
}
git_reference_free(ref);
}
git_branch_iterator_free(it);