Re: [RFC PATCH v3 3/8] Read .gitignore from index if it is assume-unchanged
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 12, 2009, 02:51 UTC
- Message-ID
- <7vocqlbv7a.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <1250005446-12047-4-git-send-email-pclouds@gmail.com>
Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
Show 11 quoted lines
> 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.
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.
Show 17 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?