Squashed 'gitstatus/' changes from 113f1f69..96b520b2
96b520b2 build v1.5.1 binaries for all platforms ffeb0507 bump version to v1.5.1 1bcbea07 mbuild: disable pacman upgrades on msys 39dbb92f log a warning if unable to parse packed-refs a9d70ec0 add `-r` flag to gitstatus_start in bash bindings (#241) abbf9a79 don't use static_assert with one argument as it's not available prior to c++17 (#239) f8c396e4 drop all tags if packed-refs doesn't have a header line (https://github.com/romkatv/powerlevel10k/issues/1428) git-subtree-dir: gitstatus git-subtree-split: 96b520b248ca872646e27b3df4535898356e4637
This commit is contained in:
parent
ba83466e1d
commit
96f3ca1733
6 changed files with 64 additions and 35 deletions
|
@ -54,7 +54,7 @@ long ParseInt(const char* s) {
|
|||
}
|
||||
|
||||
size_t ParseSizeT(const char* s) {
|
||||
static_assert(sizeof(long) <= sizeof(size_t));
|
||||
static_assert(sizeof(long) <= sizeof(size_t), "");
|
||||
long res = ParseLong(s);
|
||||
return res >= 0 ? res : -1;
|
||||
}
|
||||
|
|
|
@ -212,14 +212,30 @@ void TagDb::ParsePack() {
|
|||
char* p = &pack_[0];
|
||||
char* e = p + pack_.size();
|
||||
|
||||
if (*p == '#') {
|
||||
char* eol = std::strchr(p, '\n');
|
||||
if (!eol) return;
|
||||
*eol = 0;
|
||||
if (!std::strstr(p, " fully-peeled") || !std::strstr(p, " sorted")) return;
|
||||
p = eol + 1;
|
||||
// Usually packed-refs starts with the following line:
|
||||
//
|
||||
// # pack-refs with: peeled fully-peeled sorted
|
||||
//
|
||||
// However, some users can produce pack-refs without this line.
|
||||
// See https://github.com/romkatv/powerlevel10k/issues/1428.
|
||||
// I don't know how they do it. Without the header line we cannot
|
||||
// assume that refs are sorted, which isn't a big deal because we
|
||||
// can just sort them. What's worse is that refs cannot be assumed
|
||||
// to be fully-peeled. We don't want to peel them, so we just drop
|
||||
// all tags.
|
||||
if (*p != '#') {
|
||||
LOG(WARN) << "packed-refs doesn't have a header. Won't resolve tags.";
|
||||
return;
|
||||
}
|
||||
|
||||
char* eol = std::strchr(p, '\n');
|
||||
if (!eol) return;
|
||||
*eol = 0;
|
||||
if (!std::strstr(p, " fully-peeled") || !std::strstr(p, " sorted")) {
|
||||
LOG(WARN) << "packed-refs has unexpected header. Won't resolve tags.";
|
||||
}
|
||||
p = eol + 1;
|
||||
|
||||
name2id_.reserve(pack_.size() / 128);
|
||||
id2name_.reserve(pack_.size() / 128);
|
||||
|
||||
|
@ -249,7 +265,10 @@ void TagDb::ParsePack() {
|
|||
id2name_.push_back(tag);
|
||||
}
|
||||
|
||||
VERIFY(std::is_sorted(name2id_.begin(), name2id_.end(), ByName));
|
||||
if (!std::is_sorted(name2id_.begin(), name2id_.end(), ByName)) {
|
||||
// "sorted" in the header of packed-refs promisses that this won't trigger.
|
||||
std::sort(name2id_.begin(), name2id_.end(), ByName);
|
||||
}
|
||||
|
||||
id2name_dirty_ = true;
|
||||
GlobalThreadPool()->Schedule([this] {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue