git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 1/2] fsexcludes: add a programmatic way to exclude files from git's working directory traversal logic

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 11, 2018, 23:52 UTC
Message-ID
<xmqqsh812td0.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20180411200007.8612-2-benpeart@microsoft.com>

I haven't studied and thought about the motivation behind these two patches, but one thing I noticed...

Ben Peart <Ben.Peart@microsoft.com> writes:
Show 35 quoted lines
> diff --git a/dir.c b/dir.c
> index 63a917be45..1aa639b9f4 100644
> --- a/dir.c
> +++ b/dir.c
> @@ -1102,6 +1103,12 @@ int is_excluded_from_list(const char *pathname,
>  			  struct exclude_list *el, struct index_state *istate)
>  {
>  	struct exclude *exclude;
> +
> +	if (*dtype == DT_UNKNOWN)
> +		*dtype = get_dtype(NULL, istate, pathname, pathlen);
> +	if (fsexcludes_is_excluded_from(istate, pathname, pathlen, *dtype) > 0)
> +		return 1;
> +
>  	exclude = last_exclude_matching_from_list(pathname, pathlen, basename,
>  						  dtype, el, istate);
>  	if (exclude)
> @@ -1317,8 +1324,15 @@ struct exclude *last_exclude_matching(struct dir_struct *dir,
>  int is_excluded(struct dir_struct *dir, struct index_state *istate,
>  		const char *pathname, int *dtype_p)
>  {
> -	struct exclude *exclude =
> -		last_exclude_matching(dir, istate, pathname, dtype_p);
> +	struct exclude *exclude;
> +	int pathlen = strlen(pathname);
> +
> +	if (*dtype_p == DT_UNKNOWN)
> +		*dtype_p = get_dtype(NULL, istate, pathname, pathlen);
> +	if (fsexcludes_is_excluded_from(istate, pathname, pathlen, *dtype_p) > 0)
> +		return 1;
> +
> +	exclude = last_exclude_matching(dir, istate, pathname, dtype_p);
>  	if (exclude)
>  		return exclude->flags & EXC_FLAG_NEGATIVE ? 0 : 1;
>  	return 0;

A piece of impression I am getting from the above two hunks is that the fsexcludes_is_excluded_from() function requires a real dtype in its last parameter (i.e. DT_UNKNOWN is not acceptable).

Show 7 quoted lines
> @@ -1671,6 +1685,9 @@ static enum path_treatment treat_one_path(struct dir_struct *dir,
>  	if (dtype != DT_DIR && has_path_in_index)
>  		return path_none;
>  
> +	if (fsexcludes_is_excluded_from(istate, path->buf, path->len, dtype) > 0)
> +		return path_excluded;
> +

And this hunk reinforces that impression (we are comparing dtype with DT_DIR, so we know we cannot be passing DT_UNKNOWN to it).

Show 6 quoted lines
> @@ -2011,6 +2028,8 @@ static enum path_treatment read_directory_recursive(struct dir_struct *dir,
>  		/* add the path to the appropriate result list */
>  		switch (state) {
>  		case path_excluded:
> +			if (fsexcludes_is_excluded_from(istate, path.buf, path.len, DTYPE(cdir.de)) > 0)
> +				break;

Then the use of DTYPE() looks a bit odd here. On NO_D_TYPE_IN_DIRENT platforms, we would get DT_UNKNOWN out of it and then end up passing DT_UNKNOWN to the function.

Previous: Ben PeartNext: Ben Peart
Message 9 of 17 in “fsexcludes: Add programmatic way to exclude files”
  1. 0/2 fsexcludes: Add programmatic way to exclude filesBen Peart, Apr 10, 2018
  2. 2/2 fsmonitor: switch to use new fsexcludes logic and remove unused untracked cache based logicBen Peart, Apr 10, 2018
  3. 1/2 fsexcludes: add a programmatic way to exclude files from git's working directory traversal logicBen Peart, Apr 10, 2018
  4. Martin ÅgrenApr 10, 2018
  5. Ben PeartApr 11, 2018
  6. Junio C HamanoApr 11, 2018
  7. 0/2 fsexcludes: Add programmatic way to exclude filesBen Peart, Apr 11, 2018
  8. 1/2 fsexcludes: add a programmatic way to exclude files from git's working directory traversal logicBen Peart, Apr 11, 2018
  9. Junio C HamanoApr 11, 2018
  10. Ben PeartApr 13, 2018
  11. 2/2 fsmonitor: switch to use new fsexcludes logic and remove unused untracked cache based logicBen Peart, Apr 11, 2018
  12. 0/2 fsexcludes: Add programmatic way to exclude filesBen Peart, Apr 13, 2018
  13. 1/2 fsexcludes: add a programmatic way to exclude files from git's working directory traversal logicBen Peart, Apr 13, 2018
  14. 2/2 fsmonitor: switch to use new fsexcludes logic and remove unused untracked cache based logicBen Peart, Apr 13, 2018
  15. Ben PeartApr 18, 2018
  16. Junio C HamanoApr 18, 2018
  17. Duy NguyenApr 14, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.