Re: [RFC PATCH v3 3/8] Read .gitignore from index if it is assume-unchanged
- From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
- Date
- Aug 13, 2009, 06:37 UTC
- Message-ID
- <fcaeb9bf0908122337j7d783f59l8ce7a125bf0dbc7e@mail.gmail.com>
- In-Reply-To
- <7vocqlbv7a.fsf@alter.siamese.dyndns.org>
2009/8/12 Junio C Hamano <gitster@pobox.com>:
Show 17 quoted lines
> Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes: > >> diff --git a/Documentation/technical/api-directory-listing.txt b/Documentation/technical/api-directory-listing.txt >> index 5bbd18f..7d0e282 100644 >> --- a/Documentation/technical/api-directory-listing.txt >> +++ b/Documentation/technical/api-directory-listing.txt >> @@ -58,6 +58,9 @@ The result of the enumeration is left in these fields:: >> Calling sequence >> ---------------- >> >> +* Ensure the_index is populated as it may have CE_VALID entries that >> + affect directory listing. >> + > > When you want to enumerate all paths in the work tree, instead of not just > the untracked ones, it used to be possible to first run read_directory() > before calling read_cache(). You are now forbidding this.
Either I phrased it badly, or I don't follow you. If you don't call read_cache() before read_directory(), the_index should be empty and read_assume_unchanged_from_index() will be no-op. So read_directory() behavior does not change in this case.
Show 5 quoted lines
> I do not think it is hard to resurrect the feature if it is necessary (add > an option to dir_struct and teach dir_add_name() not to ignore paths the > index knows about), and I do not think none of the existing code relies on > it anymore (I think "git add" used to), but there may be some codepath I > forgot about, which is a concern.
Hmm.. "git add" loaded index early since the first version of builtin-add.c. I have checked all code path that can lead to read_directory_recursively(). In all cases, index is loaded before read_dir..() is called.
Show 21 quoted lines
>> diff --git a/builtin-clean.c b/builtin-clean.c
>> index 2d8c735..d917472 100644
>> --- a/builtin-clean.c
>> +++ b/builtin-clean.c
>> @@ -71,8 +71,11 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
>>
>> dir.flags |= DIR_SHOW_OTHER_DIRECTORIES;
>>
>> - if (!ignored)
>> + if (!ignored) {
>> + if (read_cache() < 0)
>> + die("index file corrupt");
>> setup_standard_excludes(&dir);
>> + }
>>
>> pathspec = get_pathspec(prefix, argv);
>> read_cache();
>
> Wouldn't it be much cleaner to move the existing read_cache() up, like you
> did for ls-files, instead of conditionally reading the index at a random
> place in the program sequence depending on the combinations of options?Agreed. read_cache() is called right below anyway.
-- Duy