• Duy Nguyen's avatar
    pathspec: stop --*-pathspecs impact on internal parse_pathspec() uses · 4a2d5ae2
    Duy Nguyen authored
    Normally parse_pathspec() is used on command line arguments where it
    can do fancy thing like parsing magic on each argument or adding magic
    for all pathspecs based on --*-pathspecs options.
    There's another use of parse_pathspec(), where pathspec is needed, but
    the input is known to be pure paths. In this case we usually don't
    want --*-pathspecs to interfere. And we definitely do not want to
    parse magic in these paths, regardless of --literal-pathspecs.
    Add new flag PATHSPEC_LITERAL_PATH for this purpose. When it's set,
    --*-pathspecs are ignored, no magic is parsed. And if the caller
    allows PATHSPEC_LITERAL (i.e. the next calls can take literal magic),
    then PATHSPEC_LITERAL will be set.
    This fixes cases where git chokes when GIT_*_PATHSPECS are set because
    parse_pathspec() indicates it won't take any magic. But
    GIT_*_PATHSPECS add them anyway. These are
       git blame -- something
       git log --follow something
       git log --merge
    "git ls-files --with-tree=path" (aka parse_pathspec() in
    overlay_tree_on_cache()) is safe because the input is empty, and
    producing one pathspec due to PATHSPEC_PREFER_CWD does not take any
    magic into account.
    Signed-off-by: Duy Nguyen's avatarNguyễn Thái Ngọc Duy <pclouds@gmail.com>
    Acked-by: default avatarJeff King <peff@peff.net>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
t6130-pathspec-noglob.sh 3.99 KB