Skip to content

Commit

Permalink
[PATCH] Make git-update-cache --force-remove regular
Browse files Browse the repository at this point in the history
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 <pasky@ucw.cz>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
pasky authored and Linus Torvalds committed Jun 5, 2005
1 parent 418aaf8 commit 9b63f50
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Documentation/git-update-cache.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ SYNOPSIS
'git-update-cache'
[--add] [--remove] [--refresh] [--replace]
[--ignore-missing]
[--force-remove <file>]
[--force-remove]
[--cacheinfo <mode> <object> <file>]\*
[--] [<file>]\*

Expand Down Expand Up @@ -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,
Expand Down
12 changes: 7 additions & 5 deletions update-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 <path>");
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;
}

Expand All @@ -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);
}
Expand Down

0 comments on commit 9b63f50

Please sign in to comment.