Re: [RFC PATCH v3 3/8] Read .gitignore from index if it is assume-unchanged

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Nguyễn Thái Ngọc Duy  <pclouds@xxxxxxxxx> 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.

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.

> 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?
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]