git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Josh Triplett <josh@joshtriplett.org>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: Re: Can't git stash after using git add -N
Date: Wed, 16 Mar 2016 17:05:35 -0400	[thread overview]
Message-ID: <20160316210535.GA2200@sigill.intra.peff.net> (raw)
In-Reply-To: <20160316120245.GA15091@cloud>

On Wed, Mar 16, 2016 at 05:02:45AM -0700, Josh Triplett wrote:

> On Tue, Mar 15, 2016 at 09:51:35PM -0700, Junio C Hamano wrote:
> > Josh Triplett <josh@joshtriplett.org> writes:
> > 
> > > As far as I can tell, if I run "git add -N" on a file, and then commit
> > > without adding the file contents, it gets committed as an empty file.
> > 
> > Is that true?  Git once worked like that in earlier days, but I
> > think write-tree (hence commit) would simply ignore intent-to-add
> > entries from its resulting tree.
> 
> Git 2.7.0 does appear to commit an empty file if I commit after git add
> -N.

I don't think this is the case:

  git init
  echo content >file
  git add -N file
  git commit -m "empty?"

  git ls-tree HEAD
  git status

shows that we committed an empty tree. So I see two obvious
possibilities for improvement:

  1. This commit should have failed without --allow-if-empty. We need to
     be more careful about intent-to-add entries when figuring out if
     the commit would be empty or not

  2. I'm not sure if "silently ignore intent-to-add" is the best policy.
     At least a warning ("hey, what did you want to do with these
     entries") seems merited, if not aborting the commit entirely. I
     hesitate on the latter only because perhaps that would mess up
     somebody's legitimate workflow.

-Peff

  reply	other threads:[~2016-03-16 21:05 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-15 23:07 Can't git stash after using git add -N Josh Triplett
2016-03-15 23:46 ` Junio C Hamano
2016-03-16  2:00   ` Josh Triplett
2016-03-16  4:51     ` Junio C Hamano
2016-03-16 11:09       ` Duy Nguyen
2016-03-16 12:02       ` Josh Triplett
2016-03-16 21:05         ` Jeff King [this message]
2016-03-16 21:11           ` Junio C Hamano
2016-03-16 21:18             ` 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=20160316210535.GA2200@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=josh@joshtriplett.org \
    /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;
as well as URLs for NNTP newsgroup(s).