diff --git a/src/git.cpp b/src/git.cpp index 6110e00..5cfefc6 100644 --- a/src/git.cpp +++ b/src/git.cpp @@ -19,10 +19,10 @@ #include "fs-compat.hpp" #include "json.hpp" -#include -#include #include +#include +#include #include #include #include @@ -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,18 +90,16 @@ 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) { - const string branch_name{out}; - size_t pos{branch_name.find(branch_prefix)}; - if (pos != string::npos) + pos += branch_prefix.size(); + uint64_t newid{stoull(branch_name.substr(pos))}; + if (newid > id) { - pos += branch_prefix.size(); - uint64_t newid{stoull(branch_name.substr(pos))}; - if (newid > id) - { - id = newid; - } + id = newid; } } git_reference_free(ref);