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 --- wrapper.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'wrapper.c') diff --git a/wrapper.c b/wrapper.c index 4017bff6bb..10a6750795 100644 --- a/wrapper.c +++ b/wrapper.c @@ -333,3 +333,8 @@ int rmdir_or_warn(const char *file) { return warn_if_unremovable("rmdir", file, rmdir(file)); } + +int remove_or_warn(unsigned int mode, const char *file) +{ + return S_ISGITLINK(mode) ? rmdir_or_warn(file) : unlink_or_warn(file); +} -- cgit v1.2.1