Skip to content
  • Thomas Rast's avatar
    Make !pattern in .gitattributes non-fatal · 8b1bd024
    Thomas Rast authored and Junio C Hamano's avatar Junio C Hamano committed
    Before 82dce998 (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 82dce998
    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 82dce998 '!' matched that literal
    character, so it is conceivable that users have .gitattributes with
    such lines in them.  After 82dce998
    
     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.
    
    Reported-by: default avatar <mathstuf@gmail.com>
    Signed-off-by: default avatarThomas Rast <trast@student.ethz.ch>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    8b1bd024