{"thread":{"id":"60573","subject":"Minor UX annoyance w/`git add --patch untracked/file`","startedAt":"2023-11-30T19:34:10Z","lastAt":"2023-12-08T22:29:43Z","messageCount":4,"participants":["Vito Caputo","Jeff King","Junio C Hamano","Taylor Blau"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"485286","messageId":"20231130192637.wqpmidfv2roqmxdx@shells.gnugeneration.com","threadId":"60573","inReplyTo":null,"subject":"Minor UX annoyance w/`git add --patch untracked/file`","fromName":"Vito Caputo","fromEmail":"vcaputo@pengaru.com","sentAt":"2023-11-30T19:26:37Z","receivedAt":"2023-11-30T19:34:10Z","isPatch":false,"sender":{"key":"vcaputo@pengaru.com","avatar":null},"body":"Hello list,\n\nCouldn't the following two steps be done automagically by --patch:\n\n```\ngit add -N path/to/untracked/file/wishing/to/partially/add\ngit add --patch path/to/untracked/file/wishing/to/partially/add\n```\n\nwhen one simply does:\n\n`git add --patch path/to/untracked/file/wishing/to/partially/add`\n\n?\n\nCheers,\nVito Caputo\n"},{"id":"485394","messageId":"20231206195407.GD103708@coredump.intra.peff.net","threadId":"60573","inReplyTo":"20231130192637.wqpmidfv2roqmxdx@shells.gnugeneration.com","subject":"Re: Minor UX annoyance w/`git add --patch untracked/file`","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2023-12-06T19:54:07Z","receivedAt":"2023-12-06T19:54:08Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Nov 30, 2023 at 11:26:37AM -0800, Vito Caputo wrote:\n\n> Couldn't the following two steps be done automagically by --patch:\n> \n> ```\n> git add -N path/to/untracked/file/wishing/to/partially/add\n> git add --patch path/to/untracked/file/wishing/to/partially/add\n> ```\n> \n> when one simply does:\n> \n> `git add --patch path/to/untracked/file/wishing/to/partially/add`\n> \n> ?\n\nThey _could_, but keep in mind that the argument is not strictly a path.\nIt is a pathspec that may match multiple paths. So:\n\n  git add -p path/to/\n\nfor example will pick up the tracked files in path/to/, but not your\nuntracked one.\n\nIt would be possible to distinguish the two cases, and only auto-add\nfiles which are explicitly mentioned as full paths. But we usually shy\naway from too many special cases like this, as the resulting behavior\ncan end up confusing and hard to explain.\n\n-Peff\n"},{"id":"485481","messageId":"xmqqmsuk1jvp.fsf@gitster.g","threadId":"60573","inReplyTo":"20231206195407.GD103708@coredump.intra.peff.net","subject":"Re: Minor UX annoyance w/`git add --patch untracked/file`","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2023-12-08T21:09:46Z","receivedAt":"2023-12-08T21:09:49Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> They _could_, but keep in mind that the argument is not strictly a path.\n> It is a pathspec that may match multiple paths. So:\n>\n>   git add -p path/to/\n>\n> for example will pick up the tracked files in path/to/, but not your\n> untracked one.\n\nThe corresponding command w/o \"-p\", i.e., \"git add path/to/\", will\npick up both tracked and untracked ones from the named directory,\nwhile honoring the ignore settings.  So I suspect it might feel more\nnatural if \"-p\" followed suit.\n\nNot that I feel strongly either way.  The command has only worked\nwith already tracked files since its inception and nobody complained\nin the past 15 years or so, probably because nobody cared that much\nfor relatively rare event of creating a new file and adding it.\n\nThanks.\n"},{"id":"485489","messageId":"ZXOY1Qq4MKQPEEAZ@nand.local","threadId":"60573","inReplyTo":"xmqqmsuk1jvp.fsf@gitster.g","subject":"Re: Minor UX annoyance w/`git add --patch untracked/file`","fromName":"Taylor Blau","fromEmail":"me@ttaylorr.com","sentAt":"2023-12-08T22:29:41Z","receivedAt":"2023-12-08T22:29:43Z","isPatch":false,"sender":{"key":"me@ttaylorr.com","avatar":"https://avatars.githubusercontent.com/u/301000140?v=4"},"body":"On Sat, Dec 09, 2023 at 06:09:46AM +0900, Junio C Hamano wrote:\n> Jeff King <peff@peff.net> writes:\n>\n> > They _could_, but keep in mind that the argument is not strictly a path.\n> > It is a pathspec that may match multiple paths. So:\n> >\n> >   git add -p path/to/\n> >\n> > for example will pick up the tracked files in path/to/, but not your\n> > untracked one.\n>\n> The corresponding command w/o \"-p\", i.e., \"git add path/to/\", will\n> pick up both tracked and untracked ones from the named directory,\n> while honoring the ignore settings.  So I suspect it might feel more\n> natural if \"-p\" followed suit.\n\nI tend to agree. I do think that the full specification of when \"git add\n-p\" implies \"git add -N ... && git add -p\" would be difficult to explain\nto users.\n\nBut I think it's a worthwhile trade-off in that it makes the UX more\nconsistent in the common case (where the argument to add is a literal\npath, not a pathspec).\n\nThanks,\nTaylor\n"}]}