1. 14 Jun, 2021 1 commit
  2. 05 Jun, 2020 1 commit
  3. 07 Feb, 2020 1 commit
  4. 20 Jul, 2019 1 commit
  5. 18 Jul, 2019 1 commit
    • ignore: fix determining whether a shorter pattern negates another · 6f6340af
      When computing whether we need to store a negative pattern, we iterate
      through all previously known patterns and check whether the negative
      pattern undoes any of the previous ones. In doing so we call `wildmatch`
      and check it's return for any negative error values. If there was a
      negative return, we will abort and bubble up that error to the caller.
      
      In fact, this check for negative values stems from the time where we
      still used `fnmatch` instead of `wildmatch`. For `fnmatch`, negative
      values indicate a "real" error, while for `wildmatch` a negative value
      may be returned if the matching was prematurely aborted. A premature
      abort may for example also happen if the pattern matches a prefix of the
      haystack if the pattern is shorter. Returning an error in that case is
      the wrong thing to do.
      
      Fix the code to compare for equality with `WM_MATCH`, only. Negative
      values returned by `wildmatch` are perfectly fine and thus should be
      ignored. Add a test that verifies we do not see the error.
      Patrick Steinhardt committed
  6. 15 Jun, 2019 1 commit
    • attr_file: convert to use `wildmatch` · 05f9986a
      Upstream git has converted to use `wildmatch` instead of
      `fnmatch`. Convert our gitattributes logic to use `wildmatch` as
      the last user of `fnmatch`. Please, don't expect I know what I'm
      doing here: the fnmatch parser is one of the most fun things to
      play around with as it has a sh*tload of weird cases. In all
      honesty, I'm simply relying on our tests that are by now rather
      comprehensive in that area.
      
      The conversion actually fixes compatibility with how git.git
      parser "**" patterns when the given path does not contain any
      directory separators. Previously, a pattern "**.foo" erroneously
      wouldn't match a file "x.foo", while git.git would match.
      
      Remove the new-unused LEADINGDIR/NOLEADINGDIR flags for
      `git_attr_fnmatch`.
      Patrick Steinhardt committed
  7. 13 Jun, 2019 2 commits
    • attr_file: account for escaped escapes when searching trailing space · b3b6a39d
      When determining the trailing space length, we need to honor
      whether spaces are escaped or not. Currently, we do not check
      whether the escape itself is escaped, though, which might
      generate an off-by-one in that case as we will simply treat the
      space as escaped.
      
      Fix this by checking whether the backslashes preceding the space
      are themselves escaped.
      Patrick Steinhardt committed
    • attr_file: fix unescaping of escapes required for fnmatch · 10ac298c
      When parsing attribute patterns, we will eventually unescape the
      parsed pattern. This is required because we require custom
      escapes for whitespace characters, as normally they are used to
      terminate the current pattern. Thing is, we don't only unescape
      those whitespace characters, but in fact all escaped sequences.
      So for example if the pattern was "\*", we unescape that to "*".
      As this is directly passed to fnmatch(3) later, fnmatch would
      treat it as a simple glob matching all files where it should
      instead only match a file with name "*".
      
      Fix the issue by unescaping spaces, only. Add a bunch of tests to
      exercise escape parsing.
      Patrick Steinhardt committed
  8. 07 Jun, 2019 1 commit
    • tests: unify ignore tests into their own dir · 01dda5ff
      We had several occasions where tests for the gitignore had been
      added to status::ignore instead of the easier-to-handle
      attr::ignore test suite. This most likely resulted from the fact
      that the attr::ignore test suite is not easy to discover inside
      of the attr folder. Furthermore, ignore being part of the
      attributes code is an implementation detail, only, and thus
      shouldn't be stressed as much.
      
      Improve this by moving both attr::ignore and status::ignore tests
      into a new ignore test suite.
      Patrick Steinhardt committed
  9. 06 Jun, 2019 1 commit
    • ignore: handle escaped trailing whitespace · d81e7866
      The gitignore's pattern format specifies that "Trailing spaces
      are ignored unless they are quoted with backslash ("\")". We do
      not honor this currently and will treat a pattern "foo\ " as if
      it was "foo\" only and a pattern "foo\ \ " as "foo\ \".
      
      Fix our code to handle those special cases and add tests to avoid
      regressions.
      Patrick Steinhardt committed
  10. 05 Apr, 2019 1 commit
    • ignore: treat paths with trailing "/" as directories · 9d117e20
      The function `git_ignore_path_is_ignored` is there to test the
      ignore status of paths that need not necessarily exist inside of
      a repository. This has the implication that for a given path, we
      cannot always decide whether it references a directory or a file,
      and we need to distinguish those cases because ignore rules may
      treat those differently. E.g. given the following gitignore file:
      
          *
          !/**/
      
      we'd only want to unignore directories, while keeping files
      ignored. But still, calling `git_ignore_path_is_ignored("dir/")`
      will say that this directory is ignored because it treats "dir/"
      as a file path.
      
      As said, the `is_ignored` function cannot always decide whether
      the given path is a file or directory, and thus it may produce
      wrong results in some cases. While this is unfixable in the
      general case, we can do better when we are being passed a path
      name with a trailing path separator (e.g. "dir/") and always
      treat them as directories.
      Patrick Steinhardt committed
  11. 20 Mar, 2019 1 commit
  12. 12 Apr, 2018 1 commit
    • attr_file: fix handling of directory patterns with trailing spaces · 251d8771
      When comparing whether a path matches a directory rule, we pass the
      both the path and directory name to `fnmatch` with
      `GIT_ATTR_FNMATCH_DIRECTORY` being set. `fnmatch` expects the pattern to
      contain no trailing directory '/', which is why we try to always strip
      patterns of trailing slashes. We do not handle that case correctly
      though when the pattern itself has trailing spaces, causing the match to
      fail.
      
      Fix the issue by stripping trailing spaces and tabs for a rule previous
      to checking whether the pattern is a directory pattern with a trailing
      '/'. This replaces the whitespace-stripping in our ignore file parsing
      code, which was stripping whitespaces too late. Add a test to catch
      future breakage.
      Patrick Steinhardt committed
  13. 29 Oct, 2017 1 commit
  14. 25 Aug, 2017 2 commits
    • ignore: honor case insensitivity for negative ignores · 2d9ff8f5
      When computing negative ignores, we throw away any rule which does not
      undo a previous rule to optimize. But on case insensitive file systems,
      we need to keep in mind that a negative ignore can also undo a previous
      rule with different case, which we did not yet honor while determining
      whether a rule undoes a previous one. So in the following example, we
      fail to unignore the "/Case" directory:
      
          /case
          !/Case
      
      Make both paths checking whether a plain- or wildcard-based rule undo a
      previous rule aware of case-insensitivity. This fixes the described
      issue.
      Patrick Steinhardt committed
    • ignore: keep negative rules containing wildcards · b8922fc8
      Ignore rules allow for reverting a previously ignored rule by prefixing
      it with an exclamation mark. As such, a negative rule can only override
      previously ignored files. While computing all ignore patterns, we try to
      use this fact to optimize away some negative rules which do not override
      any previous patterns, as they won't change the outcome anyway.
      
      In some cases, though, this optimization causes us to get the actual
      ignores wrong for some files. This may happen whenever the pattern
      contains a wildcard, as we are unable to reason about whether a pattern
      overrides a previous pattern in a sane way. This happens for example in
      the case where a gitignore file contains "*.c" and "!src/*.c", where we
      wouldn't un-ignore files inside of the "src/" subdirectory.
      
      In this case, the first solution coming to mind may be to just strip the
      "src/" prefix and simply compare the basenames. While that would work
      here, it would stop working as soon as the basename pattern itself is
      different, like for example with "*x.c" and "!src/*.c. As such, we
      settle for the easier fix of just not optimizing away rules that contain
      a wildcard.
      Patrick Steinhardt committed
  15. 17 May, 2017 1 commit
  16. 17 Feb, 2017 2 commits
  17. 19 Apr, 2016 1 commit
    • ignore: fix directory limits when searching for star-star · 1c3018eb
      In order to match the star-star, we disable the flag that's looking for
      a single path element, but that leads to searching for the pattern in
      the middle of elements in the input string.
      
      Mark when we're handing a star-star so we jump over the elements in our
      attempt to match the part of the pattern that comes after the star-star.
      
      While here, tighten up the check so we don't allow invalid rules
      through.
      Carlos Martín Nieto committed
  18. 18 Apr, 2016 1 commit
  19. 02 Apr, 2016 1 commit
  20. 13 May, 2015 1 commit
  21. 12 May, 2015 3 commits
  22. 23 Apr, 2015 1 commit
  23. 02 May, 2014 1 commit
    • Improve handling of fake home directory · 0f603132
      There are a few tests that set up a fake home directory and a
      fake GLOBAL search path so that we can test things in global
      ignore or attribute or config files.  This cleans up that code to
      work more robustly even if there is a test failure.  This also
      fixes some valgrind warnings where scanning search paths for
      separators could end up doing a little bit of sketchy data access
      when coming to the end of search list.
      Russell Belfer committed
  24. 01 May, 2014 1 commit
  25. 18 Apr, 2014 1 commit
  26. 14 Apr, 2014 1 commit
    • Fix core.excludesfile named .gitignore · a9528b8f
      Ignore rules with slashes in them are matched using FNM_PATHNAME
      and use the path to the .gitignore file from the root of the
      repository along with the path fragment (including slashes) in
      the ignore file itself.  Unfortunately, the relative path to the
      .gitignore file was being applied to the global core.excludesfile
      if that was also named ".gitignore".
      
      This fixes that with more precise matching and includes test for
      ignore rules with leading slashes (which were the primary example
      of this being broken in the real world).
      
      This also backports an improvement to the file context logic from
      the threadsafe-iterators branch where we don't rely on mutating
      the key of the attribute file name to generate the context path.
      Russell Belfer committed
  27. 06 Apr, 2014 1 commit
  28. 05 Apr, 2014 1 commit
  29. 14 Nov, 2013 1 commit
  30. 29 May, 2013 1 commit
  31. 24 May, 2013 1 commit
    • Add ~ expansion to global attributes and excludes · 7a5ee3dc
      This adds ~/ prefix expansion for the value of core.attributesfile
      and core.excludesfile, plus it fixes the fact that the attributes
      cache was holding on to the string data from the config for a long
      time (instead of making its own strdup) which could have caused a
      problem if the config was refreshed.  Adds a test for the new
      expansion capability.
      Russell Belfer committed
  32. 22 Feb, 2013 2 commits