aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2025-04-17 10:28:19 -0700
committerJunio C Hamano <gitster@pobox.com>2025-04-17 10:28:19 -0700
commitc81538ea6cf4612a6ec2128c2bdb94abdbda8b97 (patch)
tree1112613c3e1557060631be6ae7cbfc9b7f7f555d
parent4a3d816dd2d36cee3fec058f08c3a48815680b87 (diff)
parentf1fb0644650a3c2ca5f957e29c626924c870b6cc (diff)
downloadgit-c81538ea6cf4612a6ec2128c2bdb94abdbda8b97.tar.gz
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
-rw-r--r--refs/packed-backend.c4
-rwxr-xr-xt/t1408-packed-refs.sh15
2 files changed, 17 insertions, 2 deletions
diff --git a/refs/packed-backend.c b/refs/packed-backend.c
index 94fb655b72..3ad1ed0787 100644
--- a/refs/packed-backend.c
+++ b/refs/packed-backend.c
@@ -980,9 +980,9 @@ static int packed_ref_iterator_advance(struct ref_iterator *ref_iterator)
continue;
while (prefix && *prefix) {
- if (*refname < *prefix)
+ if ((unsigned char)*refname < (unsigned char)*prefix)
BUG("packed-refs backend yielded reference preceding its prefix");
- else if (*refname > *prefix)
+ else if ((unsigned char)*refname > (unsigned char)*prefix)
return ITER_DONE;
prefix++;
refname++;
diff --git a/t/t1408-packed-refs.sh b/t/t1408-packed-refs.sh
index 41ba1f1d7f..833477f0fa 100755
--- a/t/t1408-packed-refs.sh
+++ b/t/t1408-packed-refs.sh
@@ -42,4 +42,19 @@ test_expect_success 'no error from stale entry in packed-refs' '
test_cmp expect actual
'
+test_expect_success 'list packed refs with unicode characters' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+ test_commit --no-tag A &&
+ git update-ref refs/heads/ HEAD &&
+ git update-ref refs/heads/z HEAD &&
+ git pack-refs --all &&
+ printf "%s commit\trefs/heads/z\n" $(git rev-parse HEAD) >expect &&
+ git for-each-ref refs/heads/z >actual &&
+ test_cmp expect actual
+ )
+'
+
test_done