summaryrefslogtreecommitdiff
path: root/wrapper.c
diff options
context:
space:
mode:
authorRonnie Sahlberg <sahlberg@google.com>2014-07-16 11:01:18 -0700
committerJunio C Hamano <gitster@pobox.com>2014-10-15 10:47:20 -0700
commit1054af7d04aef64378d69a0496b45cdbf6a0bef2 (patch)
tree3387241e7b60dfaf8e8195ec4d161aa31fdb7f54 /wrapper.c
parent2b2b1e4d27b4e44c0c46d4857c76b8391d303af3 (diff)
downloadgit-1054af7d04aef64378d69a0496b45cdbf6a0bef2.tar.gz
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 <sahlberg@google.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'wrapper.c')
-rw-r--r--wrapper.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/wrapper.c b/wrapper.c
index 5b77d2a1ae..8d4be66e66 100644
--- a/wrapper.c
+++ b/wrapper.c
@@ -466,14 +466,12 @@ int xmkstemp_mode(char *template, int mode)
static int warn_if_unremovable(const char *op, const char *file, int rc)
{
- if (rc < 0) {
- int err = errno;
- if (ENOENT != err) {
- warning("unable to %s %s: %s",
- op, file, strerror(errno));
- errno = err;
- }
- }
+ int err;
+ if (!rc || errno == ENOENT)
+ return 0;
+ err = errno;
+ warning("unable to %s %s: %s", op, file, strerror(errno));
+ errno = err;
return rc;
}