Skip to content

Commit c81538e

Browse files
committed
Merge branch 'ps/refname-avail-check-optim'
Incorrect sorting of refs with bytes with high-bit set on platforms with signed char led to a BUG, which has been corrected. * ps/refname-avail-check-optim: refs/packed: fix BUG when seeking refs with UTF-8 characters
2 parents 4a3d816 + f1fb064 commit c81538e

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

refs/packed-backend.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -980,9 +980,9 @@ static int packed_ref_iterator_advance(struct ref_iterator *ref_iterator)
980980
continue;
981981

982982
while (prefix && *prefix) {
983-
if (*refname < *prefix)
983+
if ((unsigned char)*refname < (unsigned char)*prefix)
984984
BUG("packed-refs backend yielded reference preceding its prefix");
985-
else if (*refname > *prefix)
985+
else if ((unsigned char)*refname > (unsigned char)*prefix)
986986
return ITER_DONE;
987987
prefix++;
988988
refname++;

t/t1408-packed-refs.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,19 @@ test_expect_success 'no error from stale entry in packed-refs' '
4242
test_cmp expect actual
4343
'
4444

45+
test_expect_success 'list packed refs with unicode characters' '
46+
test_when_finished "rm -rf repo" &&
47+
git init repo &&
48+
(
49+
cd repo &&
50+
test_commit --no-tag A &&
51+
git update-ref refs/heads/ HEAD &&
52+
git update-ref refs/heads/z HEAD &&
53+
git pack-refs --all &&
54+
printf "%s commit\trefs/heads/z\n" $(git rev-parse HEAD) >expect &&
55+
git for-each-ref refs/heads/z >actual &&
56+
test_cmp expect actual
57+
)
58+
'
59+
4560
test_done

0 commit comments

Comments
 (0)