Skip to content

Commit

Permalink
attr: failure to open a .gitattributes file is OK with ENOTDIR
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
gitster committed Sep 14, 2012
1 parent 55b38a4 commit 8e950da
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ static struct attr_stack *read_attr_from_file(const char *path, int macro_ok)
int lineno = 0;

if (!fp) {
if (errno != ENOENT)
if (errno != ENOENT && errno != ENOTDIR)
warn_on_inaccessible(path);
return NULL;
}
Expand Down

0 comments on commit 8e950da

Please sign in to comment.