Junio C Hamano <gitster@xxxxxxxxx> writes: > Jeff King <peff@xxxxxxxx> writes: > > > It also feels like any checks like this should be relying on the > > existing pathspec-magic parser a bit more. I don't know the pathspec > > code that well, but surely at some point it has a notion of which parts > > are magic flags (e.g., after parse_element_magic in init_pathspec_item). > > Absolutely. parse_element_magic() decides, by looking at the > character after the initial ':', the we are looking at the longhand > form when magic sequence is introduced by ":(". Absolutely from me too! I would want to re-use more of the existing code. In response to that, patch https://lore.kernel.org/git/20210328152629.16486-1-133706+stdedos@xxxxxxxxxxxxxxxxxxxxxxxx/ clearly shows that it is possible to re-use the de-facto long form magic parsing code to attempt to parse the string that continues as a long form magic. This could theoretically pave the road for mixed short/long form parsing (in that order), if would be so desired. However, as probably suspected, it suffers from one big problem: if (ARRAY_SIZE(pathspec_magic) <= i) die(_("Invalid pathspec magic '%.*s' in '%s'"), (int) len, pos, elem); which is an unconditional `exit(128)`. I don't know if it's possible to rescue (or redirect) that `die` call. In any case, considering that, this again deviates from the "small informative" change this commit was supposed to be. Having said that, I have cooked a working patch with the proposed code.