From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 2/2] rm: loosen safety valve for empty files
Date: Mon, 20 Oct 2008 19:50:36 -0700 [thread overview]
Message-ID: <7v4p361x1f.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <20081021003712.GB32569@coredump.intra.peff.net> (Jeff King's message of "Mon, 20 Oct 2008 20:37:12 -0400")
Jeff King <peff@peff.net> 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@peff.net>
> ---
> ...
> +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?
next prev parent reply other threads:[~2008-10-21 2:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-21 0:37 [PATCH 2/2] rm: loosen safety valve for empty files Jeff King
2008-10-21 2:50 ` Junio C Hamano [this message]
2008-10-21 13:54 ` Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7v4p361x1f.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox