mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-29 08:11:58 +00:00
Clean up issues include.path issues found during code review.
* Error-handling is cleaned up to only let a file-not-found error through, not other sorts of errors. And when a file-not-found error happens, we clean up the error. * Test now checks that file-not-found introduces no error. And other minor cleanups.
This commit is contained in:
parent
727ae380a5
commit
ebc13b2b7c
@ -1280,11 +1280,18 @@ static int config_parse(git_strmap *values, diskfile_backend *cfg_file, struct r
|
|||||||
|
|
||||||
r->file_path = git_buf_detach(&path);
|
r->file_path = git_buf_detach(&path);
|
||||||
git_buf_init(&r->buffer, 0);
|
git_buf_init(&r->buffer, 0);
|
||||||
if (git_futils_readbuffer_updated(&r->buffer, r->file_path, &r->file_mtime,
|
result = git_futils_readbuffer_updated(&r->buffer, r->file_path, &r->file_mtime,
|
||||||
&r->file_size, NULL) == 0) {
|
&r->file_size, NULL);
|
||||||
|
|
||||||
|
if (result == 0) {
|
||||||
result = config_parse(values, cfg_file, r, level, depth+1);
|
result = config_parse(values, cfg_file, r, level, depth+1);
|
||||||
r = git_array_get(cfg_file->readers, index);
|
r = git_array_get(cfg_file->readers, index);
|
||||||
}
|
}
|
||||||
|
else if (result == GIT_ENOTFOUND) {
|
||||||
|
giterr_clear();
|
||||||
|
result = 0;
|
||||||
|
}
|
||||||
|
|
||||||
git_buf_free(&r->buffer);
|
git_buf_free(&r->buffer);
|
||||||
|
|
||||||
if (result < 0)
|
if (result < 0)
|
||||||
|
@ -92,12 +92,13 @@ void test_config_include__missing(void)
|
|||||||
git_config *cfg;
|
git_config *cfg;
|
||||||
const char *str;
|
const char *str;
|
||||||
|
|
||||||
cl_git_mkfile("included", "[include]\npath = nonexistentfile\n[foo]\nbar = baz");
|
cl_git_mkfile("including", "[include]\npath = nonexistentfile\n[foo]\nbar = baz");
|
||||||
|
|
||||||
cl_git_pass(git_config_open_ondisk(&cfg, "included"));
|
giterr_clear();
|
||||||
|
cl_git_pass(git_config_open_ondisk(&cfg, "including"));
|
||||||
|
cl_assert(giterr_last() == NULL);
|
||||||
cl_git_pass(git_config_get_string(&str, cfg, "foo.bar"));
|
cl_git_pass(git_config_get_string(&str, cfg, "foo.bar"));
|
||||||
cl_assert_equal_s(str, "baz");
|
cl_assert_equal_s(str, "baz");
|
||||||
|
|
||||||
git_config_free(cfg);
|
git_config_free(cfg);
|
||||||
unlink("included");
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user