diff options
author | lhchavez <lhchavez@lhchavez.com> | 2021-01-07 05:43:30 -0800 |
---|---|---|
committer | lhchavez <lhchavez@lhchavez.com> | 2021-01-07 06:37:11 -0800 |
commit | d50d3db64a7c3a80479954440b373237ee2d716f (patch) | |
tree | 367dbddf37917b4e2e99ea0fdf5d6b2dacdcc940 | |
parent | ba6824db5b6fed0e241c6323451d9237a8466a68 (diff) | |
download | libgit2-d50d3db64a7c3a80479954440b373237ee2d716f.tar.gz |
midx: Fix a bug in `git_midx_needs_refresh()`
The very last check in the freshness check for the midx was wrong ><
This was also because this function was not tested.
-rw-r--r-- | src/midx.c | 2 | ||||
-rw-r--r-- | tests/pack/midx.c | 1 |
2 files changed, 2 insertions, 1 deletions
diff --git a/src/midx.c b/src/midx.c index ee93b03c1..60858716d 100644 --- a/src/midx.c +++ b/src/midx.c @@ -364,7 +364,7 @@ bool git_midx_needs_refresh( if (bytes_read != GIT_OID_RAWSZ) return true; - return git_oid_cmp(&idx_checksum, &idx->checksum) == 0; + return !git_oid_equal(&idx_checksum, &idx->checksum); } int git_midx_entry_find( diff --git a/tests/pack/midx.c b/tests/pack/midx.c index 92d9ae24c..0d7efbef1 100644 --- a/tests/pack/midx.c +++ b/tests/pack/midx.c @@ -15,6 +15,7 @@ void test_pack_midx__parse(void) cl_git_pass(git_repository_open(&repo, cl_fixture("testrepo.git"))); cl_git_pass(git_buf_joinpath(&midx_path, git_repository_path(repo), "objects/pack/multi-pack-index")); cl_git_pass(git_midx_open(&idx, git_buf_cstr(&midx_path))); + cl_assert_equal_i(git_midx_needs_refresh(idx, git_buf_cstr(&midx_path)), 0); cl_git_pass(git_oid_fromstr(&id, "5001298e0c09ad9c34e4249bc5801c75e9754fa5")); cl_git_pass(git_midx_entry_find(&e, idx, &id, GIT_OID_HEXSZ)); |