From 1054af7d04aef64378d69a0496b45cdbf6a0bef2 Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Wed, 16 Jul 2014 11:01:18 -0700 Subject: wrapper.c: remove/unlink_or_warn: simplify, treat ENOENT as success Simplify the function warn_if_unremovable slightly. Additionally, change behaviour slightly. If we failed to remove the object because the object does not exist, we can still return success back to the caller since none of the callers depend on "fail if the file did not exist". Signed-off-by: Ronnie Sahlberg Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- git-compat-util.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'git-compat-util.h') diff --git a/git-compat-util.h b/git-compat-util.h index fb41118c07..d67592fd96 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -777,11 +777,14 @@ void git_qsort(void *base, size_t nmemb, size_t size, /* * Preserves errno, prints a message, but gives no warning for ENOENT. - * Always returns the return value of unlink(2). + * Returns 0 on success, which includes trying to unlink an object that does + * not exist. */ int unlink_or_warn(const char *path); /* - * Likewise for rmdir(2). + * Preserves errno, prints a message, but gives no warning for ENOENT. + * Returns 0 on success, which includes trying to remove a directory that does + * not exist. */ int rmdir_or_warn(const char *path); /* -- cgit v1.2.1