Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
d99c8ca1
Commit
d99c8ca1
authored
Aug 28, 2014
by
Vicent Marti
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2539 from libgit2/cmn/ahead-behind-order
Fix ahead-behind results
parents
69db8934
05f0d0c1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
20 deletions
+20
-20
src/graph.c
+2
-2
tests/revwalk/mergebase.c
+18
-18
No files found.
src/graph.c
View file @
d99c8ca1
...
...
@@ -124,9 +124,9 @@ static int ahead_behind(git_commit_list_node *one, git_commit_list_node *two,
(
commit
->
flags
&
(
PARENT1
|
PARENT2
))
==
(
PARENT1
|
PARENT2
))
continue
;
else
if
(
commit
->
flags
&
PARENT1
)
(
*
behind
)
++
;
else
if
(
commit
->
flags
&
PARENT2
)
(
*
ahead
)
++
;
else
if
(
commit
->
flags
&
PARENT2
)
(
*
behind
)
++
;
for
(
i
=
0
;
i
<
commit
->
out_degree
;
i
++
)
{
git_commit_list_node
*
p
=
commit
->
parents
[
i
];
...
...
tests/revwalk/mergebase.c
View file @
d99c8ca1
...
...
@@ -33,12 +33,12 @@ void test_revwalk_mergebase__single1(void)
cl_assert_equal_oid
(
&
expected
,
&
result
);
cl_git_pass
(
git_graph_ahead_behind
(
&
ahead
,
&
behind
,
_repo
,
&
one
,
&
two
));
cl_assert_equal_sz
(
ahead
,
2
);
cl_assert_equal_sz
(
behind
,
1
);
cl_assert_equal_sz
(
ahead
,
1
);
cl_assert_equal_sz
(
behind
,
2
);
cl_git_pass
(
git_graph_ahead_behind
(
&
ahead
,
&
behind
,
_repo
,
&
two
,
&
one
));
cl_assert_equal_sz
(
ahead
,
1
);
cl_assert_equal_sz
(
behind
,
2
);
cl_assert_equal_sz
(
ahead
,
2
);
cl_assert_equal_sz
(
behind
,
1
);
}
void
test_revwalk_mergebase__single2
(
void
)
...
...
@@ -54,12 +54,12 @@ void test_revwalk_mergebase__single2(void)
cl_assert_equal_oid
(
&
expected
,
&
result
);
cl_git_pass
(
git_graph_ahead_behind
(
&
ahead
,
&
behind
,
_repo
,
&
one
,
&
two
));
cl_assert_equal_sz
(
ahead
,
4
);
cl_assert_equal_sz
(
behind
,
1
);
cl_git_pass
(
git_graph_ahead_behind
(
&
ahead
,
&
behind
,
_repo
,
&
two
,
&
one
));
cl_assert_equal_sz
(
ahead
,
1
);
cl_assert_equal_sz
(
behind
,
4
);
cl_git_pass
(
git_graph_ahead_behind
(
&
ahead
,
&
behind
,
_repo
,
&
two
,
&
one
));
cl_assert_equal_sz
(
ahead
,
4
);
cl_assert_equal_sz
(
behind
,
1
);
}
void
test_revwalk_mergebase__merged_branch
(
void
)
...
...
@@ -78,12 +78,12 @@ void test_revwalk_mergebase__merged_branch(void)
cl_assert_equal_oid
(
&
expected
,
&
result
);
cl_git_pass
(
git_graph_ahead_behind
(
&
ahead
,
&
behind
,
_repo
,
&
one
,
&
two
));
cl_assert_equal_sz
(
ahead
,
0
);
cl_assert_equal_sz
(
behind
,
3
);
cl_git_pass
(
git_graph_ahead_behind
(
&
ahead
,
&
behind
,
_repo
,
&
two
,
&
one
));
cl_assert_equal_sz
(
ahead
,
3
);
cl_assert_equal_sz
(
behind
,
0
);
cl_git_pass
(
git_graph_ahead_behind
(
&
ahead
,
&
behind
,
_repo
,
&
two
,
&
one
));
cl_assert_equal_sz
(
ahead
,
0
);
cl_assert_equal_sz
(
behind
,
3
);
}
void
test_revwalk_mergebase__two_way_merge
(
void
)
...
...
@@ -95,13 +95,13 @@ void test_revwalk_mergebase__two_way_merge(void)
cl_git_pass
(
git_oid_fromstr
(
&
two
,
"a953a018c5b10b20c86e69fef55ebc8ad4c5a417"
));
cl_git_pass
(
git_graph_ahead_behind
(
&
ahead
,
&
behind
,
_repo2
,
&
one
,
&
two
));
cl_assert_equal_sz
(
ahead
,
2
);
cl_assert_equal_sz
(
behind
,
8
);
cl_assert_equal_sz
(
ahead
,
8
);
cl_assert_equal_sz
(
behind
,
2
);
cl_git_pass
(
git_graph_ahead_behind
(
&
ahead
,
&
behind
,
_repo2
,
&
two
,
&
one
));
cl_assert_equal_sz
(
ahead
,
8
);
cl_assert_equal_sz
(
behind
,
2
);
cl_assert_equal_sz
(
ahead
,
2
);
cl_assert_equal_sz
(
behind
,
8
);
}
void
test_revwalk_mergebase__no_common_ancestor_returns_ENOTFOUND
(
void
)
...
...
@@ -119,8 +119,8 @@ void test_revwalk_mergebase__no_common_ancestor_returns_ENOTFOUND(void)
cl_assert_equal_i
(
GIT_ENOTFOUND
,
error
);
cl_git_pass
(
git_graph_ahead_behind
(
&
ahead
,
&
behind
,
_repo
,
&
one
,
&
two
));
cl_assert_equal_sz
(
2
,
ahead
);
cl_assert_equal_sz
(
4
,
behind
);
cl_assert_equal_sz
(
4
,
ahead
);
cl_assert_equal_sz
(
2
,
behind
);
}
void
test_revwalk_mergebase__prefer_youngest_merge_base
(
void
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment