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:
Edward Thomson
2016-06-25 20:02:45 -04:00
committed by Carlos Martín Nieto
parent e8ab13b3fd
commit 565fb8dcd4
15 changed files with 64 additions and 4 deletions

View File

@@ -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);

View File

@@ -0,0 +1,2 @@
x-▌]jC!FШЛ*f)Ч]║■@Х
з Х УZ▄║ш╞iШvЬЮ>Й╜М╢╠Os0┐B%s)f▄ниMИlяhЖV4╒5┴╡Ь┼┐▐ е&4я∙@:║Dе)oIr`▐▓╫$МLп■┬ВYШ─wЙsб╔FЙ╪эХнвВоМ■Ж∙а`А$╫■b╜КАДoЫ;▌ ╣╥шцФU|пЫ╨оzOЪ╬u}пз/ъ._╓╙Пв│~╟ЬуДJ

View File

@@ -0,0 +1,4 @@
x<01><>K
1}%<25>N'7ήΐ δΣγ 8ΌΎρ
ξκΌ\Χuι 5zc†¤<E280A0> 6¤Η8ωb,β”ΚDΞ2Ί0†'«QΌbγ­ƒΗ@<40>©¬“QΚ[<5B>Α94‰)ϊ£qοsmp+<2B>Ψ
άηΊΎλgφGΧΗ<CEA7>η=<3D>r]/ ΄3<CE84>((£tR<74>aΗΛΞ<CE9B>φΆ>‹ψ±

View File

@@ -0,0 +1,2 @@
x<01><>½jÄ0„Sû)¶»*aõ»„ãš”éò+íúl8[AÉëÇ×äÒ 33¥®ëÒÁ¡yéM$ÌmÈ*Öç ã$q²äG?YŒAœ5< ßÜtëà<C3AB>¦8rÂÀ£5Á<35>Ž”³7nD#.d<18>)~ŠNÈ0Ë„‰)R,‰|,h½jQ*töóÑçÚàC~¸ |ÍuÝëïzÒ§ºÝ—>ù­Ôõ
Ƴd¼ðŠ„8œô\Õõ¿ùáSÛ]!7ÞÊ —ýÈÏsö ,[¯Pfw^Ä

View File

@@ -0,0 +1,2 @@
x-Î]ŠÃ0 à}Î)t<>.þQ J),{‚öŽ-7<>º^\‡^<>Ò·AÌ7(”œ×FÓW«"ÀˆA%ŒÉ£y’Ùg<>iTI´Ód†?_åÑÀ<>#ê•Ø[‰Ó(-§DÎ0wdp²ƒßÚR*\Bi ~ÊŽÏðç[öëý;”|mµa´djRjè×þa“
¿ñåk„ëRòs×Ò÷t¾­mÙæ<C399>G"7±á©{ì~ø¥LD

View File

@@ -0,0 +1,2 @@
x-ЮQJ1PПs<D09F>О<EFBFBD>вIz2= В <20>@/<2F>tz7f"й,^пЌњWМЂЄеКp<>FWЫgkйЪЦб­ыЖ`т$Д8J<38>ё<>0cИ<>Џиѕ<D0B8><D195>Й<>5
ЩIв<EFBFBD><EFBFBD>J>!+<2B>ГN<>UШФл(­УЛД1рЕDi<_х7<D185>.5ю<EFBFBD>Oвъ XЗС<>fЖѓсаoљ;і Ѕеы]ы\МЇгeх<>ў=<3D>Р[@tггє&ѕxH<78>Пh<><68>ћYJn

View File

@@ -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));
}