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

Re: git-add --verbose should say when something is already indexed

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 29, 2008, 09:02 UTC
Message-ID
<7v63l3e4lz.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<20081229175258.6117@nanako3.lavabit.com>
Nanako Shiraishi <nanako3@lavabit.com> writes:
Show 12 quoted lines
> Quoting jidanni@jidanni.org:
>
>> git-add or at least git-add --verbose should say upon
>> $ git-add bla.txt
>> $ git-add bla.txt
>> bla.txt is already in the index.
>
> I do not think it should.
>
> I suspect that you misunderstand what "git add" is. It is not about adding a new path to be tracked. Rather, it is to add the current contents of the file (unless --interactive is used).
>
> You told git to add the contents of "bla.txt" to the index as path "bla.txt". I do not think there is anything more to report after it did exactly what it was told to do.

That is almost (say, 98%) true, but it is not absolutely outlandishly unreasonable if somebody wants:

    $ git add bla.txt
    $ edit bla.txt
    $ git add bla.txt
and
    $ git add bla.txt
    $ git add bla.txt
to behave differently.  The latter is a pure no-op.

Having said that, I do not think it is worth it. For one thing, if you did:

    $ git add .

after making changes to a few files and created one new file in a project with 20,000 files, command would say "Yo, bozo, you told me to add the same contents for path X" for 19,998 times.

If the report were not negative as Jidanni suggests, but instead were positive, i.e.

    $ git add -v frotz.txt nitfol.txt
    added new contents for frotz.txt
    added new contents for nitfol.txt
    $ edit frotz.txt
    $ git add -v frotz.txt nitfol.txt
    added new contents for frotz.txt

it might be slightly more useful, but I doubt it is that useful in practice.

I won't reject a patch if it is cleanly done, though.
Previous: Nanako ShiraishiNext: jidanni@jidanni.org
Message 3 of 4 in “git-add --verbose should say when something is already indexed”
  1. jidanni@jidanni.orgDec 29, 2008
  2. Nanako ShiraishiDec 29, 2008
  3. Junio C HamanoDec 29, 2008
  4. jidanni@jidanni.orgDec 29, 2008

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.