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

Re: git add -p with new file

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 10, 2016, 22:04 UTC
Message-ID
<xmqq37hvphji.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20161210085556.nwg3pbay367jqin5@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 8 quoted lines
> On Fri, Dec 09, 2016 at 01:43:24PM -0500, Ariel wrote:
> ...
>> But it doesn't have to be that way. You could make add -p identical to add
>> without options, except the -p prompts to review diffs first.
>
> The question is whether you would annoy people using "-p" if you started
> including untracked files by default. I agree because it's inherently an
> interactive process that we can be looser with backwards compatibility.

It might be interactive, but it will be irritating that we suddenly have to see hundreds of lines in an untracked file before we are asked to say "no I do not want to add this file" and have to do so for all the untracked files that happen to match the given pathspec.

It might make it less irritating if one of the interactive choices offered in the first prompt were N that tells the command: "No, ignore all the untracked paths", though. I dunno.

Also, because "git add -p" (no pathspec) is NOT a no-op, the similarity Ariel sees with "git add" (no other options) does not hold. As you kept explaining (but perhaps not successfully being understood yet), "add -p" works like "add -u", and it will make the command incoherent if we allowed "git add -p <path>" to add new paths, exactly because "git add -u <path>" does not do so. Of course that can be fixed by allowing "git add -u" to also add new paths that match pathspec.

Of course, Ariel can vote for making "add -p" more like "add" (with no options) than "add -u". I _think_ it is a better way to solve the incoherence than making "add -u" to add new paths. But what it means is that "add -p <paths>" works on both tracked and untracked paths that match the given pathspec <paths>, and also "add -p" (no pathspec) must become a no-op (because "add" without option and pathspec is).

Previous: Jeff KingNext: Jeff King
Message 8 of 17 in “git add -p with new file”
  1. ArielDec 7, 2016
  2. Duy NguyenDec 7, 2016
  3. ArielDec 9, 2016
  4. Stephan BeyerDec 12, 2016
  5. Jeff KingDec 9, 2016
  6. ArielDec 9, 2016
  7. Jeff KingDec 10, 2016
  8. Junio C HamanoDec 10, 2016
  9. Jeff KingDec 11, 2016
  10. Stephan BeyerDec 12, 2016
  11. Jeff KingDec 13, 2016
  12. Junio C HamanoDec 13, 2016
  13. Jeff KingDec 13, 2016
  14. Junio C HamanoDec 13, 2016
  15. git add -p with unmerged files (was: git add -p with new file)Stephan Beyer, Dec 13, 2016
  16. Jeff KingDec 13, 2016
  17. Junio C HamanoDec 13, 2016

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.