summaryrefslogtreecommitdiff
path: root/t/t4013/diff.diff-tree_--patch-with-stat_initial
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2025-08-14 08:09:17 -0700
committerJunio C Hamano <gitster@pobox.com>2025-08-14 08:17:21 -0700
commit8655908b9eb00a47332d53bf73d9d7fb6cd1d569 (patch)
treeb0f3cd26b2792084e4180d206496a9d395093713 /t/t4013/diff.diff-tree_--patch-with-stat_initial
parent2c2ba49d55ff26c1082b8137b1ec5eeccb4337d1 (diff)
abbrev: allow extending beyond 32 chars to disambiguate
When you have two or more objects with object names that share more than 32 letters in an SHA-1 repository, find_unique_abbrev() fails to show disambiguation. To see how many leading letters of a given full object name is sufficiently unambiguous, the algorithm starts from a initial length, guessed based on the estimated number of objects in the repository, and see if another object that shares the prefix, and keeps extending the abbreviation. The loop stops at GIT_MAX_RAWSZ, which is counted as the number of bytes, since 5b20ace6 (sha1_name: unroll len loop in find_unique_abbrev_r(), 2017-10-08); before that change, it extended up to GIT_SHA1_HEXSZ, which meant to stop at the end of hexadecimal SHA-1 object name. Because the hexadecimal object name passed to the function is NUL-terminated, and this fact is used to correctly terminate the loop that scans for the first difference earlier in the function, use it to make sure we do not increment the .cur_len member beyond the end of the string. Noticed-by: Jon Forrest <nobozo@gmail.com> Helped-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t4013/diff.diff-tree_--patch-with-stat_initial')
0 files changed, 0 insertions, 0 deletions