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
957940bf
Unverified
Commit
957940bf
authored
May 02, 2019
by
Patrick Steinhardt
Committed by
GitHub
May 02, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5023 from ianhattendorf/fix/lock_missing_global_config
Correctly write to missing locked global config
parents
bc5b19e6
e44110db
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
1 deletions
+31
-1
src/config_file.c
+1
-1
tests/config/global.c
+30
-0
No files found.
src/config_file.c
View file @
957940bf
...
...
@@ -1133,7 +1133,7 @@ static int config_write(diskfile_backend *cfg, const char *orig_key, const char
reader
.
file
=
&
cfg
->
file
;
if
(
cfg
->
locked
)
{
result
=
git_buf_puts
(
&
contents
,
git_buf_cstr
(
&
cfg
->
locked_content
));
result
=
git_buf_puts
(
&
contents
,
git_buf_cstr
(
&
cfg
->
locked_content
)
==
NULL
?
""
:
git_buf_cstr
(
&
cfg
->
locked_content
)
);
}
else
{
/* Lock the file */
if
((
result
=
git_filebuf_open
(
...
...
tests/config/global.c
View file @
957940bf
...
...
@@ -75,6 +75,36 @@ void test_config_global__open_symlinked_global(void)
#endif
}
void
test_config_global__lock_missing_global_config
(
void
)
{
git_config
*
cfg
;
git_config_entry
*
entry
;
git_transaction
*
transaction
;
p_unlink
(
"home/.gitconfig"
);
/* No global config */
cl_git_pass
(
git_config_open_default
(
&
cfg
));
cl_git_pass
(
git_config_lock
(
&
transaction
,
cfg
));
cl_git_pass
(
git_config_set_string
(
cfg
,
"assertion.fail"
,
"boom"
));
cl_git_pass
(
git_transaction_commit
(
transaction
));
git_transaction_free
(
transaction
);
/* cfg is updated */
cl_git_pass
(
git_config_get_entry
(
&
entry
,
cfg
,
"assertion.fail"
));
cl_assert_equal_s
(
"boom"
,
entry
->
value
);
git_config_entry_free
(
entry
);
git_config_free
(
cfg
);
/* We can reread the new value from the global config */
cl_git_pass
(
git_config_open_default
(
&
cfg
));
cl_git_pass
(
git_config_get_entry
(
&
entry
,
cfg
,
"assertion.fail"
));
cl_assert_equal_s
(
"boom"
,
entry
->
value
);
git_config_entry_free
(
entry
);
git_config_free
(
cfg
);
}
void
test_config_global__open_xdg
(
void
)
{
git_config
*
cfg
,
*
xdg
,
*
selected
;
...
...
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