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
091c742a
Commit
091c742a
authored
Aug 24, 2012
by
Vicent Martí
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #876 from arrbee/new-config-locations
new config file locations and defaults
parents
07c06f7a
7fbca880
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
11 deletions
+24
-11
src/attr.c
+16
-10
src/attr.h
+1
-0
src/config.c
+6
-1
src/config.h
+1
-0
No files found.
src/attr.c
View file @
091c742a
...
...
@@ -590,6 +590,18 @@ static int collect_attr_files(
return
error
;
}
static
char
*
try_global_default
(
const
char
*
relpath
)
{
git_buf
dflt
=
GIT_BUF_INIT
;
char
*
rval
=
NULL
;
if
(
!
git_futils_find_global_file
(
&
dflt
,
relpath
))
rval
=
git_buf_detach
(
&
dflt
);
git_buf_free
(
&
dflt
);
return
rval
;
}
int
git_attr_cache__init
(
git_repository
*
repo
)
{
...
...
@@ -607,20 +619,14 @@ int git_attr_cache__init(git_repository *repo)
ret
=
git_config_get_string
(
&
cache
->
cfg_attr_file
,
cfg
,
GIT_ATTR_CONFIG
);
if
(
ret
<
0
&&
ret
!=
GIT_ENOTFOUND
)
return
ret
;
if
(
ret
==
GIT_ENOTFOUND
)
cache
->
cfg_attr_file
=
try_global_default
(
GIT_ATTR_CONFIG_DEFAULT
);
ret
=
git_config_get_string
(
&
cache
->
cfg_excl_file
,
cfg
,
GIT_IGNORE_CONFIG
);
if
(
ret
<
0
&&
ret
!=
GIT_ENOTFOUND
)
return
ret
;
if
(
ret
==
GIT_ENOTFOUND
)
{
git_buf
dflt
=
GIT_BUF_INIT
;
ret
=
git_futils_find_global_file
(
&
dflt
,
GIT_IGNORE_CONFIG_DEFAULT
);
if
(
!
ret
)
cache
->
cfg_excl_file
=
git_buf_detach
(
&
dflt
);
git_buf_free
(
&
dflt
);
}
if
(
ret
==
GIT_ENOTFOUND
)
cache
->
cfg_excl_file
=
try_global_default
(
GIT_IGNORE_CONFIG_DEFAULT
);
giterr_clear
();
...
...
src/attr.h
View file @
091c742a
...
...
@@ -11,6 +11,7 @@
#include "strmap.h"
#define GIT_ATTR_CONFIG "core.attributesfile"
#define GIT_ATTR_CONFIG_DEFAULT ".config/git/attributes"
#define GIT_IGNORE_CONFIG "core.excludesfile"
#define GIT_IGNORE_CONFIG_DEFAULT ".config/git/ignore"
...
...
src/config.c
View file @
091c742a
...
...
@@ -449,7 +449,12 @@ int git_config_set_multivar(git_config *cfg, const char *name, const char *regex
int
git_config_find_global_r
(
git_buf
*
path
)
{
return
git_futils_find_global_file
(
path
,
GIT_CONFIG_FILENAME
);
int
error
=
git_futils_find_global_file
(
path
,
GIT_CONFIG_FILENAME
);
if
(
error
==
GIT_ENOTFOUND
)
error
=
git_futils_find_global_file
(
path
,
GIT_CONFIG_FILENAME_ALT
);
return
error
;
}
int
git_config_find_global
(
char
*
global_config_path
,
size_t
length
)
...
...
src/config.h
View file @
091c742a
...
...
@@ -13,6 +13,7 @@
#include "repository.h"
#define GIT_CONFIG_FILENAME ".gitconfig"
#define GIT_CONFIG_FILENAME_ALT ".config/git/config"
#define GIT_CONFIG_FILENAME_INREPO "config"
#define GIT_CONFIG_FILENAME_SYSTEM "gitconfig"
#define GIT_CONFIG_FILE_MODE 0666
...
...
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