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
41744745
Commit
41744745
authored
Nov 17, 2015
by
Carlos Martín Nieto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3512 from ethomson/windows_sysdir
Protect windows SYSDIR when running tests
parents
32b9e647
88638f9b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
16 deletions
+37
-16
include/git2/common.h
+6
-5
src/settings.c
+12
-3
tests/clar_libgit2.c
+13
-4
tests/config/global.c
+6
-4
No files found.
include/git2/common.h
View file @
41744745
...
...
@@ -174,9 +174,9 @@ typedef enum {
* * opts(GIT_OPT_GET_SEARCH_PATH, int level, git_buf *buf)
*
* > Get the search path for a given level of config data. "level" must
* > be one of `GIT_CONFIG_LEVEL_SYSTEM`, `GIT_CONFIG_LEVEL_GLOBAL`,
or
* > `GIT_CONFIG_LEVEL_XDG`
. The search path is written to the `out`
* > buffer.
* > be one of `GIT_CONFIG_LEVEL_SYSTEM`, `GIT_CONFIG_LEVEL_GLOBAL`,
* > `GIT_CONFIG_LEVEL_XDG`
, or `GIT_CONFIG_LEVEL_PROGRAMDATA`.
* >
The search path is written to the `out`
buffer.
*
* * opts(GIT_OPT_SET_SEARCH_PATH, int level, const char *path)
*
...
...
@@ -188,8 +188,9 @@ typedef enum {
* > variables). Use magic path `$PATH` to include the old value
* > of the path (if you want to prepend or append, for instance).
* >
* > - `level` must be GIT_CONFIG_LEVEL_SYSTEM, GIT_CONFIG_LEVEL_GLOBAL,
* > or GIT_CONFIG_LEVEL_XDG.
* > - `level` must be `GIT_CONFIG_LEVEL_SYSTEM`,
* > `GIT_CONFIG_LEVEL_GLOBAL`, `GIT_CONFIG_LEVEL_XDG`, or
* > `GIT_CONFIG_LEVEL_PROGRAMDATA`.
*
* * opts(GIT_OPT_SET_CACHE_OBJECT_LIMIT, git_otype type, size_t size)
*
...
...
src/settings.c
View file @
41744745
...
...
@@ -49,9 +49,18 @@ static int config_level_to_sysdir(int config_level)
int
val
=
-
1
;
switch
(
config_level
)
{
case
GIT_CONFIG_LEVEL_SYSTEM
:
val
=
GIT_SYSDIR_SYSTEM
;
break
;
case
GIT_CONFIG_LEVEL_XDG
:
val
=
GIT_SYSDIR_XDG
;
break
;
case
GIT_CONFIG_LEVEL_GLOBAL
:
val
=
GIT_SYSDIR_GLOBAL
;
break
;
case
GIT_CONFIG_LEVEL_SYSTEM
:
val
=
GIT_SYSDIR_SYSTEM
;
break
;
case
GIT_CONFIG_LEVEL_XDG
:
val
=
GIT_SYSDIR_XDG
;
break
;
case
GIT_CONFIG_LEVEL_GLOBAL
:
val
=
GIT_SYSDIR_GLOBAL
;
break
;
case
GIT_CONFIG_LEVEL_PROGRAMDATA
:
val
=
GIT_SYSDIR_PROGRAMDATA
;
break
;
default:
giterr_set
(
GITERR_INVALID
,
"Invalid config path selector %d"
,
config_level
);
...
...
tests/clar_libgit2.c
View file @
41744745
...
...
@@ -541,14 +541,23 @@ void cl_fake_home(void)
void
cl_sandbox_set_search_path_defaults
(
void
)
{
const
char
*
sandbox_path
=
clar_sandbox_path
();
git_buf
path
=
GIT_BUF_INIT
;
git_buf_joinpath
(
&
path
,
clar_sandbox_path
(),
"__config"
);
if
(
!
git_path_exists
(
path
.
ptr
))
cl_must_pass
(
p_mkdir
(
path
.
ptr
,
0777
));
git_libgit2_opts
(
GIT_OPT_SET_SEARCH_PATH
,
GIT_CONFIG_LEVEL_GLOBAL
,
sandbox_path
);
GIT_OPT_SET_SEARCH_PATH
,
GIT_CONFIG_LEVEL_GLOBAL
,
path
.
ptr
);
git_libgit2_opts
(
GIT_OPT_SET_SEARCH_PATH
,
GIT_CONFIG_LEVEL_XDG
,
sandbox_path
);
GIT_OPT_SET_SEARCH_PATH
,
GIT_CONFIG_LEVEL_XDG
,
path
.
ptr
);
git_libgit2_opts
(
GIT_OPT_SET_SEARCH_PATH
,
GIT_CONFIG_LEVEL_SYSTEM
,
sandbox_path
);
GIT_OPT_SET_SEARCH_PATH
,
GIT_CONFIG_LEVEL_SYSTEM
,
path
.
ptr
);
git_libgit2_opts
(
GIT_OPT_SET_SEARCH_PATH
,
GIT_CONFIG_LEVEL_PROGRAMDATA
,
path
.
ptr
);
git_buf_free
(
&
path
);
}
#ifdef GIT_WIN32
...
...
tests/config/global.c
View file @
41744745
...
...
@@ -68,7 +68,6 @@ void test_config_global__open_xdg(void)
void
test_config_global__open_programdata
(
void
)
{
char
*
programdata
;
git_config
*
cfg
;
git_repository
*
repo
;
git_buf
config_path
=
GIT_BUF_INIT
;
...
...
@@ -77,9 +76,12 @@ void test_config_global__open_programdata(void)
if
(
!
cl_getenv
(
"GITTEST_INVASIVE_FS_STRUCTURE"
))
cl_skip
();
programdata
=
cl_getenv
(
"PROGRAMDATA"
);
cl_git_pass
(
git_buf_printf
(
&
config_path
,
"%s/Git"
,
programdata
));
cl_git_pass
(
p_mkdir
(
config_path
.
ptr
,
0777
));
cl_git_pass
(
git_libgit2_opts
(
GIT_OPT_GET_SEARCH_PATH
,
GIT_CONFIG_LEVEL_PROGRAMDATA
,
&
config_path
));
if
(
!
git_path_isdir
(
config_path
.
ptr
))
cl_git_pass
(
p_mkdir
(
config_path
.
ptr
,
0777
));
cl_git_pass
(
git_buf_puts
(
&
config_path
,
"/config"
));
cl_git_pass
(
git_config_open_ondisk
(
&
cfg
,
config_path
.
ptr
));
...
...
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