git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Philip Oakley <philipoakley@iee.email>
To: Angelo Borsotti <angelo.borsotti@gmail.com>
Cc: Git List <git@vger.kernel.org>
Subject: Re: Git add documentation error
Date: Thu, 27 Oct 2022 17:16:03 +0100	[thread overview]
Message-ID: <2ed22fa1-4d9d-e50a-18cf-048007272729@iee.email> (raw)
In-Reply-To: <CAB9Jk9BBddd5d0wKFB0eJw1OMMAQj88J9Bn1Yn1rbK_F1mEs1A@mail.gmail.com>

Hi Angelo, please use 'reply all' so others can participate.
Also, in-line replies are preferred.

On 27/10/2022 16:28, Angelo Borsotti wrote:
> Hi,
>
> I have tested this in the following way: I have two files: C1.java and C2.java
>
>     > git status
>     On branch master
>     nothing added to commit
>     > ... edit C2.java
>     > git status
>     On branch master
>     Changes not staged for commit:
>     (use "git add <file>..." to update what will be committed)
>     (use "git restore <file>..." to discard changes in working directory)
>         modified:   C2.java
>      > git add C1.java
>      > git add C2.java
>      > git commit -m "commit2"
>      D:\gittest>git commit -m "commit1"
>      [master 91ef45d] commit1
>      1 file changed, 1 insertion(+), 1 deletion(-)
>
> In commit1 there is only one file, which is C2.java.

It does say "1 file changed", which is true.
What it fails to mention is all the other files that are included within
the commit, but are unchanged.

Maybe have a look at
https://git-scm.com/docs/git-ls-tree#Documentation/git-ls-tree.txt---name-status,
probably with the -r option (check the command's description)

What Git version & OS are you on?
> This is a useful feature: one can stage all its files without
> bothering to remember
> which one had been changed, and then make a commit, and place the commands
> to do it in a script to be used each time a new commit is needed.
>
> -Angelo
>     ...
>
> On Thu, 27 Oct 2022 at 17:10, Philip Oakley <philipoakley@iee.email> wrote:
>> Hi,
>> On 27/10/2022 12:53, Angelo Borsotti wrote:
>>> Hello,
>>>
>>> the reference manual for the "git add" command does not
>>> specify what that command does when applied to an
>>> unmodified file.
>> I presume that this file is already tracked..
>>> By testing this, I have seen that it does not add the file
>>> to the index,
>> How was this tested?
>>
>> If you have no changes, thaen the status diff will have no mention of
>> that file.
>> Perhaps change the tracked mode bits to see if that is noticed (note
>> though, not all mode bits are tracked..)
>>> and consequently it does not add it when a
>>> subsequent commit is done.
>> I suspect this is a subtle mental model misunderstanding about the
>> distinction between a commit as a snapshot, and a commit being reported
>> as the diff relative to its parent (and here, there is none, if the file
>> is unmodified)
>>> I think that this should be documented.
>> A test script with sample output would help here.
>> --
>> Philip
>>
>>


  parent reply	other threads:[~2022-10-27 16:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-27 11:53 Git add documentation error Angelo Borsotti
2022-10-27 15:10 ` Philip Oakley
     [not found]   ` <CAB9Jk9BBddd5d0wKFB0eJw1OMMAQj88J9Bn1Yn1rbK_F1mEs1A@mail.gmail.com>
2022-10-27 16:16     ` Philip Oakley [this message]
2022-10-27 16:57       ` Angelo Borsotti
2022-10-27 17:28         ` Junio C Hamano
2022-10-27 17:46           ` Angelo Borsotti
2022-10-27 18:44             ` Junio C Hamano
2022-10-27 19:15               ` Angelo Borsotti

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2ed22fa1-4d9d-e50a-18cf-048007272729@iee.email \
    --to=philipoakley@iee.email \
    --cc=angelo.borsotti@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).