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

Re: git add -u nonexistent-file

From
Chris Packham <judge.packham@gmail.com>
Date
Feb 9, 2010, 14:43 UTC
Message-ID
<a038bef51002090643g23b35bb6xaa765ff13b80f5bb@mail.gmail.com>
In-Reply-To
<20100209003958.GA4065@coredump.intra.peff.net>
On Mon, Feb 8, 2010 at 7:39 PM, Jeff King <peff@peff.net> wrote:
Show 26 quoted lines
> On Mon, Feb 08, 2010 at 02:12:41PM -0500, Chris Packham wrote:
>
>> > $ git add -u nonexistent-file
>> > $ echo $?
>> > 0
>> [...]
>> It looks like in the case you've highlighted git is ignoring the extra
>> non-option parameters on the command line. I'll let other people argue
>> whether this is by design or omission.
>
> It's not ignoring the extra parameters. They limit the scope of the
> operation. So:
>
>  $ git init
>  $ touch file && mkdir subdir && touch subdir/file
>  $ git add . && git commit -m one
>  $ echo changes >file && echo changes >subdir/file
>  $ git add -u subdir
>  $ git status
>  # On branch master
>  # Changes to be committed:
>  #       modified:   subdir/file
>  #
>  # Changed but not updated:
>  #       modified:   file
>  #

Yep my bad. I tried the non-existent case but not the "normal" case. Re reading the man page it makes sense it just happens that the <filepattern> part scrolls off the top when I get to the -u part.

Show 7 quoted lines
> That being said, you noticed that the regular add case notes unused
> pathspecs on the command line:
>
>  $ git add bogus
>  fatal: pathspec 'bogus' did not match any files
>
> We could probably do the same here.

I think so. By not having this error it led me to think "OK it just throws away the pathspec". Gabor rightly thought that it does use it so shouldn't it be giving an error.

If I get brave enough I could attempt a patch but I wouldn't let that dissuade anyone that actually knows what they're doing from jumping in with a patch.

Previous: Jeff KingNext: Chris Packham
Message 4 of 13 in “git add -u nonexistent-file”
  1. SZEDER GáborFeb 8, 2010
  2. Chris PackhamFeb 8, 2010
  3. Jeff KingFeb 9, 2010
  4. Chris PackhamFeb 9, 2010
  5. test for add with non-existent pathspecChris Packham, Feb 9, 2010
  6. Junio C HamanoFeb 9, 2010
  7. Chris PackhamFeb 9, 2010
  8. Chris PackhamFeb 9, 2010
  9. 1/3 test for add with non-existent pathspecChris Packham, Feb 9, 2010
  10. 2/3 git add -u: give an error if pathspec unmatchedChris Packham, Feb 9, 2010
  11. 3/3 t2200-add-update.sh: change expected fail to successChris Packham, Feb 9, 2010
  12. Junio C HamanoFeb 9, 2010
  13. Jeff KingFeb 10, 2010

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.