Skip to content

Commit 42ebeb9

Browse files
torvaldsgitster
authored andcommitted
pathspec magic: add '^' as alias for '!'
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6e3a7b3 commit 42ebeb9

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

Documentation/glossary-content.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,8 @@ Glob magic is incompatible with literal magic.
386386

387387
exclude;;
388388
After a path matches any non-exclude pathspec, it will be run
389-
through all exclude pathspec (magic signature: `!`). If it
390-
matches, the path is ignored.
389+
through all exclude pathspec (magic signature: `!` or its
390+
synonym `^`). If it matches, the path is ignored.
391391
--
392392

393393
[[def_parent]]parent::

pathspec.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,12 @@ static const char *parse_short_magic(unsigned *magic, const char *elem)
224224
char ch = *pos;
225225
int i;
226226

227+
/* Special case alias for '!' */
228+
if (ch == '^') {
229+
*magic |= PATHSPEC_EXCLUDE;
230+
continue;
231+
}
232+
227233
if (!is_pathspec_magic(ch))
228234
break;
229235

0 commit comments

Comments
 (0)