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
f2d42eea
Commit
f2d42eea
authored
Jul 09, 2012
by
Ben Straub
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Checkout: add structure for CRLF.
parent
4a26ee4f
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
5 deletions
+24
-5
src/crlf.c
+18
-2
src/filter.c
+3
-3
src/filter.h
+3
-0
No files found.
src/crlf.c
View file @
f2d42eea
...
...
@@ -184,7 +184,8 @@ static int crlf_apply_to_odb(git_filter *self, git_buf *dest, const git_buf *sou
return
drop_crlf
(
dest
,
source
);
}
int
git_filter_add__crlf_to_odb
(
git_vector
*
filters
,
git_repository
*
repo
,
const
char
*
path
)
static
int
find_and_add_filter
(
git_vector
*
filters
,
git_repository
*
repo
,
const
char
*
path
,
int
(
*
apply
)(
struct
git_filter
*
self
,
git_buf
*
dest
,
const
git_buf
*
source
))
{
struct
crlf_attrs
ca
;
struct
crlf_filter
*
filter
;
...
...
@@ -219,10 +220,25 @@ int git_filter_add__crlf_to_odb(git_vector *filters, git_repository *repo, const
filter
=
git__malloc
(
sizeof
(
struct
crlf_filter
));
GITERR_CHECK_ALLOC
(
filter
);
filter
->
f
.
apply
=
&
crlf_apply_to_odb
;
filter
->
f
.
apply
=
apply
;
filter
->
f
.
do_free
=
NULL
;
memcpy
(
&
filter
->
attrs
,
&
ca
,
sizeof
(
struct
crlf_attrs
));
return
git_vector_insert
(
filters
,
filter
);
}
static
int
crlf_apply_to_workdir
(
git_filter
*
self
,
git_buf
*
dest
,
const
git_buf
*
source
)
{
/* TODO */
return
0
;
}
int
git_filter_add__crlf_to_odb
(
git_vector
*
filters
,
git_repository
*
repo
,
const
char
*
path
)
{
return
find_and_add_filter
(
filters
,
repo
,
path
,
&
crlf_apply_to_odb
);
}
int
git_filter_add__crlf_to_workdir
(
git_vector
*
filters
,
git_repository
*
repo
,
const
char
*
path
)
{
return
find_and_add_filter
(
filters
,
repo
,
path
,
&
crlf_apply_to_workdir
);
}
src/filter.c
View file @
f2d42eea
...
...
@@ -95,8 +95,9 @@ int git_filters_load(git_vector *filters, git_repository *repo, const char *path
if
(
error
<
0
)
return
error
;
}
else
{
giterr_set
(
GITERR_INVALID
,
"Worktree filters are not implemented yet"
);
return
-
1
;
error
=
git_filter_add__crlf_to_workdir
(
filters
,
repo
,
path
);
if
(
error
<
0
)
return
error
;
}
return
(
int
)
filters
->
length
;
...
...
@@ -162,4 +163,3 @@ int git_filters_apply(git_buf *dest, git_buf *source, git_vector *filters)
return
0
;
}
src/filter.h
View file @
f2d42eea
...
...
@@ -96,6 +96,9 @@ extern void git_filters_free(git_vector *filters);
/* Strip CRLF, from Worktree to ODB */
extern
int
git_filter_add__crlf_to_odb
(
git_vector
*
filters
,
git_repository
*
repo
,
const
char
*
path
);
/* Add CRLF, from ODB to worktree */
extern
int
git_filter_add__crlf_to_workdir
(
git_vector
*
filters
,
git_repository
*
repo
,
const
char
*
path
);
/*
* PLAINTEXT API
...
...
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