Unverified Commit 1926163a by Edward Thomson Committed by GitHub

Merge pull request #4622 from pks-t/pks/revwalk-hide-newer-parents

revwalk: fix uninteresting revs sometimes not limiting graphwalk
parents 69870a67 54fd80e3
...@@ -375,20 +375,6 @@ static int add_parents_to_list(git_revwalk *walk, git_commit_list_node *commit, ...@@ -375,20 +375,6 @@ static int add_parents_to_list(git_revwalk *walk, git_commit_list_node *commit,
return 0; return 0;
} }
static int everybody_uninteresting(git_commit_list *orig)
{
git_commit_list *list = orig;
while (list) {
git_commit_list_node *commit = list->item;
list = list->next;
if (!commit->uninteresting)
return 0;
}
return 1;
}
/* How many unintersting commits we want to look at after we run out of interesting ones */ /* How many unintersting commits we want to look at after we run out of interesting ones */
#define SLOP 5 #define SLOP 5
...@@ -398,16 +384,15 @@ static int still_interesting(git_commit_list *list, int64_t time, int slop) ...@@ -398,16 +384,15 @@ static int still_interesting(git_commit_list *list, int64_t time, int slop)
if (!list) if (!list)
return 0; return 0;
/* for (; list; list = list->next) {
* If the destination list has commits with an earlier date /*
* than our source we want to continue looking. * If the destination list has commits with an earlier date than
*/ * our source or if it still contains interesting commits we
if (time <= list->item->time) * want to continue looking.
return SLOP; */
if (!list->item->uninteresting || list->item->time > time)
/* If we find interesting commits, we reset the slop count */ return SLOP;
if (!everybody_uninteresting(list)) }
return SLOP;
/* Everything's uninteresting, reduce the count */ /* Everything's uninteresting, reduce the count */
return slop - 1; return slop - 1;
......
[core]
bare = true
repositoryformatversion = 0
filemode = false
symlinks = false
ignorecase = true
Unnamed repository; edit this file 'description' to name the repository.
P pack-9adacb9971981a1a3264fd473da5b800f2715959.pack
# pack-refs with: peeled fully-peeled sorted
3ae0f53011bdb7e68f99bde4943449f36c1c318a refs/heads/A
061978578d7c9ff2ba92dd36d31fd8d809871030 refs/heads/B
743398b425d6c216d6cfaae3786b5bc436393ae5 refs/heads/C
790ba0facf6fd103699a5c40cd19dad277ff49cd refs/heads/D
d3d783066cf7d95def6844b9c5118c1e7bcce7df refs/heads/E
d3d783066cf7d95def6844b9c5118c1e7bcce7df refs/heads/master
...@@ -555,3 +555,30 @@ void test_revwalk_basic__old_hidden_commit_two(void) ...@@ -555,3 +555,30 @@ void test_revwalk_basic__old_hidden_commit_two(void)
cl_git_fail_with(GIT_ITEROVER, git_revwalk_next(&oid, _walk)); cl_git_fail_with(GIT_ITEROVER, git_revwalk_next(&oid, _walk));
} }
/*
* Ensure that we correctly hide all parent commits of a newer
* commit when first hiding older commits.
*
* % git rev-list D ^B ^A ^E
* 790ba0facf6fd103699a5c40cd19dad277ff49cd
* b82cee5004151ae0c4f82b69fb71b87477664b6f
*/
void test_revwalk_basic__newer_hidden_commit_hides_old_commits(void)
{
git_oid oid;
revwalk_basic_setup_walk("revwalk.git");
cl_git_pass(git_revwalk_push_ref(_walk, "refs/heads/D"));
cl_git_pass(git_revwalk_hide_ref(_walk, "refs/heads/B"));
cl_git_pass(git_revwalk_hide_ref(_walk, "refs/heads/A"));
cl_git_pass(git_revwalk_hide_ref(_walk, "refs/heads/E"));
cl_git_pass(git_revwalk_next(&oid, _walk));
cl_assert(git_oid_streq(&oid, "b82cee5004151ae0c4f82b69fb71b87477664b6f"));
cl_git_pass(git_revwalk_next(&oid, _walk));
cl_assert(git_oid_streq(&oid, "790ba0facf6fd103699a5c40cd19dad277ff49cd"));
cl_git_fail_with(GIT_ITEROVER, git_revwalk_next(&oid, _walk));
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment