public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jon Forrest <nobozo@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: Repost: Inconsistent Behavior in 'git add' (git 2.52.0)?
Date: Thu, 15 Jan 2026 08:55:34 -0800	[thread overview]
Message-ID: <xmqq8qdydddl.fsf@gitster.g> (raw)
In-Reply-To: <12239ac3-bc9c-4484-8633-a255a706011c@gmail.com> (Jon Forrest's message of "Thu, 15 Jan 2026 08:36:49 -0800")

Jon Forrest <nobozo@gmail.com> writes:

> % git init
> Initialized empty Git repository in /tmp/fish/.git/
>
> The index is empty, as shown by
> % git ls-files --cached
> %
>
> I then ran
>
> % git add file1 jon
> git add file1 jon
> The following paths are ignored by one of your .gitignore files:
> file1
>
> Again, this is exactly what I expected. But, running
> '% git ls-files --cached' shows
>
> jon
>
> This is *not* what I expected.

If the exclude mechanism does not allow others to go through when it
kicks in, like "file1 is listed in .gitignore, so it should not be
added unless it is forced", it would make it almost useless.
Imagine running "git add ." instead of running "git add file1 jon"
and seeing that nothing gets added?

It is plausible to teach "git add" to treat paths that are
explicitly named on the command line (as opposed to the paths that
are discovered due to recursion) differently, but that would be a
new feature, not a bugfix, I would think.

Even then, I am not sure how useful it would be.  Imagine running
"git add *" instead of "git add ." or "git add file1 jon" and seeing
that nothing gets added?  Unlike "giving a '.' would let 'git add'
discover 'file1' and 'jon' due to recursion", an asterisk on the
command line that is not quoted is expanded by the shell command
interpreter, and by the time 'git add' sees the parameters given to
it, it cannot tell if 'file1' was explicitly typed or expanded via
'*'.  It would be mildly irritating if the addition is rejected.

So, I dunno.



  reply	other threads:[~2026-01-15 16:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-15 16:36 Repost: Inconsistent Behavior in 'git add' (git 2.52.0)? Jon Forrest
2026-01-15 16:55 ` Junio C Hamano [this message]
2026-01-18 17:50   ` Jon Forrest

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=xmqq8qdydddl.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=nobozo@gmail.com \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox