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
099c1b74
Commit
099c1b74
authored
Apr 30, 2013
by
Vicent Martí
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1522 from arrbee/repo-open-with-no-config
Catch issue in config set with no config file
parents
41578510
0a1755c0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
0 deletions
+41
-0
src/config.c
+6
-0
tests-clar/repo/open.c
+35
-0
No files found.
src/config.c
View file @
099c1b74
...
...
@@ -373,6 +373,12 @@ int git_config_set_string(git_config *cfg, const char *name, const char *value)
}
internal
=
git_vector_get
(
&
cfg
->
files
,
0
);
if
(
!
internal
)
{
/* Should we auto-vivify .git/config? Tricky from this location */
giterr_set
(
GITERR_CONFIG
,
"Cannot set value when no config files exist"
);
return
GIT_ENOTFOUND
;
}
file
=
internal
->
file
;
error
=
file
->
set
(
file
,
name
,
value
);
...
...
tests-clar/repo/open.c
View file @
099c1b74
...
...
@@ -280,3 +280,38 @@ void test_repo_open__opening_a_non_existing_repository_returns_ENOTFOUND(void)
git_repository
*
repo
;
cl_assert_equal_i
(
GIT_ENOTFOUND
,
git_repository_open
(
&
repo
,
"i-do-not/exist"
));
}
void
test_repo_open__no_config
(
void
)
{
git_buf
path
=
GIT_BUF_INIT
;
git_repository
*
repo
;
git_config
*
config
;
cl_fixture_sandbox
(
"empty_standard_repo"
);
cl_git_pass
(
cl_rename
(
"empty_standard_repo/.gitted"
,
"empty_standard_repo/.git"
));
/* remove local config */
cl_git_pass
(
git_futils_rmdir_r
(
"empty_standard_repo/.git/config"
,
NULL
,
GIT_RMDIR_REMOVE_FILES
));
/* isolate from system level configs */
cl_must_pass
(
p_mkdir
(
"alternate"
,
0777
));
cl_git_pass
(
git_path_prettify
(
&
path
,
"alternate"
,
NULL
));
cl_git_pass
(
git_libgit2_opts
(
GIT_OPT_SET_SEARCH_PATH
,
GIT_CONFIG_LEVEL_GLOBAL
,
path
.
ptr
));
cl_git_pass
(
git_libgit2_opts
(
GIT_OPT_SET_SEARCH_PATH
,
GIT_CONFIG_LEVEL_SYSTEM
,
path
.
ptr
));
cl_git_pass
(
git_libgit2_opts
(
GIT_OPT_SET_SEARCH_PATH
,
GIT_CONFIG_LEVEL_XDG
,
path
.
ptr
));
git_buf_free
(
&
path
);
cl_git_pass
(
git_repository_open
(
&
repo
,
"empty_standard_repo"
));
cl_git_pass
(
git_repository_config
(
&
config
,
repo
));
cl_git_fail
(
git_config_set_string
(
config
,
"test.set"
,
"42"
));
git_config_free
(
config
);
git_repository_free
(
repo
);
cl_fixture_cleanup
(
"empty_standard_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