summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b23b27e)
raw | patch | inline | side by side (parent: b23b27e)
author | Miklos Vajna <vmiklos@frugalware.org> | |
Thu, 21 Feb 2008 01:44:46 +0000 (02:44 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Thu, 21 Feb 2008 04:21:39 +0000 (20:21 -0800) |
git-clean simply ignored errors if removing a file or directory failed. This
patch makes it raise a warning and the exit code also greater than zero if
there are remaining files.
Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
patch makes it raise a warning and the exit code also greater than zero if
there are remaining files.
Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-clean.c | patch | blob | history | |
t/t7300-clean.sh | patch | blob | history |
diff --git a/builtin-clean.c b/builtin-clean.c
index eb853a37cf993a875f2acd1992ee5191783740a1..3b220d5060b90318e2d2331d3cd0f5b6a70164ee 100644 (file)
--- a/builtin-clean.c
+++ b/builtin-clean.c
{
int i;
int show_only = 0, remove_directories = 0, quiet = 0, ignored = 0;
- int ignored_only = 0, baselen = 0, config_set = 0;
+ int ignored_only = 0, baselen = 0, config_set = 0, errors = 0;
struct strbuf directory;
struct dir_struct dir;
const char *path, *base;
if (show_only && (remove_directories || matches)) {
printf("Would remove %s\n",
directory.buf + prefix_offset);
- } else if (quiet && (remove_directories || matches)) {
- remove_dir_recursively(&directory, 0);
} else if (remove_directories || matches) {
- printf("Removing %s\n",
- directory.buf + prefix_offset);
- remove_dir_recursively(&directory, 0);
+ if (!quiet)
+ printf("Removing %s\n",
+ directory.buf + prefix_offset);
+ if (remove_dir_recursively(&directory, 0) != 0) {
+ warning("failed to remove '%s'",
+ directory.buf + prefix_offset);
+ errors++;
+ }
} else if (show_only) {
printf("Would not remove %s\n",
directory.buf + prefix_offset);
printf("Removing %s\n",
ent->name + prefix_offset);
}
- unlink(ent->name);
+ if (unlink(ent->name) != 0) {
+ warning("failed to remove '%s'", ent->name);
+ errors++;
+ }
}
}
free(seen);
strbuf_release(&directory);
- return 0;
+ return (errors != 0);
}
diff --git a/t/t7300-clean.sh b/t/t7300-clean.sh
index dfd118878fd37c096ccd426aa01fa2ac36581367..38403643a6271ae4e6bb5a9c7d768ae4b50df34d 100755 (executable)
--- a/t/t7300-clean.sh
+++ b/t/t7300-clean.sh
'
+test_expect_success 'removal failure' '
+
+ mkdir foo &&
+ touch foo/bar &&
+ chmod 0 foo &&
+ ! git clean -f -d
+
+'
+chmod 755 foo
+
test_done