Skip to content

Commit 84d938b

Browse files
pcloudsgitster
authored andcommitted
add: do not accept pathspec magic 'attr'
Commit b0db704 (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 message: $ 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. Reported-by: [email protected] Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d33c875 commit 84d938b

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

builtin/add.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
433433
* Check the "pathspec '%s' did not match any files" block
434434
* below before enabling new magic.
435435
*/
436-
parse_pathspec(&pathspec, 0,
436+
parse_pathspec(&pathspec, PATHSPEC_ATTR,
437437
PATHSPEC_PREFER_FULL |
438438
PATHSPEC_SYMLINK_LEADING_PATH,
439439
prefix, argv);

t/t6135-pathspec-with-attrs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ test_expect_success 'fail if attr magic is used places not implemented' '
166166
# though, but git-add is convenient as it has its own internal pathspec
167167
# parsing.
168168
test_must_fail git add ":(attr:labelB)" 2>actual &&
169-
test_i18ngrep "unsupported magic" actual
169+
test_i18ngrep "magic not supported" actual
170170
'
171171

172172
test_expect_success 'abort on giving invalid label on the command line' '

0 commit comments

Comments
 (0)