summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSim Domingo <sim@github.com>2016-06-20 13:15:35 +0800
committerEdward Thomson <ethomson@edwardthomson.com>2017-03-23 12:12:38 +0000
commit301dc26a5a426870dc8f0728670c1c59ca42d300 (patch)
tree857dcf289e98658a6338829e7cf9625a37ad4550
parent047fe29c4f8cd3f9554673570266b1bb9add3f46 (diff)
downloadlibgit2-301dc26a5a426870dc8f0728670c1c59ca42d300.tar.gz
fix error when including a missing config file relative to the home directory
-rw-r--r--src/config_file.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/config_file.c b/src/config_file.c
index 50c5a3d82..6ef80660a 100644
--- a/src/config_file.c
+++ b/src/config_file.c
@@ -1254,8 +1254,16 @@ static int strip_comments(char *line, int in_quotes)
static int included_path(git_buf *out, const char *dir, const char *path)
{
/* From the user's home */
- if (path[0] == '~' && path[1] == '/')
- return git_sysdir_find_global_file(out, &path[1]);
+ int result;
+ if (path[0] == '~' && path[1] == '/') {
+ result = git_sysdir_find_global_file(out, &path[1]);
+ if (result == GIT_ENOTFOUND) {
+ git_buf_sets(out, &path[1]);
+ return 0;
+ }
+
+ return result;
+ }
return git_path_join_unrooted(out, path, dir, NULL);
}