git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Make !pattern in .gitattributes non-fatal

From
Duy Nguyen <pclouds@gmail.com>
Date
Mar 2, 2013, 03:50 UTC
Message-ID
<CACsJy8CO1i1_QpMbLvfys=wsLDPTK69_9JanQYq2D3-fboK_WA@mail.gmail.com>
In-Reply-To
<a1679159dbe67c34675bbe016e131260310db189.1362168366.git.trast@student.ethz.ch>
On Sat, Mar 2, 2013 at 3:06 AM, Thomas Rast <trast@student.ethz.ch> wrote:
Show 21 quoted lines
> Before 82dce99 (attr: more matching optimizations from .gitignore,
> 2012-10-15), .gitattributes did not have any special treatment of a
> leading '!'.  The docs, however, always said
>
>   The rules how the pattern matches paths are the same as in
>   `.gitignore` files; see linkgit:gitignore[5].
>
> By those rules, leading '!' means pattern negation.  So 82dce99
> correctly determined that this kind of line makes no sense and should
> be disallowed.
>
> However, users who actually had a rule for files starting with a '!'
> are in a bad position: before 82dce99 '!' matched that literal
> character, so it is conceivable that users have .gitattributes with
> such lines in them.  After 82dce99 the unescaped version was
> disallowed in such a way that git outright refuses to run(!) most
> commands in the presence of such a .gitattributes.  It therefore
> becomes very hard to fix, let alone work with, such repositories.
>
> Let's at least allow the users to fix their repos: change the fatal
> error into a warning.

I agree we should not break existing .gitattributes. So yes, die()ing here sounds bad. But..

Show 12 quoted lines
> @@ -255,9 +255,11 @@ static struct match_attr *parse_attr_line(const char *line, const char *src,
>                                       &res->u.pat.patternlen,
>                                       &res->u.pat.flags,
>                                       &res->u.pat.nowildcardlen);
> -               if (res->u.pat.flags & EXC_FLAG_NEGATIVE)
> -                       die(_("Negative patterns are forbidden in git attributes\n"
> -                             "Use '\\!' for literal leading exclamation."));
> +               if (res->u.pat.flags & EXC_FLAG_NEGATIVE) {
> +                       warning(_("Negative patterns are ignored in git attributes\n"
> +                                 "Use '\\!' for literal leading exclamation."));
> +                       return NULL;
> +               }

This "return NULL;" means we ignore "!blah" pattern, which is a regression, isn't it? Should we treat '!' as literal here?

-- 
Duy
Previous: Junio C HamanoNext: Junio C Hamano
Message 6 of 8 in “Make !pattern in .gitattributes non-fatal”
  1. Make !pattern in .gitattributes non-fatalThomas Rast, Mar 1, 2013
  2. Junio C HamanoMar 1, 2013
  3. Junio C HamanoMar 1, 2013
  4. Thomas RastMar 1, 2013
  5. Junio C HamanoMar 1, 2013
  6. Duy NguyenMar 2, 2013
  7. Junio C HamanoMar 3, 2013
  8. attr: always treat the leading exclamation mark as literalNguyễn Thái Ngọc Duy, Mar 2, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.