Jeff King <peff@xxxxxxxx> writes: > This covers the intent-to-add situation, and presumably > 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. > > Signed-off-by: Jeff King <peff@xxxxxxxx> > --- > ... > +test_expect_success 'ok to remove cached empty file' ' > + touch empty && > + git add empty && > + echo content >empty && > + git rm --cached empty > +' I am actually of two minds about this patch. With one of the commits in the nd/narrow series, we can easily add more flag bits to the index entries, and it is conceivable that we would want to change the "add -N" implementation to set an "intent to add" bit (which we don't), in addition to registering an empty blob at the path (which we currently do). I envision that such a change would allow us to: - let "git diff" continue to diff with an emptiness and keep showing what people would expect; - teach "git write-tree" (and various "commit" building commands) to either (1) ignore a staged empty blob when the "intent to add" bit is set, or (2) warn and abort, saying "you told me you will tell me what the actual contents will be later, but you haven't done so -- I'll refuse to operate until you make up your mind"; in addition to what you are trying to fix here with "git rm". With such a change, your "git rm empty" code can also distinguish between an empty blob the user wanted to add _as the final contents_, and a path that has been marked with "add -N", and behave differently (the former would not require -f while the latter would). As an interim measure, I suspect your patch is an improvement from the current state of affairs, but the above test will then break when an improvement to "git add -N" implementation outlined above materializes. So how about changing the test to explicitly check that a path that was added by "git add -N" can be removed, and either (1) not check about an empty blob that was explicitly added by the user, or (2) check that an empty blob that was explicitly added by the user cannot be "git rm"'ed without -f, with expect_failure? -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html