diff options
author | Linus Torvalds <torvalds@osdl.org> | 2006-05-19 16:19:34 -0700 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2006-05-19 17:28:33 -0700 |
commit | d9b814cc97f16daac06566a5340121c446136d22 (patch) | |
tree | 86607447958a0f032a4a26a37effbda03b4d6d8a /builtin.h | |
parent | 3c6a370b0ee78114a656acba04fddf306252b9d5 (diff) | |
download | git-d9b814cc97f16daac06566a5340121c446136d22.tar.gz git-d9b814cc97f16daac06566a5340121c446136d22.tar.xz |
Add builtin "git rm" command
This changes semantics very subtly, because it adds a new atomicity
guarantee.
In particular, if you "git rm" several files, it will now do all or
nothing. The old shell-script really looped over the removed files one by
one, and would basically randomly fail in the middle if "-f" was used and
one of the files didn't exist in the working directory.
This C builtin one will not re-write the index after each remove, but
instead remove all files at once. However, that means that if "-f" is used
(to also force removal of the file from the working directory), and some
files have already been removed from the workspace, it won't stop in the
middle in some half-way state like the old one did.
So what happens is that if the _first_ file fails to be removed with "-f",
we abort the whole "git rm". But once we've started removing, we don't
leave anything half done. If some of the other files don't exist, we'll
just ignore errors of removal from the working tree.
This is only an issue with "-f", of course.
I think the new behaviour is strictly an improvement, but perhaps more
importantly, it is _different_. As a special case, the semantics are
identical for the single-file case (which is the only one our test-suite
seems to test).
The other question is what to do with leading directories. The old "git
rm" script didn't do anything, which is somewhat inconsistent. This one
will actually clean up directories that have become empty as a result of
removing the last file, but maybe we want to have a flag to decide the
behaviour?
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'builtin.h')
-rw-r--r-- | builtin.h | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -24,6 +24,7 @@ extern int cmd_count_objects(int argc, const char **argv, char **envp); extern int cmd_push(int argc, const char **argv, char **envp); extern int cmd_grep(int argc, const char **argv, char **envp); +extern int cmd_rm(int argc, const char **argv, char **envp); extern int cmd_add(int argc, const char **argv, char **envp); #endif |