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
b75f15aa
Commit
b75f15aa
authored
Feb 18, 2015
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
git_writestream: from git_filter_stream
parent
8c2dfb38
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
51 additions
and
51 deletions
+51
-51
include/git2/filter.h
+3
-3
include/git2/sys/filter.h
+2
-8
include/git2/types.h
+8
-2
src/checkout.c
+5
-5
src/filter.c
+25
-25
tests/filter/stream.c
+8
-8
No files found.
include/git2/filter.h
View file @
b75f15aa
...
...
@@ -140,18 +140,18 @@ GIT_EXTERN(int) git_filter_list_apply_to_blob(
GIT_EXTERN
(
int
)
git_filter_list_stream_data
(
git_filter_list
*
filters
,
git_buf
*
data
,
git_
filter_
stream
*
target
);
git_
write
stream
*
target
);
GIT_EXTERN
(
int
)
git_filter_list_stream_file
(
git_filter_list
*
filters
,
git_repository
*
repo
,
const
char
*
path
,
git_
filter_
stream
*
target
);
git_
write
stream
*
target
);
GIT_EXTERN
(
int
)
git_filter_list_stream_blob
(
git_filter_list
*
filters
,
git_blob
*
blob
,
git_
filter_
stream
*
target
);
git_
write
stream
*
target
);
/**
* Free a git_filter_list
...
...
include/git2/sys/filter.h
View file @
b75f15aa
...
...
@@ -208,18 +208,12 @@ typedef int (*git_filter_apply_fn)(
const
git_buf
*
from
,
const
git_filter_source
*
src
);
struct
git_filter_stream
{
int
(
*
write
)(
git_filter_stream
*
stream
,
const
char
*
buffer
,
size_t
len
);
int
(
*
close
)(
git_filter_stream
*
stream
);
void
(
*
free
)(
git_filter_stream
*
stream
);
};
typedef
int
(
*
git_filter_stream_fn
)(
git_
filter_
stream
**
out
,
git_
write
stream
**
out
,
git_filter
*
self
,
void
**
payload
,
const
git_filter_source
*
src
,
git_
filter_
stream
*
next
);
git_
write
stream
*
next
);
/**
* Callback to clean up after filtering has been applied
...
...
include/git2/types.h
View file @
b75f15aa
...
...
@@ -410,8 +410,14 @@ typedef enum {
GIT_SUBMODULE_RECURSE_ONDEMAND
=
2
,
}
git_submodule_recurse_t
;
/** A stream to write filters. */
typedef
struct
git_filter_stream
git_filter_stream
;
/** A type to write in a streaming fashion, for example, for filters. */
typedef
struct
git_writestream
git_writestream
;
struct
git_writestream
{
int
(
*
write
)(
git_writestream
*
stream
,
const
char
*
buffer
,
size_t
len
);
int
(
*
close
)(
git_writestream
*
stream
);
void
(
*
free
)(
git_writestream
*
stream
);
};
/** @} */
GIT_END_DECL
...
...
src/checkout.c
View file @
b75f15aa
...
...
@@ -1373,14 +1373,14 @@ static int mkpath2file(
}
struct
checkout_stream
{
git_
filter_
stream
base
;
git_
write
stream
base
;
const
char
*
path
;
int
fd
;
int
open
;
};
static
int
checkout_stream_write
(
git_
filter_
stream
*
s
,
const
char
*
buffer
,
size_t
len
)
git_
write
stream
*
s
,
const
char
*
buffer
,
size_t
len
)
{
struct
checkout_stream
*
stream
=
(
struct
checkout_stream
*
)
s
;
int
ret
;
...
...
@@ -1391,7 +1391,7 @@ static int checkout_stream_write(
return
ret
;
}
static
int
checkout_stream_close
(
git_
filter_
stream
*
s
)
static
int
checkout_stream_close
(
git_
write
stream
*
s
)
{
struct
checkout_stream
*
stream
=
(
struct
checkout_stream
*
)
s
;
assert
(
stream
&&
stream
->
open
);
...
...
@@ -1400,7 +1400,7 @@ static int checkout_stream_close(git_filter_stream *s)
return
0
;
}
static
void
checkout_stream_free
(
git_
filter_
stream
*
s
)
static
void
checkout_stream_free
(
git_
write
stream
*
s
)
{
GIT_UNUSED
(
s
);
}
...
...
@@ -1456,7 +1456,7 @@ static int blob_content_to_file(
writer
.
fd
=
fd
;
writer
.
open
=
1
;
error
=
git_filter_list_stream_blob
(
fl
,
blob
,
(
git_
filter_
stream
*
)
&
writer
);
error
=
git_filter_list_stream_blob
(
fl
,
blob
,
(
git_
write
stream
*
)
&
writer
);
assert
(
writer
.
open
==
0
);
...
...
src/filter.c
View file @
b75f15aa
...
...
@@ -624,13 +624,13 @@ static int filter_list_out_buffer_from_raw(
}
struct
buf_stream
{
git_
filter_
stream
base
;
git_
write
stream
base
;
git_buf
*
target
;
bool
complete
;
};
static
int
buf_stream_write
(
git_
filter_
stream
*
s
,
const
char
*
buffer
,
size_t
len
)
git_
write
stream
*
s
,
const
char
*
buffer
,
size_t
len
)
{
struct
buf_stream
*
buf_stream
=
(
struct
buf_stream
*
)
s
;
assert
(
buf_stream
);
...
...
@@ -640,7 +640,7 @@ static int buf_stream_write(
return
git_buf_put
(
buf_stream
->
target
,
buffer
,
len
);
}
static
int
buf_stream_close
(
git_
filter_
stream
*
s
)
static
int
buf_stream_close
(
git_
write
stream
*
s
)
{
struct
buf_stream
*
buf_stream
=
(
struct
buf_stream
*
)
s
;
assert
(
buf_stream
);
...
...
@@ -651,7 +651,7 @@ static int buf_stream_close(git_filter_stream *s)
return
0
;
}
static
void
buf_stream_free
(
git_
filter_
stream
*
s
)
static
void
buf_stream_free
(
git_
write
stream
*
s
)
{
GIT_UNUSED
(
s
);
}
...
...
@@ -683,7 +683,7 @@ int git_filter_list_apply_to_data(
buf_stream_init
(
&
writer
,
tgt
);
if
((
error
=
git_filter_list_stream_data
(
filters
,
src
,
(
git_
filter_
stream
*
)
&
writer
))
<
0
)
(
git_
write
stream
*
)
&
writer
))
<
0
)
return
error
;
assert
(
writer
.
complete
);
...
...
@@ -702,7 +702,7 @@ int git_filter_list_apply_to_file(
buf_stream_init
(
&
writer
,
out
);
if
((
error
=
git_filter_list_stream_file
(
filters
,
repo
,
path
,
(
git_
filter_
stream
*
)
&
writer
))
<
0
)
filters
,
repo
,
path
,
(
git_
write
stream
*
)
&
writer
))
<
0
)
return
error
;
assert
(
writer
.
complete
);
...
...
@@ -736,7 +736,7 @@ int git_filter_list_apply_to_blob(
buf_stream_init
(
&
writer
,
out
);
if
((
error
=
git_filter_list_stream_blob
(
filters
,
blob
,
(
git_
filter_
stream
*
)
&
writer
))
<
0
)
filters
,
blob
,
(
git_
write
stream
*
)
&
writer
))
<
0
)
return
error
;
assert
(
writer
.
complete
);
...
...
@@ -744,18 +744,18 @@ int git_filter_list_apply_to_blob(
}
struct
proxy_stream
{
git_
filter_
stream
base
;
git_
write
stream
base
;
git_filter
*
filter
;
const
git_filter_source
*
source
;
void
**
payload
;
git_buf
input
;
git_buf
temp_buf
;
git_buf
*
output
;
git_
filter_
stream
*
target
;
git_
write
stream
*
target
;
};
static
int
proxy_stream_write
(
git_
filter_
stream
*
s
,
const
char
*
buffer
,
size_t
len
)
git_
write
stream
*
s
,
const
char
*
buffer
,
size_t
len
)
{
struct
proxy_stream
*
proxy_stream
=
(
struct
proxy_stream
*
)
s
;
assert
(
proxy_stream
);
...
...
@@ -763,7 +763,7 @@ static int proxy_stream_write(
return
git_buf_put
(
&
proxy_stream
->
input
,
buffer
,
len
);
}
static
int
proxy_stream_close
(
git_
filter_
stream
*
s
)
static
int
proxy_stream_close
(
git_
write
stream
*
s
)
{
struct
proxy_stream
*
proxy_stream
=
(
struct
proxy_stream
*
)
s
;
git_buf
*
writebuf
;
...
...
@@ -794,7 +794,7 @@ static int proxy_stream_close(git_filter_stream *s)
return
error
;
}
static
void
proxy_stream_free
(
git_
filter_
stream
*
s
)
static
void
proxy_stream_free
(
git_
write
stream
*
s
)
{
struct
proxy_stream
*
proxy_stream
=
(
struct
proxy_stream
*
)
s
;
assert
(
proxy_stream
);
...
...
@@ -805,12 +805,12 @@ static void proxy_stream_free(git_filter_stream *s)
}
static
int
proxy_stream_init
(
git_
filter_
stream
**
out
,
git_
write
stream
**
out
,
git_filter
*
filter
,
git_buf
*
temp_buf
,
void
**
payload
,
const
git_filter_source
*
source
,
git_
filter_
stream
*
target
)
git_
write
stream
*
target
)
{
struct
proxy_stream
*
proxy_stream
=
git__calloc
(
1
,
sizeof
(
struct
proxy_stream
));
GITERR_CHECK_ALLOC
(
proxy_stream
);
...
...
@@ -824,17 +824,17 @@ static int proxy_stream_init(
proxy_stream
->
target
=
target
;
proxy_stream
->
output
=
temp_buf
?
temp_buf
:
&
proxy_stream
->
temp_buf
;
*
out
=
(
git_
filter_
stream
*
)
proxy_stream
;
*
out
=
(
git_
write
stream
*
)
proxy_stream
;
return
0
;
}
static
int
stream_list_init
(
git_
filter_
stream
**
out
,
git_
write
stream
**
out
,
git_vector
*
streams
,
git_filter_list
*
filters
,
git_
filter_
stream
*
target
)
git_
write
stream
*
target
)
{
git_
filter_
stream
*
last_stream
=
target
;
git_
write
stream
*
last_stream
=
target
;
size_t
i
;
int
error
=
0
;
...
...
@@ -850,7 +850,7 @@ static int stream_list_init(
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_
filter_
stream
*
filter_stream
;
git_
write
stream
*
filter_stream
;
assert
(
fe
->
filter
->
stream
||
fe
->
filter
->
apply
);
...
...
@@ -879,7 +879,7 @@ static int stream_list_init(
void
stream_list_free
(
git_vector
*
streams
)
{
git_
filter_
stream
*
stream
;
git_
write
stream
*
stream
;
size_t
i
;
git_vector_foreach
(
streams
,
i
,
stream
)
...
...
@@ -894,13 +894,13 @@ int git_filter_list_stream_file(
git_filter_list
*
filters
,
git_repository
*
repo
,
const
char
*
path
,
git_
filter_
stream
*
target
)
git_
write
stream
*
target
)
{
char
buf
[
STREAM_BUFSIZE
];
git_buf
abspath
=
GIT_BUF_INIT
;
const
char
*
base
=
repo
?
git_repository_workdir
(
repo
)
:
NULL
;
git_vector
filter_streams
=
GIT_VECTOR_INIT
;
git_
filter_
stream
*
stream_start
;
git_
write
stream
*
stream_start
;
ssize_t
readlen
;
int
fd
,
error
;
...
...
@@ -935,10 +935,10 @@ done:
int
git_filter_list_stream_data
(
git_filter_list
*
filters
,
git_buf
*
data
,
git_
filter_
stream
*
target
)
git_
write
stream
*
target
)
{
git_vector
filter_streams
=
GIT_VECTOR_INIT
;
git_
filter_
stream
*
stream_start
;
git_
write
stream
*
stream_start
;
int
error
=
0
;
git_buf_sanitize
(
data
);
...
...
@@ -956,7 +956,7 @@ int git_filter_list_stream_data(
int
git_filter_list_stream_blob
(
git_filter_list
*
filters
,
git_blob
*
blob
,
git_
filter_
stream
*
target
)
git_
write
stream
*
target
)
{
git_buf
in
=
GIT_BUF_INIT
;
...
...
tests/filter/stream.c
View file @
b75f15aa
...
...
@@ -30,8 +30,8 @@ void test_filter_stream__cleanup(void)
#define CHUNKSIZE 10240
struct
compress_stream
{
git_
filter_
stream
base
;
git_
filter_
stream
*
next
;
git_
write
stream
base
;
git_
write
stream
*
next
;
git_filter_mode_t
mode
;
char
current
;
size_t
current_chunk
;
...
...
@@ -78,7 +78,7 @@ static int compress_stream_write__inflated(struct compress_stream *stream, const
return
0
;
}
static
int
compress_stream_write
(
git_
filter_
stream
*
s
,
const
char
*
buffer
,
size_t
len
)
static
int
compress_stream_write
(
git_
write
stream
*
s
,
const
char
*
buffer
,
size_t
len
)
{
struct
compress_stream
*
stream
=
(
struct
compress_stream
*
)
s
;
...
...
@@ -87,7 +87,7 @@ static int compress_stream_write(git_filter_stream *s, const char *buffer, size_
compress_stream_write__inflated
(
stream
,
buffer
,
len
);
}
static
int
compress_stream_close
(
git_
filter_
stream
*
s
)
static
int
compress_stream_close
(
git_
write
stream
*
s
)
{
struct
compress_stream
*
stream
=
(
struct
compress_stream
*
)
s
;
cl_assert_equal_i
(
0
,
stream
->
current_chunk
);
...
...
@@ -95,17 +95,17 @@ static int compress_stream_close(git_filter_stream *s)
return
0
;
}
static
void
compress_stream_free
(
git_
filter_
stream
*
stream
)
static
void
compress_stream_free
(
git_
write
stream
*
stream
)
{
git__free
(
stream
);
}
static
int
compress_filter_stream_init
(
git_
filter_
stream
**
out
,
git_
write
stream
**
out
,
git_filter
*
self
,
void
**
payload
,
const
git_filter_source
*
src
,
git_
filter_
stream
*
next
)
git_
write
stream
*
next
)
{
struct
compress_stream
*
stream
=
git__calloc
(
1
,
sizeof
(
struct
compress_stream
));
cl_assert
(
stream
);
...
...
@@ -119,7 +119,7 @@ static int compress_filter_stream_init(
stream
->
next
=
next
;
stream
->
mode
=
git_filter_source_mode
(
src
);
*
out
=
(
git_
filter_
stream
*
)
stream
;
*
out
=
(
git_
write
stream
*
)
stream
;
return
0
;
}
...
...
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