Skip to content

Commit 8e950da

Browse files
committed
attr: failure to open a .gitattributes file is OK with ENOTDIR
Often we consult an in-tree .gitattributes file that exists per directory. Majority of directories do not usually have such a file, and it is perfectly fine if we cannot open it because there is no such file, but we do want to know when there is an I/O or permission error. Earlier, we made the codepath warn when we fail to open it for reasons other than ENOENT for that reason. We however sometimes have to attempt to open the .gitattributes file from a directory that does not exist in the commit that is currently checked out. "git pack-objects" wants to know if a path is marked with "-delta" attributes, and "git archive" wants to know about export-ignore and export-subst attributes. Both commands may and do need to ask the attributes system about paths in an arbitrary commit. "git diff", after removing an entire directory, may want to know textconv on paths that used to be in that directory. Make sure we also ignore a failure to open per-directory attributes file due to ENOTDIR. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 55b38a4 commit 8e950da

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

attr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ static struct attr_stack *read_attr_from_file(const char *path, int macro_ok)
353353
int lineno = 0;
354354

355355
if (!fp) {
356-
if (errno != ENOENT)
356+
if (errno != ENOENT && errno != ENOTDIR)
357357
warn_on_inaccessible(path);
358358
return NULL;
359359
}

0 commit comments

Comments
 (0)