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

Re: Minor UX annoyance w/`git add --patch untracked/file`

From
Jeff King <peff@peff.net>
Date
Dec 6, 2023, 19:54 UTC
Message-ID
<20231206195407.GD103708@coredump.intra.peff.net>
In-Reply-To
<20231130192637.wqpmidfv2roqmxdx@shells.gnugeneration.com>
On Thu, Nov 30, 2023 at 11:26:37AM -0800, Vito Caputo wrote:
Show 12 quoted lines
> Couldn't the following two steps be done automagically by --patch:
> 
> ```
> git add -N path/to/untracked/file/wishing/to/partially/add
> git add --patch path/to/untracked/file/wishing/to/partially/add
> ```
> 
> when one simply does:
> 
> `git add --patch path/to/untracked/file/wishing/to/partially/add`
> 
> ?

They _could_, but keep in mind that the argument is not strictly a path. It is a pathspec that may match multiple paths. So:

  git add -p path/to/

for example will pick up the tracked files in path/to/, but not your untracked one.

It would be possible to distinguish the two cases, and only auto-add files which are explicitly mentioned as full paths. But we usually shy away from too many special cases like this, as the resulting behavior can end up confusing and hard to explain.

-Peff
Previous: Vito CaputoNext: Junio C Hamano
Message 2 of 4 in “Minor UX annoyance w/`git add --patch untracked/file`”
  1. Vito CaputoNov 30, 2023
  2. Jeff KingDec 6, 2023
  3. Junio C HamanoDec 8, 2023
  4. Taylor BlauDec 8, 2023

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.