X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=update-cache.c;h=7c2698df6e7b08315e7d20bd40c1e7e313f52bf3;hb=180926636e47ecfe28d03cec493af75899994f0f;hp=48b4deeebc92db2bcef97141bb1c162ef4e3dea7;hpb=320d3a1b1aa04d75f0aaff3cc7cf582e144a84c6;p=git.git diff --git a/update-cache.c b/update-cache.c index 48b4deee..7c2698df 100644 --- a/update-cache.c +++ b/update-cache.c @@ -12,7 +12,8 @@ * like "git-update-cache *" and suddenly having all the object * files be revision controlled. */ -static int allow_add = 0, allow_remove = 0, allow_replace = 0, not_new = 0; +static int allow_add = 0, allow_remove = 0, allow_replace = 0, not_new = 0, quiet = 0; +static int force_remove; /* Three functions to allow overloaded pointer return; see linux/err.h */ static inline void *ERR_PTR(long error) @@ -221,10 +222,12 @@ static int refresh_cache(void) new = refresh_entry(ce); if (IS_ERR(new)) { - if (!(not_new && PTR_ERR(new) == -ENOENT)) { - printf("%s: needs update\n", ce->name); - has_errors = 1; - } + if (not_new && PTR_ERR(new) == -ENOENT) + continue; + if (quiet) + continue; + printf("%s: needs update\n", ce->name); + has_errors = 1; continue; } active_cache_changed = 1; @@ -351,6 +354,10 @@ int main(int argc, char **argv) allow_options = 0; continue; } + if (!strcmp(path, "-q")) { + quiet = 1; + continue; + } if (!strcmp(path, "--add")) { allow_add = 1; continue; @@ -376,11 +383,7 @@ int main(int argc, char **argv) continue; } if (!strcmp(path, "--force-remove")) { - if (argc <= i + 1) - die("git-update-cache: --force-remove "); - if (remove_file_from_cache(argv[i+1])) - die("git-update-cache: --force-remove cannot remove %s", argv[i+1]); - i++; + force_remove = 1; continue; } @@ -394,6 +397,11 @@ int main(int argc, char **argv) fprintf(stderr, "Ignoring path %s\n", argv[i]); continue; } + if (force_remove) { + if (remove_file_from_cache(path)) + die("git-update-cache: --force-remove cannot remove %s", path); + continue; + } if (add_file_to_cache(path)) die("Unable to add %s to database", path); }