Commit 84d938b7 authored by Duy Nguyen's avatar Duy Nguyen Committed by Junio C Hamano

add: do not accept pathspec magic 'attr'

Commit b0db7046 (pathspec: allow querying for attributes -
2017-03-13) adds new pathspec magic 'attr' but only with
match_pathspec(). "git add" has some pathspec related code that still
does not know about 'attr' and will bail out:

    $ git add ':(attr:foo)'
    fatal: BUG:dir.c:1584: unsupported magic 40

A better solution would be making this code support 'attr'. But I
don't know how much work is needed (I'm not familiar with this new
magic). For now, let's simply reject this magic with a friendlier

    $ git add ':(attr:foo)'
    fatal: :(attr:foo): pathspec magic not supported by this command: 'attr'

Update t6135 so that the expected error message is from the
"graceful" rejection codepath, not "oops, we were supposed to reject
the request to trigger this magic" codepath.

Signed-off-by: Duy Nguyen's avatarNguyễn Thái Ngọc Duy <>
Signed-off-by: default avatarJunio C Hamano <>
parent d33c8751
......@@ -433,7 +433,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
* Check the "pathspec '%s' did not match any files" block
* below before enabling new magic.
parse_pathspec(&pathspec, 0,
parse_pathspec(&pathspec, PATHSPEC_ATTR,
prefix, argv);
......@@ -166,7 +166,7 @@ test_expect_success 'fail if attr magic is used places not implemented' '
# though, but git-add is convenient as it has its own internal pathspec
# parsing.
test_must_fail git add ":(attr:labelB)" 2>actual &&
test_i18ngrep "unsupported magic" actual
test_i18ngrep "magic not supported" actual
test_expect_success 'abort on giving invalid label on the command line' '
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment