From d1723296af67e6bbadf6e73cd1e921aefafe491f Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Fri, 26 Mar 2010 15:25:33 +0000 Subject: Implement the rmdir_or_warn function This patch implements an rmdir_or_warn function (like unlink_or_warn but for directories) that uses the generalised warning code in warn_if_unremovable. Signed-off-by: Peter Collingbourne Signed-off-by: Junio C Hamano --- git-compat-util.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'git-compat-util.h') diff --git a/git-compat-util.h b/git-compat-util.h index a3c4537366..67ea4c89f5 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -469,5 +469,9 @@ void git_qsort(void *base, size_t nmemb, size_t size, * Always returns the return value of unlink(2). */ int unlink_or_warn(const char *path); +/* + * Likewise for rmdir(2). + */ +int rmdir_or_warn(const char *path); #endif -- cgit v1.2.1 From 80d706afed6c6c6fb3ac9c168a6a958244405b45 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Fri, 26 Mar 2010 15:25:34 +0000 Subject: Introduce remove_or_warn function This patch introduces the remove_or_warn function which is a generalised version of the {unlink,rmdir}_or_warn functions. It takes an additional parameter indicating the mode of the file to be removed. The patch also modifies certain functions to use remove_or_warn where appropriate, and adds a test case for a bug fixed by the use of remove_or_warn. Signed-off-by: Peter Collingbourne Signed-off-by: Junio C Hamano --- git-compat-util.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'git-compat-util.h') diff --git a/git-compat-util.h b/git-compat-util.h index 67ea4c89f5..3ebf96690a 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -473,5 +473,10 @@ int unlink_or_warn(const char *path); * Likewise for rmdir(2). */ int rmdir_or_warn(const char *path); +/* + * Calls the correct function out of {unlink,rmdir}_or_warn based on + * the supplied file mode. + */ +int remove_or_warn(unsigned int mode, const char *path); #endif -- cgit v1.2.1