Re: Bug: Git sometimes disregards wildcards in pathspecs if a file name matches exactly

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

 



Upon a much closer look into the Git source code, specifically
init_pathspec_item within pathspec.c, my previous hypothesis regarding
the optimization check in do_match_pathspec appears to be incorrect,
or at least not the root cause.

The debugging output confirmed that the core issue seems to originate
earlier, during the pathspec parsing phase. It revealed that when
processing the input string 'f*' (without any explicit magic like
:(glob)), the resulting pathspec_item.magic field does not have the ,
even though the string clearly contains the * glob metacharacter. (To
clarify I did multiple fprintf checks in the do_match_pathspec fun)

Looking at the logic in init_pathspec_item, it seems the PATHSPEC_GLOB
flag is generally only added to item->magic if:
a) The user explicitly uses a magic prefix like :(glob)f*.
b) A global setting like GIT_GLOB_PATHSPECS_ENVIRONMENT is active.

The code does not appear to automatically set PATHSPEC_GLOB on
item->magic simply based on scanning the content of the path string
for unescaped *, ?, or [ characters if no explicit magic prefix is
present.

This explains why the fix attempted in do_match_pathspec (which relied
on checking the PATHSPEC_GLOB flag) was ineffective – the flag wasn't
set in the first place for the 'f*' input. It also explains the
original inconsistent behavior: because the pathspec lacks the
PATHSPEC_GLOB magic flag, parts of Git relying on these flags treat it
as literal by default, even if lower-level matching functions might
still perform some wildcard expansion based on the string content
itself.

So, this seems less like a bug in a specific conditional check and
more like a consequence of the current design where the magic flags
indicating glob behavior are opt-in (via prefixes or environment
variables) rather than implicitly inferred from the pathspec string's
content.

-Jayatheerth





[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]

  Powered by Linux