From: Junio C Hamano <gitster@pobox•com>
To: "D. Ben Knoble" <ben.knoble@gmail•com>
Cc: Eric Frederickson <ericfrederickson68@gmail•com>, git@vger•kernel.org
Subject: Re: A Question from a Hopeful Future Contributor
Date: Mon, 28 Jul 2025 08:02:13 -0700 [thread overview]
Message-ID: <xmqq5xfcz7d6.fsf@gitster.g> (raw)
In-Reply-To: <CALnO6CC+Tn5xFYcHwH-M7kLNt2+gut7Okx7fCuWRdOsQHoDWFw@mail.gmail.com> (D. Ben Knoble's message of "Sat, 26 Jul 2025 10:21:10 -0400")
"D. Ben Knoble" <ben.knoble@gmail•com> writes:
>> >> * "git status" on intent-to-add index entries (say "I" in the first
>> >> column instead of "A" for short status, add "(needs 'git add')" at the
>> >> end of "new file: $path " in long status).
>> >
>> > I am interpreting this todo message as meaning that the following behavior
>> > should be implemented:
>>
>> I think that was done long time ago. The entry may have been a wish-item
>> in April 2011, but not anymore.
>
> At least in 2.48.1 and in git version 2.50.0.rc0.48.g74dbe4346c, this
> behavior isn't present. So I wouldn't call it "done"—maybe there was a
> discussion that it shouldn't be done, though? I didn't search the
> list.
I didn't either, so this response may not be adding much value, but
I think the intent of the above entry is so that the output allows
users to tell between already added entries and about to be added
entries. Perhaps in an ancient version of "git status" did not give
enough information to allow us to tell the status of the index entry
for the path and the status of the working tree file for the path
separately, or something?
In any case, we do not need to add anything to achieve that today.
$ >P
$ cp P Q
$ git add -N P
$ git add Q
The user expresses an intent to add P and actually adds Q.
$ git status -suno
A P
A Q
The first column of the output is about how the path in the index
compares with the HEAD, and the second column is about how working
tree file compares with the index. A file that hasn't been added
(e.g., untracked cruft) is not even known to the index so the latter
is _usually_ only for tracked files. The fact that P appears as
"_A" is a sign enough that its contents haven't been added to the
index, but only that the index has been made aware of the presence
of the path, which is exactly what intent-to-add is about.
If you further add P, this time for real, the status would become
"A_" (i.e. to the index, new contents added relative to HEAD; to the
working tree there is no change relative to the index), but the
intent-to-add bit is gone once the index has (a version of) contents
for the path P.
Normal output without "-s" is even easier to reason about.
$ git status -uno
On branch foo
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
new file: Q
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)
new file: P
P is _known_ to the system but its contents is not added at all, so
it is "not staged for commit", and known as a "new" file.
next prev parent reply other threads:[~2025-07-28 15:02 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-18 22:26 A Question from a Hopeful Future Contributor Eric Frederickson
2025-07-18 23:15 ` Junio C Hamano
2025-07-19 19:57 ` Eric Frederickson
2025-07-26 14:21 ` D. Ben Knoble
2025-07-28 15:02 ` Junio C Hamano [this message]
2025-07-28 16:54 ` D. Ben Knoble
2025-07-18 23:31 ` Ayush Chandekar
2025-07-19 22:06 ` Lucas Seiki Oshiro
2025-07-20 1:02 ` Eric Frederickson
2025-07-19 22:16 ` brian m. carlson
2025-07-20 1:22 ` Eric Frederickson
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqq5xfcz7d6.fsf@gitster.g \
--to=gitster@pobox$(echo .)com \
--cc=ben.knoble@gmail$(echo .)com \
--cc=ericfrederickson68@gmail$(echo .)com \
--cc=git@vger$(echo .)kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox