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

Re: [PATCH] dir.c: fix EXC_FLAG_MUSTBEDIR match in sparse checkout

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 8, 2010, 20:13 UTC
Message-ID
<7vfwvbpo9c.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1289153098-15684-1-git-send-email-pclouds@gmail.com>
Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:
Show 10 quoted lines
> Commit c84de70 (excluded_1(): support exclude files in index -
> 2009-08-20) tries to work around the fact that there is no
> directory/file information in index entries, therefore
> EXC_FLAG_MUSTBEDIR match would fail.
>
> Unfortunately the workaround is flawed. This fixes it.
>
> Reported-by: Thomas Rinderknecht <thomasr@sailguy.org>
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
Hmmm...
Show 11 quoted lines
> diff --git a/dir.c b/dir.c
> index d1e5e5e..b2dfb69 100644
> --- a/dir.c
> +++ b/dir.c
> @@ -360,7 +360,8 @@ int excluded_from_list(const char *pathname,
>  
>  			if (x->flags & EXC_FLAG_MUSTBEDIR) {
>  				if (!dtype) {
> -					if (!prefixcmp(pathname, exclude))
> +					if (!prefixcmp(pathname, exclude) &&
> +					    pathname[x->patternlen] == '/')
- Can pathname be much shorter than x->patternlen (it doesn't matter as
  prefixcmp will return false in that case)?
- Can pathname be equal to exclude (yes it can but in that case pathname
  is not a directory but is a regular file, symlink or a submodule)?

So it may be a tricky code, but I do not think it is a "workaround" in any way. Isn't it just a "correct solution"?

By the way, builtin/add.c calls excluded() with DT_UNKNOWN and relies on the fact that the macro is accidentally defined as 0. 108da0d (git add: Add the "--ignore-missing" option for the dry run, 2010-07-10). If it means NULL, it should spell it out as such.

Thanks.
Previous: Thomas RinderknechtNext: Nguyen Thai Ngoc Duy
Message 5 of 6 in “Minor bug with git sparse checkout code”
  1. Thomas RinderknechtNov 7, 2010
  2. Thomas RinderknechtNov 7, 2010
  3. dir.c: fix EXC_FLAG_MUSTBEDIR match in sparse checkoutNguyễn Thái Ngọc Duy, Nov 7, 2010
  4. Thomas RinderknechtNov 7, 2010
  5. Junio C HamanoNov 8, 2010
  6. Nguyen Thai Ngoc DuyNov 9, 2010

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.