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

Re: git add -N vs. git stash

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 8, 2022, 17:30 UTC
Message-ID
<xmqqh72mskvi.fsf@gitster.g>
In-Reply-To
<20220808163954.tnozlrv7nyx63imu@pengutronix.de>
Uwe Kleine-König <uwe@kleine-koenig.org> writes:
> I'd say that's not a feature, is it?

I think that is a sign that "add -N" came much later than "stash", and whoever added the former was not a heavy user of "stash" ;-)

As the state of the "tracked files in the working tree" and "staged contents in the index" are both stored as tree objects, I think the necessary fix would involve

 - record the contents of the "intent-to-add" paths to the tree
   object for the working tree.
 - record the fact that the "intent-to-add" paths are "not in the
   index yet" by removing them from the tree object for the index.

on the recording side (i.e. "stash create"), and then teach the replay side (i.e. "stash apply") to pay attention to such strange "exists in the tree for the working tree, but missing from the tree for the index" paths and mark them with the "intent-to-add" bit.

Previous: Uwe Kleine-König
Message 2 of 2 in “git add -N vs. git stash”
  1. Uwe Kleine-KönigAug 8, 2022
  2. Junio C HamanoAug 8, 2022

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.