Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
Generalise the unlink_or_warn function
author
Peter Collingbourne
<peter@pcc.me.uk>
Fri, 26 Mar 2010 15:25:32 +0000
(15:25 +0000)
committer
Junio C Hamano
<gitster@pobox.com>
Sun, 28 Mar 2010 16:52:59 +0000
(09:52 -0700)
This patch moves the warning code of the unlink_or_warn function into
a separate function named warn_if_unremovable so that it may be reused.
Signed-off-by: Peter Collingbourne <peter@pcc.me.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
wrapper.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
5e4f614
)
diff --git
a/wrapper.c
b/wrapper.c
index 9c71b21242773f52ca560d7e5e5e52123674d334..0bbff56e2c38651b10551d17caeed84e0cc250c8 100644
(file)
--- a/
wrapper.c
+++ b/
wrapper.c
@@
-311,18
+311,20
@@
int odb_pack_keep(char *name, size_t namesz, unsigned char *sha1)
return open(name, O_RDWR|O_CREAT|O_EXCL, 0600);
}
return open(name, O_RDWR|O_CREAT|O_EXCL, 0600);
}
-
int unlink_or_warn(const char *file
)
+
static int warn_if_unremovable(const char *op, const char *file, int rc
)
{
{
- int rc = unlink(file);
-
if (rc < 0) {
int err = errno;
if (ENOENT != err) {
if (rc < 0) {
int err = errno;
if (ENOENT != err) {
- warning("unable to
unlink
%s: %s",
- file, strerror(errno));
+ warning("unable to
%s
%s: %s",
+
op,
file, strerror(errno));
errno = err;
}
}
return rc;
}
errno = err;
}
}
return rc;
}
+int unlink_or_warn(const char *file)
+{
+ return warn_if_unremovable("unlink", file, unlink(file));
+}