pathspec magic: add '^' as alias for '!'
authorLinus Torvalds <torvalds@linux-foundation.org>
Wed, 8 Feb 2017 05:05:28 +0000 (21:05 -0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 10 Feb 2017 21:19:10 +0000 (13:19 -0800)
The choice of '!' for a negative pathspec ends up not only not matching
what we do for revisions, it's also a horrible character for shell
expansion since it needs quoting.

So add '^' as an alternative alias for an excluding pathspec entry.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/glossary-content.txt
pathspec.c
index 8ad29e61a950c2cb1f33779977a33c63ae0df33b..822ca832640fe0142e364e99468715d45d2e1fc5 100644 (file)
@@ -386,8 +386,8 @@ Glob magic is incompatible with literal magic.
 
 exclude;;
        After a path matches any non-exclude pathspec, it will be run
-       through all exclude pathspec (magic signature: `!`). If it
-       matches, the path is ignored.
+       through all exclude pathspec (magic signature: `!` or its
+       synonym `^`). If it matches, the path is ignored.
 --
 
 [[def_parent]]parent::
index 7ababb315944d5536ec251b19937beef5def2538..ecad03406397338961fa0cb065b7ca18889d86ef 100644 (file)
@@ -224,6 +224,12 @@ static const char *parse_short_magic(unsigned *magic, const char *elem)
                char ch = *pos;
                int i;
 
+               /* Special case alias for '!' */
+               if (ch == '^') {
+                       *magic |= PATHSPEC_EXCLUDE;
+                       continue;
+               }
+
                if (!is_pathspec_magic(ch))
                        break;