{"thread":{"id":"51040","subject":"Surprising semantics of \"git add file\"","startedAt":"2019-05-05T20:12:15Z","lastAt":"2019-05-06T07:14:25Z","messageCount":4,"participants":["Ulrich Windl","Andreas Schwab"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"374929","messageId":"5CCF414A020000A10003108C@gwsmtp.uni-regensburg.de","threadId":"51040","inReplyTo":null,"subject":"Surprising semantics of \"git add file\"","fromName":"Ulrich Windl","fromEmail":"ulrich.windl@rz.uni-regensburg.de","sentAt":"2019-05-05T20:02:18Z","receivedAt":"2019-05-05T20:12:15Z","isPatch":false,"sender":{"key":"ulrich.windl@rz.uni-regensburg.de","avatar":null},"body":"Hi!\n\nReading the manual, I realized that \"it is the way it is (it works as documented)\", but to me it's surprising, meaning: I feel it's wrong:\n(git-2.16.4)\nI have staged several files, and then I do \"git add -interactive file\" to add some selected changes from file.\nAfter that a \"git diff --cached file\" just shows the changes added interactively, but when I \"git add file\" to commit those changes), even the unstaged changes from file are committed.\nI feel this is inconsistent: At least \"git diff --cached file\" should behave like \"git commit file\", meaning \"git commit file\" should be fixed IMHO.\nOr are there any reasonable use cased for that?\n\nRegards,\nUlrich Windl\n\n\n\n"},{"id":"374930","messageId":"5CCF43AE020000A100031092@gwsmtp.uni-regensburg.de","threadId":"51040","inReplyTo":"5CCF414A020000A10003108C@gwsmtp.uni-regensburg.de","subject":"Antw: Surprising semantics of \"git add file\"","fromName":"Ulrich Windl","fromEmail":"ulrich.windl@rz.uni-regensburg.de","sentAt":"2019-05-05T20:12:30Z","receivedAt":"2019-05-05T20:12:34Z","isPatch":false,"sender":{"key":"ulrich.windl@rz.uni-regensburg.de","avatar":null},"body":"Actually things are worse: When I tried to fix the comment for the unexpected commit at least using \"git commit --amend\", more files were committed!\n\n>>> Ulrich Windl 05.05.19 22.02 Uhr >>>\nHi!\n\nReading the manual, I realized that \"it is the way it is (it works as documented)\", but to me it's surprising, meaning: I feel it's wrong:\n(git-2.16.4)\nI have staged several files, and then I do \"git add -interactive file\" to add some selected changes from file.\nAfter that a \"git diff --cached file\" just shows the changes added interactively, but when I \"git add file\" to commit those changes), even the unstaged changes from file are committed.\nI feel this is inconsistent: At least \"git diff --cached file\" should behave like \"git commit file\", meaning \"git commit file\" should be fixed IMHO.\nOr are there any reasonable use cased for that?\n\nRegards,\nUlrich Windl\n\n\n\n"},{"id":"374932","messageId":"87o94gbq46.fsf@igel.home","threadId":"51040","inReplyTo":"5CCF414A020000A10003108C@gwsmtp.uni-regensburg.de","subject":"Re: Surprising semantics of \"git add file\"","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2019-05-05T20:31:05Z","receivedAt":"2019-05-05T20:31:53Z","isPatch":false,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"On Mai 05 2019, \"Ulrich Windl\" <Ulrich.Windl@rz.uni-regensburg.de> wrote:\n\n> After that a \"git diff --cached file\" just shows the changes added interactively, but when I \"git add file\" to commit those changes), even the unstaged changes from file are committed.\n\nDid you really mean \"git add\" here?  It doesn't commit, it adds to the index.\n\nAndreas.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1\n\"And now for something completely different.\"\n"},{"id":"374938","messageId":"5CCFDECB020000A1000310EC@gwsmtp.uni-regensburg.de","threadId":"51040","inReplyTo":"87o94gbq46.fsf@igel.home","subject":"Antw: Re: Surprising semantics of \"git add file\"","fromName":"Ulrich Windl","fromEmail":"ulrich.windl@rz.uni-regensburg.de","sentAt":"2019-05-06T07:14:19Z","receivedAt":"2019-05-06T07:14:25Z","isPatch":false,"sender":{"key":"ulrich.windl@rz.uni-regensburg.de","avatar":null},"body":">>> Andreas Schwab <schwab@linux-m68k.org> schrieb am 05.05.2019 um 22:31 in\nNachricht <87o94gbq46.fsf@igel.home>:\n> On Mai 05 2019, \"Ulrich Windl\" <Ulrich.Windl@rz.uni‑regensburg.de> wrote:\n> \n>> After that a \"git diff ‑‑cached file\" just shows the changes added \n> interactively, but when I \"git add file\" to commit those changes), even the\n\n> unstaged changes from file are committed.\n> \n> Did you really mean \"git add\" here?  It doesn't commit, it adds to the \n> index.\n\nSorry, you are right \"git commit file\" I meant. I guess I was distracted when\nwriting that. Otherwise it wouldn't make any sense.\n\n> \n> Andreas.\n> \n> ‑‑ \n> Andreas Schwab, schwab@linux‑m68k.org \n> GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1\n> \"And now for something completely different.\"\n\n\n\n"}]}