summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2017-06-13 13:47:06 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2017-06-13 13:47:07 -0700
commit93dd544f54ea596e9d70d06c100123c10689861c (patch)
tree78b1af433503d44eb977ed7e6464d4d959fb4809 /dir.c
parentMerge branch 'master' of git://bogomips.org/git-svn (diff)
parenttreewide: use is_missing_file_error() where ENOENT and ENOTDIR are checked (diff)
downloadtgif-93dd544f54ea596e9d70d06c100123c10689861c.tar.xz
Merge branch 'jc/noent-notdir'
Our code often opens a path to an optional file, to work on its contents when we can successfully open it. We can ignore a failure to open if such an optional file does not exist, but we do want to report a failure in opening for other reasons (e.g. we got an I/O error, or the file is there, but we lack the permission to open). The exact errors we need to ignore are ENOENT (obviously) and ENOTDIR (less obvious). Instead of repeating comparison of errno with these two constants, introduce a helper function to do so. * jc/noent-notdir: treewide: use is_missing_file_error() where ENOENT and ENOTDIR are checked compat-util: is_missing_file_error()
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/dir.c b/dir.c
index 9efcf1eab6..70f2de38f2 100644
--- a/dir.c
+++ b/dir.c
@@ -2337,7 +2337,7 @@ int remove_path(const char *name)
{
char *slash;
- if (unlink(name) && errno != ENOENT && errno != ENOTDIR)
+ if (unlink(name) && !is_missing_file_error(errno))
return -1;
slash = strrchr(name, '/');