git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [BUG] git stash refuses to save after "add -N"

From
Jeff King <peff@peff.net>
Date
Aug 30, 2009, 09:55 UTC
Message-ID
<20090830095509.GB30922@coredump.intra.peff.net>
In-Reply-To
<7vmy5ixn96.fsf@alter.siamese.dyndns.org>
On Sat, Aug 29, 2009 at 03:34:45PM -0700, Junio C Hamano wrote:
> I am slightly in favor of leaving the things as they are, as the error
> message is quite clear.

Hmm. Thinking about it a bit more, I think "add as empty content" is probably the best. It scares me a little because it is losing information during the stash, but consider it from the user's perspective.

Their work-in-progress is being interrupted, so they need to stash. They try "git stash" and the current version comes back with an error. Now what? If they know what to do, they can manually "git rm --cached" each of the offending files (and I say manually because there isn't a parseable list of them anywhere). But they probably don't know what to do, which means trying to find the information in the documentation.

And all of this while they are trying to quickly switch contexts to whatever it was that caused them to stash in the first place. So I expect the most useful thing would be a "git stash -f" that adds them as empty. And it's reasonably safe, because we're not losing information in the transition from index to stash tree without the user first having been notified.

On the other hand, it may be sufficient to just do the transformation with a "-f", which will save users even more time, and we can put a note in the documentation about how stash interacts with -N. I don't know whether people will actually care or not (and your patch already does the unconditional form, so it's less work :) ).

-Peff
Previous: Junio C HamanoNext: Junio C Hamano
Message 5 of 11 in “[BUG] git stash refuses to save after "add -N"”
  1. Yann DirsonAug 28, 2009
  2. Jeff KingAug 28, 2009
  3. Jeff KingAug 28, 2009
  4. Junio C HamanoAug 29, 2009
  5. Jeff KingAug 30, 2009
  6. Junio C HamanoAug 30, 2009
  7. Jeff KingAug 31, 2009
  8. Junio C HamanoAug 31, 2009
  9. Jeff KingAug 31, 2009
  10. Yann DirsonAug 31, 2009
  11. Jeff KingAug 31, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.