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
29e92d38
Commit
29e92d38
authored
Sep 10, 2013
by
Russell Belfer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Hook up filter initialize callback
I knew I forgot something
parent
2a7d224f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
2 deletions
+34
-2
include/git2/sys/filter.h
+2
-0
src/filter.c
+32
-2
No files found.
include/git2/sys/filter.h
View file @
29e92d38
...
@@ -139,7 +139,9 @@ typedef void (*git_filter_cleanup_fn)(
...
@@ -139,7 +139,9 @@ typedef void (*git_filter_cleanup_fn)(
*/
*/
struct
git_filter
{
struct
git_filter
{
unsigned
int
version
;
unsigned
int
version
;
const
char
*
attributes
;
const
char
*
attributes
;
git_filter_init_fn
initialize
;
git_filter_init_fn
initialize
;
git_filter_shutdown_fn
shutdown
;
git_filter_shutdown_fn
shutdown
;
git_filter_check_fn
check
;
git_filter_check_fn
check
;
...
...
src/filter.c
View file @
29e92d38
...
@@ -39,6 +39,7 @@ typedef struct {
...
@@ -39,6 +39,7 @@ typedef struct {
const
char
*
filter_name
;
const
char
*
filter_name
;
git_filter
*
filter
;
git_filter
*
filter
;
int
priority
;
int
priority
;
int
initialized
;
size_t
nattrs
,
nmatches
;
size_t
nattrs
,
nmatches
;
char
*
attrdata
;
char
*
attrdata
;
const
char
*
attrs
[
GIT_FLEX_ARRAY
];
const
char
*
attrs
[
GIT_FLEX_ARRAY
];
...
@@ -178,6 +179,23 @@ static git_filter_def *filter_find_by_name(size_t *pos, const char *name)
...
@@ -178,6 +179,23 @@ static git_filter_def *filter_find_by_name(size_t *pos, const char *name)
return
fdef
;
return
fdef
;
}
}
static
int
filter_initialize
(
git_filter_def
*
fdef
)
{
int
error
=
0
;
if
(
!
fdef
->
initialized
&&
fdef
->
filter
&&
fdef
->
filter
->
initialize
&&
(
error
=
fdef
->
filter
->
initialize
(
fdef
->
filter
))
<
0
)
{
git_filter_unregister
(
fdef
->
filter_name
);
return
error
;
}
fdef
->
initialized
=
true
;
return
0
;
}
int
git_filter_unregister
(
const
char
*
name
)
int
git_filter_unregister
(
const
char
*
name
)
{
{
size_t
pos
;
size_t
pos
;
...
@@ -196,8 +214,10 @@ int git_filter_unregister(const char *name)
...
@@ -196,8 +214,10 @@ int git_filter_unregister(const char *name)
(
void
)
git_vector_remove
(
&
git__filter_registry
,
pos
);
(
void
)
git_vector_remove
(
&
git__filter_registry
,
pos
);
if
(
fdef
->
filter
->
shutdown
)
if
(
fdef
->
initialized
&&
fdef
->
filter
&&
fdef
->
filter
->
shutdown
)
{
fdef
->
filter
->
shutdown
(
fdef
->
filter
);
fdef
->
filter
->
shutdown
(
fdef
->
filter
);
fdef
->
initialized
=
false
;
}
git__free
(
fdef
->
attrdata
);
git__free
(
fdef
->
attrdata
);
git__free
(
fdef
);
git__free
(
fdef
);
...
@@ -209,7 +229,14 @@ git_filter *git_filter_lookup(const char *name)
...
@@ -209,7 +229,14 @@ git_filter *git_filter_lookup(const char *name)
{
{
size_t
pos
;
size_t
pos
;
git_filter_def
*
fdef
=
filter_find_by_name
(
&
pos
,
name
);
git_filter_def
*
fdef
=
filter_find_by_name
(
&
pos
,
name
);
return
fdef
?
fdef
->
filter
:
NULL
;
if
(
!
fdef
)
return
NULL
;
if
(
!
fdef
->
initialized
&&
filter_initialize
(
fdef
)
<
0
)
return
NULL
;
return
fdef
->
filter
;
}
}
static
int
filter_load_defaults
(
void
)
static
int
filter_load_defaults
(
void
)
...
@@ -341,6 +368,9 @@ int git_filter_list_load(
...
@@ -341,6 +368,9 @@ int git_filter_list_load(
break
;
break
;
}
}
if
(
!
fdef
->
initialized
&&
(
error
=
filter_initialize
(
fdef
))
<
0
)
break
;
if
(
fdef
->
filter
->
check
)
if
(
fdef
->
filter
->
check
)
error
=
fdef
->
filter
->
check
(
error
=
fdef
->
filter
->
check
(
fdef
->
filter
,
&
payload
,
&
src
,
values
);
fdef
->
filter
,
&
payload
,
&
src
,
values
);
...
...
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