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
e7873eb2
Unverified
Commit
e7873eb2
authored
Nov 29, 2018
by
Patrick Steinhardt
Committed by
GitHub
Nov 29, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4888 from TheBB/add-cb
revwalk: Allow changing hide_cb
parents
487233fa
0836f069
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
10 deletions
+33
-10
include/git2/revwalk.h
+1
-1
src/revwalk.c
+3
-7
tests/revwalk/hidecb.c
+29
-2
No files found.
include/git2/revwalk.h
View file @
e7873eb2
...
...
@@ -279,7 +279,7 @@ typedef int(*git_revwalk_hide_cb)(
void
*
payload
);
/**
* Adds a callback function to hide a commit and its parents
* Adds
, changes or removes
a callback function to hide a commit and its parents
*
* @param walk the revision walker
* @param hide_cb callback function to hide a commit and its parents
...
...
src/revwalk.c
View file @
e7873eb2
...
...
@@ -756,15 +756,11 @@ int git_revwalk_add_hide_cb(
if
(
walk
->
walking
)
git_revwalk_reset
(
walk
);
if
(
walk
->
hide_cb
)
{
/* There is already a callback added */
giterr_set
(
GITERR_INVALID
,
"there is already a callback added to hide commits in revwalk"
);
return
-
1
;
}
walk
->
hide_cb
=
hide_cb
;
walk
->
hide_cb_payload
=
payload
;
walk
->
limited
=
1
;
if
(
hide_cb
)
walk
->
limited
=
1
;
return
0
;
}
...
...
tests/revwalk/hidecb.c
View file @
e7873eb2
...
...
@@ -117,13 +117,40 @@ void test_revwalk_hidecb__hide_none_cb(void)
git_revwalk_free
(
walk
);
}
void
test_revwalk_hidecb__
add_hide_cb_multiple_times
(
void
)
void
test_revwalk_hidecb__
unset_cb_before_walk
(
void
)
{
git_revwalk
*
walk
;
git_oid
id
;
int
i
,
error
;
cl_git_pass
(
git_revwalk_new
(
&
walk
,
_repo
));
cl_git_pass
(
git_revwalk_add_hide_cb
(
walk
,
hide_every_commit_cb
,
NULL
));
cl_git_pass
(
git_revwalk_add_hide_cb
(
walk
,
NULL
,
NULL
));
cl_git_pass
(
git_revwalk_push
(
walk
,
&
_head_id
));
/* It should return all 6 commits */
i
=
0
;
while
((
error
=
git_revwalk_next
(
&
id
,
walk
))
==
0
)
i
++
;
cl_assert_equal_i
(
i
,
6
);
cl_assert_equal_i
(
error
,
GIT_ITEROVER
);
git_revwalk_free
(
walk
);
}
void
test_revwalk_hidecb__change_cb_before_walk
(
void
)
{
git_revwalk
*
walk
;
git_oid
id
;
cl_git_pass
(
git_revwalk_new
(
&
walk
,
_repo
));
cl_git_pass
(
git_revwalk_add_hide_cb
(
walk
,
hide_none_cb
,
NULL
));
cl_git_pass
(
git_revwalk_add_hide_cb
(
walk
,
hide_every_commit_cb
,
NULL
));
cl_git_fail
(
git_revwalk_add_hide_cb
(
walk
,
hide_every_commit_cb
,
NULL
));
cl_git_pass
(
git_revwalk_push
(
walk
,
&
_head_id
));
/* First call to git_revwalk_next should return GIT_ITEROVER */
cl_assert_equal_i
(
GIT_ITEROVER
,
git_revwalk_next
(
&
id
,
walk
));
git_revwalk_free
(
walk
);
}
...
...
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