From 42f530bdcdd1ea4e4638f95460ab4899157ec2b4 Mon Sep 17 00:00:00 2001 From: Derrick Stolee Date: Mon, 26 Feb 2018 09:07:43 -0500 Subject: [PATCH 1/2] sha1_name: fix uninitialized memory errors --- sha1_name.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/sha1_name.c b/sha1_name.c index f6e06877305b87..0137c9581a5f2e 100644 --- a/sha1_name.c +++ b/sha1_name.c @@ -557,17 +557,14 @@ static void find_abbrev_len_for_midx(struct midxed_git *m, * nearby for the abbreviation length. */ mad->init_len = 0; - if (!match) { - nth_midxed_object_oid(&oid, m, first); + if (!match && nth_midxed_object_oid(&oid, m, first)) extend_abbrev_len(&oid, mad); - } else if (first < m->num_objects - 1) { - nth_midxed_object_oid(&oid, m, first + 1); + else if (first < m->num_objects - 1 && + nth_midxed_object_oid(&oid, m, first + 1)) extend_abbrev_len(&oid, mad); - } - if (first > 0) { - nth_midxed_object_oid(&oid, m, first - 1); + if (first > 0 && nth_midxed_object_oid(&oid, m, first - 1)) extend_abbrev_len(&oid, mad); - } + mad->init_len = mad->cur_len; } @@ -609,17 +606,12 @@ static void find_abbrev_len_for_pack(struct packed_git *p, * nearby for the abbreviation length. */ mad->init_len = 0; - if (!match) { - nth_packed_object_oid(&oid, p, first); + if (!match && nth_packed_object_oid(&oid, p, first)) extend_abbrev_len(&oid, mad); - } else if (first < num - 1) { - nth_packed_object_oid(&oid, p, first + 1); + if (first < num - 1 && nth_packed_object_oid(&oid, p, first + 1)) extend_abbrev_len(&oid, mad); - } - if (first > 0) { - nth_packed_object_oid(&oid, p, first - 1); + if (first > 0 && nth_packed_object_oid(&oid, p, first - 1)) extend_abbrev_len(&oid, mad); - } mad->init_len = mad->cur_len; } From 7cdbbf08acfc3fb109947289a53bcd4722737cab Mon Sep 17 00:00:00 2001 From: Derrick Stolee Date: Mon, 26 Feb 2018 09:08:29 -0500 Subject: [PATCH 2/2] revision.c: reduce odb queries during mark_parents_uninteresting() --- revision.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/revision.c b/revision.c index 72f2b4572ee798..799215852d4ce0 100644 --- a/revision.c +++ b/revision.c @@ -113,7 +113,8 @@ void mark_parents_uninteresting(struct commit *commit) * it is popped next time around, we won't be trying * to parse it and get an error. */ - if (!has_object_file(&commit->object.oid)) + if (!commit->object.parsed && + !has_object_file(&commit->object.oid)) commit->object.parsed = 1; if (commit->object.flags & UNINTERESTING)