Skip to content

Commit 83e4b75

Browse files
bk2204gitster
authored andcommitted
tree-walk: replace hard-coded constants with the_hash_algo
Remove the hard-coded 20-based values and replace them with uses of the_hash_algo. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 509f6f6 commit 83e4b75

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

tree-walk.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ static int decode_tree_entry(struct tree_desc *desc, const char *buf, unsigned l
2626
{
2727
const char *path;
2828
unsigned int mode, len;
29+
const unsigned hashsz = the_hash_algo->rawsz;
2930

30-
if (size < 23 || buf[size - 21]) {
31+
if (size < hashsz + 3 || buf[size - (hashsz + 1)]) {
3132
strbuf_addstr(err, _("too-short tree object"));
3233
return -1;
3334
}

0 commit comments

Comments
 (0)