From: Petr Baudis Date: Tue, 31 May 2005 16:52:43 +0000 (+0200) Subject: [PATCH] Make git-update-cache --force-remove regular X-Git-Tag: v0.99~351 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=9b63f50148bd155c00b6893dbbf48583f7b0848d;p=git.git [PATCH] Make git-update-cache --force-remove regular Make the --force-remove flag behave same as --add, --remove and --replace. This means I can do git-update-cache --force-remove -- file1.c file2.c which is probably saner and also makes it easier to use in cg-rm. Signed-off-by: Petr Baudis Signed-off-by: Linus Torvalds --- diff --git a/Documentation/git-update-cache.txt b/Documentation/git-update-cache.txt index 604411d6d..947f2bded 100644 --- a/Documentation/git-update-cache.txt +++ b/Documentation/git-update-cache.txt @@ -12,7 +12,7 @@ SYNOPSIS 'git-update-cache' [--add] [--remove] [--refresh] [--replace] [--ignore-missing] - [--force-remove ] + [--force-remove] [--cacheinfo ]\* [--] []\* @@ -49,7 +49,7 @@ OPTIONS --force-remove:: Remove the file from the index even when the working directory - still has such a file. + still has such a file. (Implies --remove.) --replace:: By default, when a file `path` exists in the index, diff --git a/update-cache.c b/update-cache.c index 48b4deeeb..d2f79fa45 100644 --- a/update-cache.c +++ b/update-cache.c @@ -13,6 +13,7 @@ * files be revision controlled. */ static int allow_add = 0, allow_remove = 0, allow_replace = 0, not_new = 0; +static int force_remove; /* Three functions to allow overloaded pointer return; see linux/err.h */ static inline void *ERR_PTR(long error) @@ -376,11 +377,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 +391,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); }