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
80db2043
Unverified
Commit
80db2043
authored
Apr 04, 2019
by
Edward Thomson
Committed by
GitHub
Apr 04, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5034 from pks-t/pks/symlinked-user-config
Tests for symlinked user config
parents
6bcb7357
8cf3fd93
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
0 deletions
+62
-0
tests/config/global.c
+32
-0
tests/repo/open.c
+30
-0
No files found.
tests/config/global.c
View file @
80db2043
...
...
@@ -27,22 +27,54 @@ void test_config_global__initialize(void)
void
test_config_global__cleanup
(
void
)
{
cl_sandbox_set_search_path_defaults
();
cl_git_pass
(
git_futils_rmdir_r
(
"home"
,
NULL
,
GIT_RMDIR_REMOVE_FILES
));
cl_git_pass
(
git_futils_rmdir_r
(
"xdg"
,
NULL
,
GIT_RMDIR_REMOVE_FILES
));
cl_git_pass
(
git_futils_rmdir_r
(
"etc"
,
NULL
,
GIT_RMDIR_REMOVE_FILES
));
}
void
test_config_global__open_global
(
void
)
{
git_config
*
cfg
,
*
global
,
*
selected
,
*
dummy
;
int32_t
value
;
cl_git_mkfile
(
"home/.gitconfig"
,
"[global]
\n
test = 4567
\n
"
);
cl_git_pass
(
git_config_open_default
(
&
cfg
));
cl_git_pass
(
git_config_get_int32
(
&
value
,
cfg
,
"global.test"
));
cl_assert_equal_i
(
4567
,
value
);
cl_git_pass
(
git_config_open_level
(
&
global
,
cfg
,
GIT_CONFIG_LEVEL_GLOBAL
));
cl_git_pass
(
git_config_get_int32
(
&
value
,
global
,
"global.test"
));
cl_assert_equal_i
(
4567
,
value
);
cl_git_fail
(
git_config_open_level
(
&
dummy
,
cfg
,
GIT_CONFIG_LEVEL_XDG
));
cl_git_pass
(
git_config_open_global
(
&
selected
,
cfg
));
cl_git_pass
(
git_config_get_int32
(
&
value
,
selected
,
"global.test"
));
cl_assert_equal_i
(
4567
,
value
);
git_config_free
(
selected
);
git_config_free
(
global
);
git_config_free
(
cfg
);
}
void
test_config_global__open_symlinked_global
(
void
)
{
#ifndef GIT_WIN32
git_config
*
cfg
;
int32_t
value
;
cl_git_mkfile
(
"home/.gitconfig.linked"
,
"[global]
\n
test = 4567
\n
"
);
cl_must_pass
(
symlink
(
".gitconfig.linked"
,
"home/.gitconfig"
));
cl_git_pass
(
git_config_open_default
(
&
cfg
));
cl_git_pass
(
git_config_get_int32
(
&
value
,
cfg
,
"global.test"
));
cl_assert_equal_i
(
4567
,
value
);
git_config_free
(
cfg
);
#endif
}
void
test_config_global__open_xdg
(
void
)
{
git_config
*
cfg
,
*
xdg
,
*
selected
;
...
...
tests/repo/open.c
View file @
80db2043
...
...
@@ -118,6 +118,36 @@ void test_repo_open__gitlinked(void)
git_repository_free
(
repo2
);
}
void
test_repo_open__with_symlinked_config
(
void
)
{
#ifndef GIT_WIN32
git_buf
path
=
GIT_BUF_INIT
;
git_repository
*
repo
;
git_config
*
cfg
;
int32_t
value
;
cl_git_sandbox_init
(
"empty_standard_repo"
);
/* Setup .gitconfig as symlink */
cl_git_pass
(
git_futils_mkdir_r
(
"home"
,
0777
));
cl_git_mkfile
(
"home/.gitconfig.linked"
,
"[global]
\n
test = 4567
\n
"
);
cl_must_pass
(
symlink
(
".gitconfig.linked"
,
"home/.gitconfig"
));
cl_git_pass
(
git_path_prettify
(
&
path
,
"home"
,
NULL
));
cl_git_pass
(
git_libgit2_opts
(
GIT_OPT_SET_SEARCH_PATH
,
GIT_CONFIG_LEVEL_GLOBAL
,
path
.
ptr
));
cl_git_pass
(
git_repository_open
(
&
repo
,
"empty_standard_repo"
));
cl_git_pass
(
git_config_open_default
(
&
cfg
));
cl_git_pass
(
git_config_get_int32
(
&
value
,
cfg
,
"global.test"
));
cl_assert_equal_i
(
4567
,
value
);
git_config_free
(
cfg
);
git_repository_free
(
repo
);
cl_git_pass
(
git_futils_rmdir_r
(
git_buf_cstr
(
&
path
),
NULL
,
GIT_RMDIR_REMOVE_FILES
));
cl_sandbox_set_search_path_defaults
();
git_buf_dispose
(
&
path
);
#endif
}
void
test_repo_open__from_git_new_workdir
(
void
)
{
#ifndef GIT_WIN32
...
...
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