Repository navigation
Closed
Description
Relates to libgit2/libgit2sharp#612 (comment)
Against the testrepo.git test repository
$ git rev-list br2 master e908
a65fedf39aefe402d3bb6e24df4d4f5fe4547750
e90810b8df3e80c413d903f631643c716887138d
6dcf9bf7541ee10456529833502442f385010c3d
a4a7dce85cf63874e984719f4fdd239f5145052f
be3563ae3f795b2b4353bcce3a527ad0a4f7f644
c47800c7266a2be04c571c04d5a6614691ea99bd
9fd738e8f7967c078dceed8190330fc8648ee56a
4a202b346bb0fb0db7eff3cffeb3c70babbd2045
5b5b025afb0b4c913b4c338a42934a3863bf3644
8496071c1b46c854b31185ea97743be6a8774479
The test (see below) pass, when applied on top of 65e9dc6 and produces the following output
a65fedf39aefe402d3bb6e24df4d4f5fe4547750
e90810b8df3e80c413d903f631643c716887138d
6dcf9bf7541ee10456529833502442f385010c3d
a4a7dce85cf63874e984719f4fdd239f5145052f
be3563ae3f795b2b4353bcce3a527ad0a4f7f644
c47800c7266a2be04c571c04d5a6614691ea99bd
9fd738e8f7967c078dceed8190330fc8648ee56a
4a202b346bb0fb0db7eff3cffeb3c70babbd2045
5b5b025afb0b4c913b4c338a42934a3863bf3644
8496071c1b46c854b31185ea97743be6a8774479
However, when applied on the latest tip (9af1488), it fails, the revwalk outputting the commits in the following order
a65fedf39aefe402d3bb6e24df4d4f5fe4547750
a4a7dce85cf63874e984719f4fdd239f5145052f
e90810b8df3e80c413d903f631643c716887138d
6dcf9bf7541ee10456529833502442f385010c3d
be3563ae3f795b2b4353bcce3a527ad0a4f7f644
9fd738e8f7967c078dceed8190330fc8648ee56a
c47800c7266a2be04c571c04d5a6614691ea99bd
4a202b346bb0fb0db7eff3cffeb3c70babbd2045
5b5b025afb0b4c913b4c338a42934a3863bf3644
8496071c1b46c854b31185ea97743be6a8774479
diff --git a/tests/revwalk/basic.c b/tests/revwalk/basic.c
index 9fe8a35..77ef7ca 100644
--- a/tests/revwalk/basic.c
+++ b/tests/revwalk/basic.c
@@ -290,3 +290,79 @@ void test_revwalk_basic__push_all(void)
/* git rev-list --count --all #=> 15 */
cl_assert_equal_i(15, i);
}
+
+
+static void dump(const git_oid *oid)
+{
+ char str[41];
+ git_oid_fmt(str, oid);
+ str[40] = 0;
+ printf("%s\n", str);
+}
+/*
+* $ git rev-list br2 master e908
+* a65fedf39aefe402d3bb6e24df4d4f5fe4547750
+* e90810b8df3e80c413d903f631643c716887138d
+* 6dcf9bf7541ee10456529833502442f385010c3d
+* a4a7dce85cf63874e984719f4fdd239f5145052f
+* be3563ae3f795b2b4353bcce3a527ad0a4f7f644
+* c47800c7266a2be04c571c04d5a6614691ea99bd
+* 9fd738e8f7967c078dceed8190330fc8648ee56a
+* 4a202b346bb0fb0db7eff3cffeb3c70babbd2045
+* 5b5b025afb0b4c913b4c338a42934a3863bf3644
+* 8496071c1b46c854b31185ea97743be6a8774479
+*/
+void test_revwalk_basic__mimic_git_rev_list(void)
+{
+ git_oid oid;
+
+ revwalk_basic_setup_walk(NULL);
+ git_revwalk_sorting(_walk, GIT_SORT_TIME);
+
+ cl_git_pass(git_revwalk_push_ref(_walk, "refs/heads/br2"));
+ cl_git_pass(git_revwalk_push_ref(_walk, "refs/heads/master"));
+ cl_git_pass(git_oid_fromstr(&oid, "e90810b8df3e80c413d903f631643c716887138d"));
+ cl_git_pass(git_revwalk_push(_walk, &oid));
+
+ cl_git_pass(git_revwalk_next(&oid, _walk));
+ dump(&oid);
+ //cl_assert_equal_i(0, git_oid_streq(&oid, "a65fedf39aefe402d3bb6e24df4d4f5fe4547750"));
+
+ cl_git_pass(git_revwalk_next(&oid, _walk));
+ dump(&oid);
+ //cl_assert_equal_i(0, git_oid_streq(&oid, "e90810b8df3e80c413d903f631643c716887138d"));
+
+ cl_git_pass(git_revwalk_next(&oid, _walk));
+ dump(&oid);
+ //cl_assert_equal_i(0, git_oid_streq(&oid, "6dcf9bf7541ee10456529833502442f385010c3d"));
+
+ cl_git_pass(git_revwalk_next(&oid, _walk));
+ dump(&oid);
+ // cl_assert_equal_i(0, git_oid_streq(&oid, "a4a7dce85cf63874e984719f4fdd239f5145052f"));
+
+ cl_git_pass(git_revwalk_next(&oid, _walk));
+ dump(&oid);
+ // cl_assert_equal_i(0, git_oid_streq(&oid, "be3563ae3f795b2b4353bcce3a527ad0a4f7f644"));
+
+ cl_git_pass(git_revwalk_next(&oid, _walk));
+ dump(&oid);
+ //cl_assert_equal_i(0, git_oid_streq(&oid, "c47800c7266a2be04c571c04d5a6614691ea99bd"));
+
+ cl_git_pass(git_revwalk_next(&oid, _walk));
+ dump(&oid);
+ //cl_assert_equal_i(0, git_oid_streq(&oid, "9fd738e8f7967c078dceed8190330fc8648ee56a"));
+
+ cl_git_pass(git_revwalk_next(&oid, _walk));
+ dump(&oid);
+ //cl_assert_equal_i(0, git_oid_streq(&oid, "4a202b346bb0fb0db7eff3cffeb3c70babbd2045"));
+
+ cl_git_pass(git_revwalk_next(&oid, _walk));
+ dump(&oid);
+ //cl_assert_equal_i(0, git_oid_streq(&oid, "5b5b025afb0b4c913b4c338a42934a3863bf3644"));
+
+ cl_git_pass(git_revwalk_next(&oid, _walk));
+ dump(&oid);
+ //cl_assert_equal_i(0, git_oid_streq(&oid, "8496071c1b46c854b31185ea97743be6a8774479"));
+
+ cl_git_fail_with(git_revwalk_next(&oid, _walk), GIT_ITEROVER);
+}Metadata
Metadata
Assignees
Labels
No labels
Activity
nulltoken commentedon Mar 11, 2014
/cc @carlosmn @arrbee @ben
nulltoken commentedon Mar 12, 2014
@arrbee It looks like this is linked to the pqueue change. Do you think you could give a peek a this?
arrbee commentedon Mar 12, 2014
Sure, I'll take a look.
nulltoken commentedon Mar 12, 2014
@arrbee 💖
arrbee commentedon Mar 12, 2014
Okay, I've written a super simple test that just directly uses
git_pqueueand pushes and pops in the same order that the revwalker would and replicates this problem. By taking the rev walker out of the picture, it will hopefully make this a lot simpler to diagnose.arrbee commentedon Mar 12, 2014
Okay, I think I've found the problem. There is a place where the new pqueue uses a
<and should use a<=.This bug snuck in because the element comparison function I used in the pqueue tests is "complete" (i.e. it explicitly returns -1, 0, or 1 for all variants) whereas the
TIMESORTcomparison function is one-sided (i.e. it just returnsa < band so it will only ever return 0 or 1).Fix to follow shortly once I make sure it all looks good.
nulltoken commentedon Mar 12, 2014
Closed with #2184