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
c5266eba
Commit
c5266eba
authored
Mar 01, 2012
by
Vicent Martí
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
filter: Precache the filter config options on load
parent
c5e94482
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
3 deletions
+47
-3
src/filter.c
+41
-0
src/filter.h
+5
-2
src/repository.h
+1
-1
No files found.
src/filter.c
View file @
c5266eba
...
...
@@ -9,6 +9,8 @@
#include "fileops.h"
#include "hash.h"
#include "filter.h"
#include "repository.h"
#include "git2/config.h"
/* Fresh from Core Git. I wonder what we could use this for... */
void
git_text__stat
(
git_text_stats
*
stats
,
const
git_buf
*
text
)
...
...
@@ -163,3 +165,42 @@ int git_filter__apply(git_buf *dest, git_buf *source, git_vector *filters)
return
GIT_SUCCESS
;
}
int
git_filter__load_settings
(
git_repository
*
repo
)
{
static
git_cvar_map
map_eol
[]
=
{
{
GIT_CVAR_FALSE
,
NULL
,
GIT_EOL_UNSET
},
{
GIT_CVAR_STRING
,
"lf"
,
GIT_EOL_LF
},
{
GIT_CVAR_STRING
,
"crlf"
,
GIT_EOL_CRLF
},
{
GIT_CVAR_STRING
,
"native"
,
GIT_EOL_NATIVE
}
};
static
git_cvar_map
map_crlf
[]
=
{
{
GIT_CVAR_FALSE
,
NULL
,
GIT_AUTO_CRLF_FALSE
},
{
GIT_CVAR_TRUE
,
NULL
,
GIT_AUTO_CRLF_TRUE
},
{
GIT_CVAR_STRING
,
"input"
,
GIT_AUTO_CRLF_INPUT
}
};
git_config
*
config
;
int
error
;
repo
->
filter_options
.
eol
=
GIT_EOL_DEFAULT
;
repo
->
filter_options
.
auto_crlf
=
GIT_AUTO_CRLF_DEFAULT
;
error
=
git_repository_config__weakptr
(
&
config
,
repo
);
if
(
error
<
GIT_SUCCESS
)
return
error
;
error
=
git_config_get_mapped
(
config
,
"core.eol"
,
map_eol
,
ARRAY_SIZE
(
map_eol
),
&
repo
->
filter_options
.
eol
);
if
(
error
<
GIT_SUCCESS
&&
error
!=
GIT_ENOTFOUND
)
return
error
;
error
=
git_config_get_mapped
(
config
,
"core.auto_crlf"
,
map_crlf
,
ARRAY_SIZE
(
map_crlf
),
&
repo
->
filter_options
.
auto_crlf
);
if
(
error
<
GIT_SUCCESS
&&
error
!=
GIT_ENOTFOUND
)
return
error
;
return
0
;
}
src/filter.h
View file @
c5266eba
...
...
@@ -37,6 +37,7 @@ typedef enum {
GIT_AUTO_CRLF_FALSE
=
0
,
GIT_AUTO_CRLF_TRUE
=
1
,
GIT_AUTO_CRLF_INPUT
=
-
1
,
GIT_AUTO_CRLF_DEFAULT
=
GIT_AUTO_CRLF_FALSE
,
}
git_crlf_t
;
typedef
enum
{
...
...
@@ -44,10 +45,11 @@ typedef enum {
GIT_EOL_CRLF
,
GIT_EOL_LF
,
#ifdef GIT_WIN32
GIT_EOL_NATIVE
=
GIT_EOL_CRLF
GIT_EOL_NATIVE
=
GIT_EOL_CRLF
,
#else
GIT_EOL_NATIVE
=
GIT_EOL_LF
GIT_EOL_NATIVE
=
GIT_EOL_LF
,
#endif
GIT_EOL_DEFAULT
=
GIT_EOL_NATIVE
}
git_eol_t
;
typedef
struct
{
...
...
@@ -58,6 +60,7 @@ typedef struct {
unsigned
int
printable
,
nonprintable
;
}
git_text_stats
;
extern
int
git_filter__load_settings
(
git_repository
*
repo
);
extern
int
git_filter__load_for_file
(
git_vector
*
filters
,
git_repository
*
repo
,
const
char
*
full_path
,
int
mode
);
extern
void
git_filter__free
(
git_vector
*
filters
);
extern
int
git_filter__apply
(
git_buf
*
dest
,
git_buf
*
source
,
git_vector
*
filters
);
...
...
src/repository.h
View file @
c5266eba
...
...
@@ -48,7 +48,7 @@ struct git_repository {
unsigned
int
lru_counter
;
struct
{
int
core_
eol
;
int
eol
;
int
auto_crlf
;
}
filter_options
;
};
...
...
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