diff options
| author | Edward Thomson <ethomson@github.com> | 2016-06-25 20:02:45 -0400 |
|---|---|---|
| committer | Carlos MartÃn Nieto <cmn@dwim.me> | 2016-10-06 11:04:55 +0200 |
| commit | 565fb8dcd41eefb373ec6dc71dc2f19884d29cdc (patch) | |
| tree | 1f2dd0e07d187cd4a7f2df293359b5a40181939d /tests/revwalk | |
| parent | e8ab13b3fd8485086c2a906dac85ecc8fa162d84 (diff) | |
| download | libgit2-565fb8dcd41eefb373ec6dc71dc2f19884d29cdc.tar.gz | |
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.
Diffstat (limited to 'tests/revwalk')
| -rw-r--r-- | tests/revwalk/basic.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/revwalk/basic.c b/tests/revwalk/basic.c index 5ed7da4eb..7559f72e9 100644 --- a/tests/revwalk/basic.c +++ b/tests/revwalk/basic.c @@ -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)); +} |
