diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2010-03-26 15:25:34 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2010-03-28 09:53:04 -0700 |
commit | 80d706afed6c6c6fb3ac9c168a6a958244405b45 (patch) | |
tree | 18687c3c32ff6cd9a56ec42d1e46413d1ac8ed35 /unpack-trees.c | |
parent | d1723296af67e6bbadf6e73cd1e921aefafe491f (diff) | |
download | git-80d706afed6c6c6fb3ac9c168a6a958244405b45.tar.gz |
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 <peter@pcc.me.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'unpack-trees.c')
-rw-r--r-- | unpack-trees.c | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/unpack-trees.c b/unpack-trees.c index 75f54cac97..c29a9e067f 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -67,16 +67,8 @@ static void unlink_entry(struct cache_entry *ce) { if (has_symlink_or_noent_leading_path(ce->name, ce_namelen(ce))) return; - if (S_ISGITLINK(ce->ce_mode)) { - if (rmdir(ce->name)) { - warning("unable to rmdir %s: %s", - ce->name, strerror(errno)); - return; - } - } - else - if (unlink_or_warn(ce->name)) - return; + if (remove_or_warn(ce->ce_mode, ce->name)) + return; schedule_dir_for_removal(ce->name, ce_namelen(ce)); } |