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
dcd00638
Unverified
Commit
dcd00638
authored
Nov 28, 2018
by
Edward Thomson
Committed by
GitHub
Nov 28, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4898 from pks-t/pks/config-parent-is-file
config: fix adding files if their parent directory is a file
parents
c97d302d
43cbe6b7
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
1 deletions
+21
-1
src/config.c
+1
-1
tests/config/read.c
+20
-0
No files found.
src/config.c
View file @
dcd00638
...
@@ -109,7 +109,7 @@ int git_config_add_file_ondisk(
...
@@ -109,7 +109,7 @@ int git_config_add_file_ondisk(
assert
(
cfg
&&
path
);
assert
(
cfg
&&
path
);
res
=
p_stat
(
path
,
&
st
);
res
=
p_stat
(
path
,
&
st
);
if
(
res
<
0
&&
errno
!=
ENOENT
)
{
if
(
res
<
0
&&
errno
!=
ENOENT
&&
errno
!=
ENOTDIR
)
{
giterr_set
(
GITERR_CONFIG
,
"failed to stat '%s'"
,
path
);
giterr_set
(
GITERR_CONFIG
,
"failed to stat '%s'"
,
path
);
return
-
1
;
return
-
1
;
}
}
...
...
tests/config/read.c
View file @
dcd00638
...
@@ -534,6 +534,26 @@ void test_config_read__fallback_from_local_to_global_and_from_global_to_system(v
...
@@ -534,6 +534,26 @@ void test_config_read__fallback_from_local_to_global_and_from_global_to_system(v
git_config_free
(
cfg
);
git_config_free
(
cfg
);
}
}
void
test_config_read__parent_dir_is_file
(
void
)
{
git_config
*
cfg
;
int
count
;
cl_git_pass
(
git_config_new
(
&
cfg
));
/*
* Verify we can add non-existing files when the parent directory is not
* a directory.
*/
cl_git_pass
(
git_config_add_file_ondisk
(
cfg
,
"/dev/null/.gitconfig"
,
GIT_CONFIG_LEVEL_SYSTEM
,
NULL
,
0
));
count
=
0
;
cl_git_pass
(
git_config_foreach
(
cfg
,
count_cfg_entries_and_compare_levels
,
&
count
));
cl_assert_equal_i
(
0
,
count
);
git_config_free
(
cfg
);
}
/*
/*
* At the beginning of the test, config18 has:
* At the beginning of the test, config18 has:
* int32global = 28
* int32global = 28
...
...
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