diff options
author | Jeff King <peff@peff.net> | 2008-10-21 09:54:19 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-10-22 17:16:07 -0700 |
commit | f55527f80223178d1837bae08addc57bed76d236 (patch) | |
tree | 5d38a282be5fcfe7853003d2d144af85748bbcf8 /git-gui/lib/spellcheck.tcl | |
parent | Merge branch 'jk/diff-convfilter' (diff) | |
download | tgif-f55527f80223178d1837bae08addc57bed76d236.tar.xz |
rm: loosen safety valve for empty files
If a file is different between the working tree copy, the index, and the
HEAD, then we do not allow it to be deleted without --force.
However, this is overly tight in the face of "git add --intent-to-add":
$ git add --intent-to-add file
$ : oops, I don't actually want to stage that yet
$ git rm --cached file
error: 'empty' has staged content different from both the
file and the HEAD (use -f to force removal)
$ git rm -f --cached file
Unfortunately, there is currently no way to distinguish between an empty
file that has been added and an "intent to add" file. The ideal behavior
would be to disallow the former while allowing the latter.
This patch loosens the safety valve to allow the deletion only if we are
deleting the cached entry and the cached content is empty. This covers
the intent-to-add situation, and assumes there is little harm in not
protecting users who have legitimately added an empty file. In many
cases, the file will still be empty, in which case the safety valve does
not trigger anyway (since the content remains untouched in the working
tree). Otherwise, we do remove the fact that no content was staged, but
given that the content is by definition empty, it is not terribly
difficult for a user to recreate it.
However, we still document the desired behavior in the form of two
tests. One checks the correct removal of an intent-to-add file. The other
checks that we still disallow removal of empty files, but is marked as
expect_failure to indicate this compromise. If the intent-to-add feature
is ever extended to differentiate between normal empty files and
intent-to-add files, then the safety valve can be re-tightened.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-gui/lib/spellcheck.tcl')
0 files changed, 0 insertions, 0 deletions