{"thread":{"id":"58279","subject":"git add -N vs. git stash","startedAt":"2022-08-08T16:48:51Z","lastAt":"2022-08-08T17:31:05Z","messageCount":2,"participants":["Uwe Kleine-König","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"460835","messageId":"20220808163954.tnozlrv7nyx63imu@pengutronix.de","threadId":"58279","inReplyTo":null,"subject":"git add -N vs. git stash","fromName":"Uwe Kleine-König","fromEmail":"uwe@kleine-koenig.org","sentAt":"2022-08-08T16:39:54Z","receivedAt":"2022-08-08T16:48:51Z","isPatch":false,"sender":{"key":"uwe@kleine-koenig.org","avatar":null},"body":"Hello,\n\nsomehow git stash doesn't understand the index after git add -N:\n\n\t$ git version\n\tgit version 2.36.1\n\n\t$ git init -q\n\n\t$ echo foo > foo\n\n\t$ git add foo\n\n\t$ git commit -a -m .\n\t[main (root-commit) 0e4b48cb4913] .\n\t 1 file changed, 1 insertion(+)\n\t create mode 100644 foo\n\n\t$ echo bar > bar\n\n\t$ git add -N bar\n\n\t$ git stash push\n\terror: Entry 'bar' not uptodate. Cannot merge.\n\tCannot save the current worktree state\n\nI'd say that's not a feature, is it?\n\nI would have expected the last command to just remove bar from the\nindex.\n\nBest regards\nUwe\n"},{"id":"460837","messageId":"xmqqh72mskvi.fsf@gitster.g","threadId":"58279","inReplyTo":"20220808163954.tnozlrv7nyx63imu@pengutronix.de","subject":"Re: git add -N vs. git stash","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-08-08T17:30:57Z","receivedAt":"2022-08-08T17:31:05Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Uwe Kleine-König <uwe@kleine-koenig.org> writes:\n\n> I'd say that's not a feature, is it?\n\nI think that is a sign that \"add -N\" came much later than \"stash\",\nand whoever added the former was not a heavy user of \"stash\" ;-)\n\nAs the state of the \"tracked files in the working tree\" and \"staged\ncontents in the index\" are both stored as tree objects, I think the\nnecessary fix would involve\n\n - record the contents of the \"intent-to-add\" paths to the tree\n   object for the working tree.\n\n - record the fact that the \"intent-to-add\" paths are \"not in the\n   index yet\" by removing them from the tree object for the index.\n\non the recording side (i.e. \"stash create\"), and then teach the\nreplay side (i.e. \"stash apply\") to pay attention to such strange\n\"exists in the tree for the working tree, but missing from the tree\nfor the index\" paths and mark them with the \"intent-to-add\" bit.\n\n\n"}]}