Commit b883d37055ccd5153cd92b87fe3c5e76d320dd6e

Etienne Samson 2019-06-26T14:49:30

ignore: fix a missing commondir causing failures As with the preceding commit, the ignore code tries to load code from info/exclude, and we fail to ignore a non-existent file here.

diff --git a/src/ignore.c b/src/ignore.c
index 3f748b8..b17714b 100644
--- a/src/ignore.c
+++ b/src/ignore.c
@@ -335,16 +335,13 @@ int git_ignore__for_path(
 			goto cleanup;
 	}
 
-	if ((error = git_repository_item_path(&infopath,
-			repo, GIT_REPOSITORY_ITEM_INFO)) < 0)
-		goto cleanup;
-
-	/* load .git/info/exclude */
-	error = push_ignore_file(
-		ignores, &ignores->ign_global,
-		infopath.ptr, GIT_IGNORE_FILE_INREPO);
-	if (error < 0)
-		goto cleanup;
+	/* load .git/info/exclude if possible */
+	if ((error = git_repository_item_path(&infopath, repo, GIT_REPOSITORY_ITEM_INFO)) < 0 ||
+		(error = push_ignore_file(ignores, &ignores->ign_global, infopath.ptr, GIT_IGNORE_FILE_INREPO)) < 0) {
+		if (error != GIT_ENOTFOUND)
+			goto cleanup;
+		error = 0;
+	}
 
 	/* load core.excludesfile */
 	if (git_repository_attr_cache(repo)->cfg_excl_file != NULL)