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

Re: git add -p with new file

From
Jeff King <peff@peff.net>
Date
Dec 10, 2016, 08:55 UTC
Message-ID
<20161210085556.nwg3pbay367jqin5@sigill.intra.peff.net>
In-Reply-To
<alpine.DEB.2.11.1612091331170.13185@cherryberry.dsgml.com>
On Fri, Dec 09, 2016 at 01:43:24PM -0500, Ariel wrote:
> > It's contrary to the rest of git-add for specifying pathspecs to
> > actually make things _more_ inclusive rather than less.
> 
> Is it? Because git add without -p is happy to add new files.

I was just speaking there of whether the presence of the file on the command-line was relevant. In other words, "git add -u untracked-file" does not countermand the "-u" to say "also add this file".

Show 5 quoted lines
> > Historically "add -p" has been more like "add -u" in updating tracked
> > files.
> 
> 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.

Perhaps a config option would be the best path forward (even if we were to switch the default to "true", it leaves an escape hatch for people who do not like the new behavior).

Show 5 quoted lines
> > We have "-A" for "update everything _and_ new files". It doesn't
> > seem unreasonable to me to have a variant of "-p" that is similar.
> 
> That seems unnecessarily complex because -p asks about each file, so you
> will never find new files added without realizing it.

If you care about adding new files, wouldn't you just always use "-P" instead of "-p"?

-Peff
Previous: ArielNext: Junio C Hamano
Message 7 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.