mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-02 16:34:37 +00:00
revwalk: introduce tests that hide old commits
Introduce some tests that show some commits, while hiding some commits that have a timestamp older than the common ancestors of these two commits.
This commit is contained in:
parent
e8ab13b3fd
commit
565fb8dcd4
@ -28,8 +28,8 @@ static int foreach_cb(const git_oid *oid, void *data)
|
||||
|
||||
/*
|
||||
* $ git --git-dir tests/resources/testrepo.git count-objects --verbose
|
||||
* count: 47
|
||||
* size: 4
|
||||
* count: 60
|
||||
* size: 240
|
||||
* in-pack: 1640
|
||||
* packs: 3
|
||||
* size-pack: 425
|
||||
@ -44,7 +44,7 @@ void test_odb_foreach__foreach(void)
|
||||
git_repository_odb(&_odb, _repo);
|
||||
|
||||
cl_git_pass(git_odb_foreach(_odb, foreach_cb, &nobj));
|
||||
cl_assert_equal_i(47 + 1640, nobj); /* count + in-pack */
|
||||
cl_assert_equal_i(60 + 1640, nobj); /* count + in-pack */
|
||||
}
|
||||
|
||||
void test_odb_foreach__one_pack(void)
|
||||
@ -118,7 +118,7 @@ void test_odb_foreach__files_in_objects_dir(void)
|
||||
|
||||
cl_git_pass(git_repository_odb(&odb, repo));
|
||||
cl_git_pass(git_odb_foreach(odb, foreach_cb, &nobj));
|
||||
cl_assert_equal_i(47 + 1640, nobj); /* count + in-pack */
|
||||
cl_assert_equal_i(60 + 1640, nobj); /* count + in-pack */
|
||||
|
||||
git_odb_free(odb);
|
||||
git_repository_free(repo);
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -473,3 +473,51 @@ void test_revwalk_basic__big_timestamp(void)
|
||||
git_signature_free(sig);
|
||||
|
||||
}
|
||||
|
||||
/* Ensure that we correctly hide a commit that is (timewise) older
|
||||
* than the commits that we are showing.
|
||||
*
|
||||
* % git rev-list 8e73b76..bd75801
|
||||
* bd758010071961f28336333bc41e9c64c9a64866
|
||||
*/
|
||||
void test_revwalk_basic__old_hidden_commit_one(void)
|
||||
{
|
||||
git_oid new_id, old_id, oid;
|
||||
|
||||
revwalk_basic_setup_walk("testrepo.git");
|
||||
|
||||
cl_git_pass(git_oid_fromstr(&new_id, "bd758010071961f28336333bc41e9c64c9a64866"));
|
||||
cl_git_pass(git_revwalk_push(_walk, &new_id));
|
||||
|
||||
cl_git_pass(git_oid_fromstr(&old_id, "8e73b769e97678d684b809b163bebdae2911720f"));
|
||||
cl_git_pass(git_revwalk_hide(_walk, &old_id));
|
||||
|
||||
cl_git_pass(git_revwalk_next(&oid, _walk));
|
||||
cl_assert(!git_oid_streq(&oid, "bd758010071961f28336333bc41e9c64c9a64866"));
|
||||
|
||||
cl_git_fail_with(GIT_ITEROVER, git_revwalk_next(&oid, _walk));
|
||||
}
|
||||
|
||||
/* Ensure that we correctly hide a commit that is (timewise) older
|
||||
* than the commits that we are showing.
|
||||
*
|
||||
* % git rev-list bd75801 ^b91e763
|
||||
* bd758010071961f28336333bc41e9c64c9a64866
|
||||
*/
|
||||
void test_revwalk_basic__old_hidden_commit_two(void)
|
||||
{
|
||||
git_oid new_id, old_id, oid;
|
||||
|
||||
revwalk_basic_setup_walk("testrepo.git");
|
||||
|
||||
cl_git_pass(git_oid_fromstr(&new_id, "bd758010071961f28336333bc41e9c64c9a64866"));
|
||||
cl_git_pass(git_revwalk_push(_walk, &new_id));
|
||||
|
||||
cl_git_pass(git_oid_fromstr(&old_id, "b91e763008b10db366442469339f90a2b8400d0a"));
|
||||
cl_git_pass(git_revwalk_hide(_walk, &old_id));
|
||||
|
||||
cl_git_pass(git_revwalk_next(&oid, _walk));
|
||||
cl_assert(!git_oid_streq(&oid, "bd758010071961f28336333bc41e9c64c9a64866"));
|
||||
|
||||
cl_git_fail_with(GIT_ITEROVER, git_revwalk_next(&oid, _walk));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user