Skip to content

Commit 674875d

Browse files
authored
Merge pull request libgit2#5768 from lhchavez/midx-needs-refresh
midx: Fix a bug in `git_midx_needs_refresh()`
2 parents 487f2a8 + d50d3db commit 674875d

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/midx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ bool git_midx_needs_refresh(
359359
if (bytes_read != GIT_OID_RAWSZ)
360360
return true;
361361

362-
return git_oid_cmp(&idx_checksum, &idx->checksum) == 0;
362+
return !git_oid_equal(&idx_checksum, &idx->checksum);
363363
}
364364

365365
int git_midx_entry_find(

tests/pack/midx.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ void test_pack_midx__parse(void)
1515
cl_git_pass(git_repository_open(&repo, cl_fixture("testrepo.git")));
1616
cl_git_pass(git_buf_joinpath(&midx_path, git_repository_path(repo), "objects/pack/multi-pack-index"));
1717
cl_git_pass(git_midx_open(&idx, git_buf_cstr(&midx_path)));
18+
cl_assert_equal_i(git_midx_needs_refresh(idx, git_buf_cstr(&midx_path)), 0);
1819

1920
cl_git_pass(git_oid_fromstr(&id, "5001298e0c09ad9c34e4249bc5801c75e9754fa5"));
2021
cl_git_pass(git_midx_entry_find(&e, idx, &id, GIT_OID_HEXSZ));

0 commit comments

Comments
 (0)