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
5e4cb4f4
Commit
5e4cb4f4
authored
Sep 17, 2012
by
nulltoken
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
checkout : reduce memory usage when not filtering
parent
44af67a8
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
42 deletions
+34
-42
src/checkout.c
+34
-12
src/filter.c
+0
-19
src/filter.h
+0
-11
No files found.
src/checkout.c
View file @
5e4cb4f4
...
@@ -59,28 +59,50 @@ static int blob_content_to_file(
...
@@ -59,28 +59,50 @@ static int blob_content_to_file(
unsigned
int
entry_filemode
,
unsigned
int
entry_filemode
,
git_checkout_opts
*
opts
)
git_checkout_opts
*
opts
)
{
{
int
retcode
;
int
error
,
nb_filters
=
0
,
file_mode
=
opts
->
file_mode
;
git_buf
content
=
GIT_BUF_INIT
;
bool
dont_free_filtered
=
false
;
int
file_mode
=
opts
->
file_mode
;
git_buf
unfiltered
=
GIT_BUF_INIT
,
filtered
=
GIT_BUF_INIT
;
git_vector
filters
=
GIT_VECTOR_INIT
;
if
(
opts
->
disable_filters
||
(
nb_filters
=
git_filters_load
(
&
filters
,
git_object_owner
((
git_object
*
)
blob
),
path
,
GIT_FILTER_TO_WORKTREE
))
==
0
)
{
/* Create a fake git_buf from the blob raw data... */
filtered
.
ptr
=
blob
->
odb_object
->
raw
.
data
;
filtered
.
size
=
blob
->
odb_object
->
raw
.
len
;
/* ... and make sure it doesn't get unexpectedly freed */
dont_free_filtered
=
true
;
}
/* Allow disabling of filters */
if
(
nb_filters
<
0
)
if
(
opts
->
disable_filters
)
return
nb_filters
;
retcode
=
git_blob__getbuf
(
&
content
,
blob
);
else
retcode
=
git_filter_blob_content
(
&
content
,
blob
,
path
);
if
(
retcode
<
0
)
if
(
nb_filters
>
0
)
{
if
(
git_blob__getbuf
(
&
unfiltered
,
blob
)
<
0
)
goto
cleanup
;
goto
cleanup
;
if
((
error
=
git_filters_apply
(
&
filtered
,
&
unfiltered
,
&
filters
))
<
0
)
goto
cleanup
;
}
/* Allow overriding of file mode */
/* Allow overriding of file mode */
if
(
!
file_mode
)
if
(
!
file_mode
)
file_mode
=
entry_filemode
;
file_mode
=
entry_filemode
;
retcode
=
buffer_to_file
(
&
content
,
path
,
opts
->
dir_mode
,
opts
->
file_open_flags
,
file_mode
);
error
=
buffer_to_file
(
&
filtered
,
path
,
opts
->
dir_mode
,
opts
->
file_open_flags
,
file_mode
);
cleanup:
cleanup:
git_buf_free
(
&
content
);
git_filters_free
(
&
filters
);
return
retcode
;
git_buf_free
(
&
unfiltered
);
if
(
!
dont_free_filtered
)
git_buf_free
(
&
filtered
);
return
error
;
}
}
static
int
blob_content_to_link
(
git_blob
*
blob
,
const
char
*
path
,
bool
can_symlink
)
static
int
blob_content_to_link
(
git_blob
*
blob
,
const
char
*
path
,
bool
can_symlink
)
...
...
src/filter.c
View file @
5e4cb4f4
...
@@ -164,22 +164,3 @@ int git_filters_apply(git_buf *dest, git_buf *source, git_vector *filters)
...
@@ -164,22 +164,3 @@ int git_filters_apply(git_buf *dest, git_buf *source, git_vector *filters)
return
0
;
return
0
;
}
}
int
git_filter_blob_content
(
git_buf
*
out
,
git_blob
*
blob
,
const
char
*
hintpath
)
{
git_buf
unfiltered
=
GIT_BUF_INIT
;
git_vector
filters
=
GIT_VECTOR_INIT
;
int
retcode
;
retcode
=
git_blob__getbuf
(
&
unfiltered
,
blob
);
git_buf_clear
(
out
);
if
(
git_filters_load
(
&
filters
,
git_object_owner
((
git_object
*
)
blob
),
hintpath
,
GIT_FILTER_TO_WORKTREE
)
>=
0
)
retcode
=
git_filters_apply
(
out
,
&
unfiltered
,
&
filters
);
git_filters_free
(
&
filters
);
git_buf_free
(
&
unfiltered
);
return
retcode
;
}
src/filter.h
View file @
5e4cb4f4
...
@@ -119,15 +119,4 @@ extern void git_text_gather_stats(git_text_stats *stats, const git_buf *text);
...
@@ -119,15 +119,4 @@ extern void git_text_gather_stats(git_text_stats *stats, const git_buf *text);
*/
*/
extern
int
git_text_is_binary
(
git_text_stats
*
stats
);
extern
int
git_text_is_binary
(
git_text_stats
*
stats
);
/**
* Get the content of a blob after all filters have been run.
*
* @param out buffer to receive the contents
* @param hintpath path to the blob's output file, relative to the workdir root.
* Used to determine what git filters should be applied to the content.
* @return 0 on success, an error code otherwise
*/
extern
int
git_filter_blob_content
(
git_buf
*
out
,
git_blob
*
blob
,
const
char
*
hintpath
);
#endif
#endif
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