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
5bcef522
Commit
5bcef522
authored
Aug 27, 2021
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
filter: deprecate apply function
parent
c089d5ac
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
13 deletions
+36
-13
include/git2/sys/filter.h
+8
-0
src/filter.c
+28
-13
No files found.
include/git2/sys/filter.h
View file @
5bcef522
...
...
@@ -178,6 +178,7 @@ typedef int GIT_CALLBACK(git_filter_check_fn)(
const
git_filter_source
*
src
,
const
char
**
attr_values
);
#ifndef GIT_DEPRECATE_HARD
/**
* Callback to actually perform the data filtering
*
...
...
@@ -189,6 +190,8 @@ typedef int GIT_CALLBACK(git_filter_check_fn)(
*
* The `payload` value will refer to any payload that was set by the
* `check` callback. It may be read from or written to as needed.
*
* @deprecated use git_filter_stream_fn
*/
typedef
int
GIT_CALLBACK
(
git_filter_apply_fn
)(
git_filter
*
self
,
...
...
@@ -196,6 +199,7 @@ typedef int GIT_CALLBACK(git_filter_apply_fn)(
git_buf
*
to
,
const
git_buf
*
from
,
const
git_filter_source
*
src
);
#endif
/**
* Callback to perform the data filtering.
...
...
@@ -263,12 +267,16 @@ struct git_filter {
*/
git_filter_check_fn
check
;
#ifdef GIT_DEPRECATE_HARD
void
*
reserved
;
#else
/**
* Provided for backward compatibility; this will apply the
* filter to the given contents in a `git_buf`. Callers should
* provide a `stream` function instead.
*/
git_filter_apply_fn
apply
;
#endif
/**
* Called to apply the filter, this function will provide a
...
...
src/filter.c
View file @
5bcef522
...
...
@@ -939,6 +939,32 @@ int git_filter_buffered_stream_new(
return
0
;
}
static
int
setup_stream
(
git_writestream
**
out
,
git_filter_entry
*
fe
,
git_filter_list
*
filters
,
git_writestream
*
last_stream
)
{
#ifndef GIT_DEPRECATE_HARD
GIT_ASSERT
(
fe
->
filter
->
stream
||
fe
->
filter
->
apply
);
/*
* If necessary, create a stream that proxies the traditional
* application.
*/
if
(
!
fe
->
filter
->
stream
)
{
/* Create a stream that proxies the one-shot apply */
return
git_filter_buffered_stream_new
(
out
,
fe
->
filter
,
fe
->
filter
->
apply
,
filters
->
temp_buf
,
&
fe
->
payload
,
&
filters
->
source
,
last_stream
);
}
#endif
GIT_ASSERT
(
fe
->
filter
->
stream
);
return
fe
->
filter
->
stream
(
out
,
fe
->
filter
,
&
fe
->
payload
,
&
filters
->
source
,
last_stream
);
}
static
int
stream_list_init
(
git_writestream
**
out
,
git_vector
*
streams
,
...
...
@@ -960,22 +986,11 @@ static int stream_list_init(
for
(
i
=
0
;
i
<
git_array_size
(
filters
->
filters
);
++
i
)
{
size_t
filter_idx
=
(
filters
->
source
.
mode
==
GIT_FILTER_TO_WORKTREE
)
?
git_array_size
(
filters
->
filters
)
-
1
-
i
:
i
;
git_filter_entry
*
fe
=
git_array_get
(
filters
->
filters
,
filter_idx
);
git_writestream
*
filter_stream
;
GIT_ASSERT
(
fe
->
filter
->
stream
||
fe
->
filter
->
apply
);
/* If necessary, create a stream that proxies the traditional
* application.
*/
if
(
fe
->
filter
->
stream
)
error
=
fe
->
filter
->
stream
(
&
filter_stream
,
fe
->
filter
,
&
fe
->
payload
,
&
filters
->
source
,
last_stream
);
else
/* Create a stream that proxies the one-shot apply */
error
=
git_filter_buffered_stream_new
(
&
filter_stream
,
fe
->
filter
,
fe
->
filter
->
apply
,
filters
->
temp_buf
,
&
fe
->
payload
,
&
filters
->
source
,
last_stream
);
error
=
setup_stream
(
&
filter_stream
,
fe
,
filters
,
last_stream
);
if
(
error
<
0
)
goto
out
;
...
...
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