From: Junio C Hamano <gitster@pobox.com>
To: Duy Nguyen <pclouds@gmail.com>
Cc: Antoine Pelisse <apelisse@gmail.com>,
Thomas Ferris Nicolaisen <tfnico@gmail.com>,
"git\@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: git add -A fails in empty repository since 1.8.5
Date: Wed, 18 Dec 2013 12:57:06 -0800 [thread overview]
Message-ID: <xmqqhaa5ho7x.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <CACsJy8DY7eZm7-P=azJF-jEiBKM_QPf_GXG3uzbuw5C1vq1Q5A@mail.gmail.com> (Duy Nguyen's message of "Wed, 18 Dec 2013 18:59:31 +0700")
Duy Nguyen <pclouds@gmail.com> writes:
> On Wed, Dec 18, 2013 at 3:44 PM, Antoine Pelisse <apelisse@gmail.com> wrote:
>> FWIW, git-bisect points to 84b8b5d (that is $gmane/230349).
>>
>> On Wed, Dec 18, 2013 at 9:06 AM, Thomas Ferris Nicolaisen
>> <tfnico@gmail.com> wrote:
>>> This was discussed on the Git user list recently [1].
>>>
>>> #in a repo with no files
>>>> git add -A
>>> fatal: pathspec '.' did not match any files
>>>
>>> The same goes for git add . (and -u).
>>>
>>> Whereas I think some warning feedback is useful, we are curious
>>> whether this is an intentional change or not.
>
> I was not aware of this case when I made the change. It's caused by
> this change that removes pathspec.raw[i][0] check in builtin/add.c in
> 84b8b5d .
>
> - for (i = 0; pathspec.raw[i]; i++) {
> - if (!seen[i] && pathspec.raw[i][0]
> - && !file_exists(pathspec.raw[i])) {
> + for (i = 0; i < pathspec.nr; i++) {
> + const char *path = pathspec.items[i].match;
> + if (!seen[i] && !file_exists(path)) {
Isn't that pathspec.raw[i][0] check merely an attempt to work around
the combination of
(1) "the current directory" pathspec "." is sanitized down to an
empty string by the pathspec code; and
(2) even though file_exists() is willing to say "yes" to a non-file
(namely, a directory), it is not prepared to take an empty
string resulting from (1) to mean "the directory .".
> Adding it back requires some thinking because "path" in the new code
> could be something magic..
Ehh, why? Shouldn't "something magic" that did _not_ match
(i.e. not in seen[]) diagnosed as such?
I am wondering why we even need !file_exists(path) check there in
the first place. We run fill_directory() and then let
prune_directory() report which pathspec did not have any match via
the seen[] array. We also match pathspec against the index to see
if there are pathspec that does not match anything. So at that
point of the codeflow, we ought to be able to make sure that seen[]
is the _only_ thing we need to consult to see if there are any
pathspec elements that did not match.
Stepping back even further, I wonder if this "yes, I found a
matching entity and know this is not an end-user typo" bit actually
should be _in_ "struct pathspec". Traditionally we implemented that
bit as a separate seen[] array parallel to "const char **pathspec"
array, but that was merely because we only had the list of strings.
Now we express a pathspec as a list of "struct pathspec" elements,
I think seen[] can and should become part of the pathspec. Am I
missing something?
> and the new behavior makes sense, so I'm
> inclined to keep it as is, unless people have other opinions.
>
>>>
>>> [1] https://groups.google.com/d/topic/git-users/Qs4YSPhTsqE/discussion
>>> --
>>> To unsubscribe from this list: send the line "unsubscribe git" in
>>> the body of a message to majordomo@vger.kernel.org
>>> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2013-12-18 20:57 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-18 8:06 git add -A fails in empty repository since 1.8.5 Thomas Ferris Nicolaisen
2013-12-18 8:44 ` Antoine Pelisse
2013-12-18 11:59 ` Duy Nguyen
2013-12-18 18:54 ` Junio C Hamano
2013-12-18 19:24 ` Matthieu Moy
2013-12-18 19:56 ` Junio C Hamano
2013-12-18 20:57 ` Junio C Hamano [this message]
2013-12-19 0:49 ` Duy Nguyen
2013-12-23 9:02 ` [PATCH] add: don't complain when adding empty project root Nguyễn Thái Ngọc Duy
2013-12-23 17:48 ` Torsten Bögershausen
2013-12-23 23:46 ` Duy Nguyen
2013-12-24 21:48 ` Torsten Bögershausen
2013-12-24 23:49 ` Duy Nguyen
2014-01-30 11:39 ` Torsten Bögershausen
2014-01-31 18:10 ` Junio C Hamano
2013-12-26 17:25 ` Jonathan Nieder
2013-12-26 18:54 ` Junio C Hamano
2013-12-26 19:24 ` Junio C Hamano
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=xmqqhaa5ho7x.fsf@gitster.dls.corp.google.com \
--to=gitster@pobox.com \
--cc=apelisse@gmail.com \
--cc=git@vger.kernel.org \
--cc=pclouds@gmail.com \
--cc=tfnico@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.