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 8, 2010, 19:12 UTC
Message-ID
<a038bef51002081112s2d552835m4b34973f797ab4f8@mail.gmail.com>
In-Reply-To
<20100208182929.GB14355@neumann>
2010/2/8 SZEDER Gábor <szeder@ira.uka.de>:
Show 17 quoted lines
> Hi,
>
>
> $ git --version
> git version 1.7.0.rc1.84.g9879
> $ git add -u nonexistent-file
> $ echo $?
> 0
>
> No error message, no error in exit status.
>
> Is it OK this way?  Why?
>
>
> Best,
> Gábor
>
Hi,
I see the same behaviour with git version 1.6.4.2.
From the man page of git-add
-u, --update
           Update only files that git already knows about, staging
modified content for
           commit and marking deleted files for removal.
So git will only look at files that are already in the repository.

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.

'git add nonexistent-file' works as expected, exiting with an error message and non-zero exit status.

Previous: SZEDER GáborNext: Jeff King
Message 2 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.