Skip to content

Commit

Permalink
ignore GIT_OPT_DISABLE_READNG_PACKED_TAGS if packed-refs is not sorted
Browse files Browse the repository at this point in the history
If packed-refs is not sorted, refs/tags can preceed refs/heads. We
definitely want to read the latter, so we cannot stop parsing early.

I don't know how but some users manage to create packed-refs that's
not sorted. Moreover, they manage to place refs/heads/master into
packed-refs. See romkatv/powerlevel10k#1428.
  • Loading branch information
romkatv committed Jun 11, 2021
1 parent 82cefe2 commit 5860a42
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/refdb_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ static int packref_cmp(const void *a_, const void *b_)
static int packed_reload(refdb_fs_backend *backend)
{
int error;
bool sorted = false;
git_buf packedrefs = GIT_BUF_INIT;
char *scan, *eof, *eol;

Expand Down Expand Up @@ -126,6 +127,8 @@ static int packed_reload(refdb_fs_backend *backend)
backend->peeling_mode = PEELING_STANDARD;
}

sorted = strstr(scan, " sorted ") != NULL;

scan = eol + 1;
}
}
Expand Down Expand Up @@ -155,7 +158,7 @@ static int packed_reload(refdb_fs_backend *backend)
eol[-1] = '\0';

// don't scan refs > refs/tags/
if (git_refdb__disable_reading_packed_tags && strcmp(scan, "refs/tags/") > 0) break;
if (sorted && git_refdb__disable_reading_packed_tags && strcmp(scan, "refs/tags/") > 0) break;

if (git_sortedcache_upsert((void **)&ref, backend->refcache, scan) < 0)
goto parse_failed;
Expand Down

0 comments on commit 5860a42

Please sign in to comment.