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
d4b1b767
Commit
d4b1b767
authored
Feb 03, 2015
by
Edward Thomson
Committed by
Edward Thomson
Feb 04, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
checkout: cache system attributes file location
parent
9f779aac
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
17 deletions
+65
-17
src/attr.c
+52
-16
src/attr_file.c
+10
-0
src/attr_file.h
+3
-1
No files found.
src/attr.c
View file @
d4b1b767
...
...
@@ -249,6 +249,46 @@ static int preload_attr_file(
return
error
;
}
static
int
system_attr_file
(
git_buf
*
out
,
git_repository
*
repo
,
git_attr_session
*
attr_session
)
{
int
error
;
if
(
!
attr_session
)
{
error
=
git_sysdir_find_system_file
(
out
,
GIT_ATTR_FILE_SYSTEM
);
if
(
error
==
GIT_ENOTFOUND
)
giterr_clear
();
return
error
;
}
if
(
!
attr_session
->
init_sysdir
)
{
error
=
git_sysdir_find_system_file
(
&
attr_session
->
sysdir
,
GIT_ATTR_FILE_SYSTEM
);
if
(
error
==
GIT_ENOTFOUND
)
giterr_clear
();
else
if
(
error
)
return
error
;
attr_session
->
init_sysdir
=
1
;
}
if
(
attr_session
->
sysdir
.
size
==
0
)
return
GIT_ENOTFOUND
;
/* We can safely provide a git_buf with no allocation (asize == 0) to
* a consumer. This allows them to treat this as a regular `git_buf`,
* but their call to `git_buf_free` will not attempt to free it.
*/
out
->
ptr
=
attr_session
->
sysdir
.
ptr
;
out
->
size
=
attr_session
->
sysdir
.
size
;
out
->
asize
=
0
;
return
0
;
}
static
int
attr_setup
(
git_repository
*
repo
,
git_attr_session
*
attr_session
)
{
int
error
=
0
;
...
...
@@ -256,7 +296,7 @@ static int attr_setup(git_repository *repo, git_attr_session *attr_session)
git_index
*
idx
=
NULL
;
git_buf
sys
=
GIT_BUF_INIT
;
if
(
attr_session
&&
attr_session
->
setup
)
if
(
attr_session
&&
attr_session
->
init_
setup
)
return
0
;
if
((
error
=
git_attr_cache__init
(
repo
))
<
0
)
...
...
@@ -266,18 +306,15 @@ static int attr_setup(git_repository *repo, git_attr_session *attr_session)
* definitions will be available for later file parsing
*/
if
(
!
(
error
=
git_sysdir_find_system_file
(
&
sys
,
GIT_ATTR_FILE_SYSTEM
)))
{
error
=
system_attr_file
(
&
sys
,
repo
,
attr_session
);
if
(
error
==
0
)
error
=
preload_attr_file
(
repo
,
attr_session
,
GIT_ATTR_FILE__FROM_FILE
,
NULL
,
sys
.
ptr
);
git_buf_free
(
&
sys
);
}
if
(
error
<
0
)
{
if
(
error
==
GIT_ENOTFOUND
)
{
giterr_clear
();
error
=
0
;
}
else
return
error
;
}
else
if
(
error
!=
GIT_ENOTFOUND
)
return
error
;
git_buf_free
(
&
sys
);
if
((
error
=
preload_attr_file
(
repo
,
attr_session
,
GIT_ATTR_FILE__FROM_FILE
,
...
...
@@ -300,7 +337,7 @@ static int attr_setup(git_repository *repo, git_attr_session *attr_session)
return
error
;
if
(
attr_session
)
attr_session
->
setup
=
1
;
attr_session
->
init_
setup
=
1
;
return
error
;
}
...
...
@@ -489,15 +526,14 @@ static int collect_attr_files(
}
if
((
flags
&
GIT_ATTR_CHECK_NO_SYSTEM
)
==
0
)
{
error
=
git_sysdir_find_system_file
(
&
dir
,
GIT_ATTR_FILE_SYSTEM
);
error
=
system_attr_file
(
&
dir
,
repo
,
attr_session
);
if
(
!
error
)
error
=
push_attr_file
(
repo
,
attr_session
,
files
,
GIT_ATTR_FILE__FROM_FILE
,
NULL
,
dir
.
ptr
);
else
if
(
error
==
GIT_ENOTFOUND
)
{
giterr_clear
();
else
if
(
error
==
GIT_ENOTFOUND
)
error
=
0
;
}
}
cleanup:
...
...
src/attr_file.c
View file @
d4b1b767
...
...
@@ -854,3 +854,13 @@ int git_attr_session__init(git_attr_session *session, git_repository *repo)
return
0
;
}
void
git_attr_session__free
(
git_attr_session
*
session
)
{
if
(
!
session
)
return
;
git_buf_free
(
&
session
->
sysdir
);
memset
(
session
,
0
,
sizeof
(
git_attr_session
));
}
src/attr_file.h
View file @
d4b1b767
...
...
@@ -111,7 +111,9 @@ typedef struct {
typedef
struct
{
int
key
;
unsigned
int
setup
;
unsigned
int
init_setup
:
1
,
init_sysdir
:
1
;
git_buf
sysdir
;
}
git_attr_session
;
extern
int
git_attr_session__init
(
git_attr_session
*
attr_session
,
git_repository
*
repo
);
...
...
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