1. 05 Dec, 2014 1 commit
    • ignore: match git's rule negation rules · e05b2ff1
      A rule can only negate something which was explicitly mentioned in the
      rules before it. Change our parsing to ignore a negative rule which does
      not negate something mentioned in the rules above it.
      
      While here, fix a wrong allocator usage. The memory for the match string
      comes from pool allocator. We must not free it with the general
      allocator. We can instead simply forget the string and it will be
      cleaned up.
      Carlos Martín Nieto committed
  2. 17 Sep, 2014 1 commit
  3. 06 May, 2014 1 commit
    • Improve checks for ignore containment · f554611a
      The diff code was using an "ignored_prefix" directory to track if
      a parent directory was ignored that contained untracked files
      alongside tracked files. Unfortunately, when negative ignore rules
      were used for directories inside ignored parents, the wrong rules
      were applied to untracked files inside the negatively ignored
      child directories.
      
      This commit moves the logic for ignore containment into the workdir
      iterator (which is a better place for it), so the ignored-ness of
      a directory is contained in the frame stack during traversal.  This
      allows a child directory to override with a negative ignore and yet
      still restore the ignored state of the parent when we traverse out
      of the child.
      
      Along with this, there are some problems with "directory only"
      ignore rules on container directories.  Given "a/*" and "!a/b/c/"
      (where the second rule is a directory rule but the first rule is
      just a generic prefix rule), then the directory only constraint
      was having "a/b/c/d/file" match the first rule and not the second.
      This was fixed by having ignore directory-only rules test a rule
      against the prefix of a file with LEADINGDIR enabled.
      
      Lastly, spot checks for ignores using `git_ignore_path_is_ignored`
      were tested from the top directory down to the bottom to deal with
      the containment problem, but this is wrong. We have to test bottom
      to top so that negative subdirectory rules will be checked before
      parent ignore rules.
      
      This does change the behavior of some existing tests, but it seems
      only to bring us more in line with core Git, so I think those
      changes are acceptable.
      Russell Belfer committed
  4. 21 Apr, 2014 1 commit
  5. 18 Apr, 2014 1 commit
    • Pop ignore only if whole relative path matches · 6a0956e5
      When traversing the directory structure, the iterator pushes and
      pops ignore files using a vector.  Some directories don't have
      ignore files, so it uses a path comparison to decide when it is
      right to actually pop the last ignore file.  This was only
      comparing directory suffixes, though, so a subdirectory with the
      same name as a parent could result in the parent's .gitignore
      being popped off the list ignores too early.  This changes the
      logic to compare the entire relative path of the ignore file.
      Russell Belfer committed
  6. 17 Apr, 2014 6 commits
  7. 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
  8. 10 Apr, 2014 1 commit
    • Fix bug popping ignore files during wd iteration · 8f7bc646
      There were a couple bugs in popping ignore files during iteration
      that could result in incorrect decisions be made and thus ignore
      files below the root either not being loaded correctly or not
      being popped at the right time.
      
      One bug was an off-by-one in comparing the path of the gitignore
      file with the path being exited during iteration.
      
      The second bug was not correctly truncating the path being tracked
      during traversal if there were no ignores on the list (i.e. when
      you have no .gitignore at the root, but do have some in contained
      directories).
      Russell Belfer committed
  9. 11 Dec, 2013 2 commits
    • Remove converting user error to GIT_EUSER · 25e0b157
      This changes the behavior of callbacks so that the callback error
      code is not converted into GIT_EUSER and instead we propagate the
      return value through to the caller.  Instead of using the
      giterr_capture and giterr_restore functions, we now rely on all
      functions to pass back the return value from a callback.
      
      To avoid having a return value with no error message, the user
      can call the public giterr_set_str or some such function to set
      an error message.  There is a new helper 'giterr_set_callback'
      that functions can invoke after making a callback which ensures
      that some error message was set in case the callback did not set
      one.
      
      In places where the sign of the callback return value is
      meaningful (e.g. positive to skip, negative to abort), only the
      negative values are returned back to the caller, obviously, since
      the other values allow for continuing the loop.
      
      The hardest parts of this were in the checkout code where positive
      return values were overloaded as meaningful values for checkout.
      I fixed this by adding an output parameter to many of the internal
      checkout functions and removing the overload.  This added some
      code, but it is probably a better implementation.
      
      There is some funkiness in the network code where user provided
      callbacks could be returning a positive or a negative value and
      we want to rely on that to cancel the loop.  There are still a
      couple places where an user error might get turned into GIT_EUSER
      there, I think, though none exercised by the tests.
      Russell Belfer committed
    • Further EUSER and error propagation fixes · dab89f9b
      This continues auditing all the places where GIT_EUSER is being
      returned and making sure to clear any existing error using the
      new giterr_user_cancel helper.  As a result, places that relied
      on intercepting GIT_EUSER but having the old error preserved also
      needed to be cleaned up to correctly stash and then retrieve the
      actual error.
      
      Additionally, as I encountered places where error codes were not
      being propagated correctly, I tried to fix them up.  A number of
      those fixes are included in the this commit as well.
      Russell Belfer committed
  10. 28 Oct, 2013 1 commit
    • The "common.h" should be included before "config.h". · 157cef10
      When building libgit2 for ia32 architecture on a x64 machine, including
      "config.h" without a "common.h" would result the following error:
      C:\Program Files\Microsoft SDKs\Windows\v7.1\include\winbase.h(2288): error C2373: 'InterlockedIncrement' : redefinition; different type modifiers [C:\cygwin\home\zcbenz\codes\git-utils\build\libgit2.vcxproj]
      C:\Program Files\Microsoft SDKs\Windows\v7.1\include\winbase.h(2295): error C2373: 'InterlockedDecrement' : redefinition; different type modifiers [C:\cygwin\home\zcbenz\codes\git-utils\build\libgit2.vcxproj]
      C:\Program Files\Microsoft SDKs\Windows\v7.1\include\winbase.h(2303): error C2373: 'InterlockedExchange' : redefinition; different type modifiers [C:\cygwin\home\zcbenz\codes\git-utils\build\libgit2.vcxproj]
      C:\Program Files\Microsoft SDKs\Windows\v7.1\include\winbase.h(2314): error C2373: 'InterlockedExchangeAdd' : redefinition; different type modifiers [C:\cygwin\home\zcbenz\codes\git-utils\build\libgit2.vcxproj]
      Cheng Zhao committed
  11. 09 Aug, 2013 3 commits
    • Improve and comment git_ignore__pop_dir · 3bc3ed80
      This just cleans up the improved logic for popping ignore dirs
      and documents why the complex behavior is needed.
      Russell Belfer committed
    • Improve building ignore file lists · ba8b8c04
      The routines to push and pop ignore files while traversing a
      directory had some issues. In particular, setting up the initial
      list would sometimes push an ignore file before it ought to be
      applied if the starting path was a directory containing an ignore
      file. Also, the pop function was not always matching the right
      part of the path and would fail to pop ignores from the list in
      some cases.
      
      This adds some tests that exercise a particular problematic case
      and then fixes the problems that I could find related to this.
      
      At some point, I'd like to isolate this ignore rule management
      code and rewrite it, but that's a larger project and right now,
      I'll opt to just try to fix the broken behaviors.
      Russell Belfer committed
    • Revert PR #1462 and provide alternative fix · 4ba64794
      This rolls back the changes to fnmatch parsing from commit
      2e40a60e except for the tests
      that were added.  Instead this adds couple of new flags that can
      be passed in when attempting to parse an fnmatch pattern.  Also,
      this changes the pathspec match logic to special case matching a
      filename with a '!' prefix against a negative pattern.
      
      This fixes the build.
      Russell Belfer committed
  12. 19 Jun, 2013 1 commit
    • Add fn to check pathspec for ignored files · 85b8b18b
      Command line Git sometimes generates an error message if given a
      pathspec that contains an exact match to an ignored file (provided
      --force isn't also given).  This adds an internal function that
      makes it easy to check it that has happened.  Right now, I'm not
      creating a public API for this because that would get a little
      more complicated with a need for callbacks for all invalid paths.
      Russell Belfer committed
  13. 23 Apr, 2013 1 commit
  14. 15 Apr, 2013 1 commit
  15. 15 Mar, 2013 1 commit
    • Implement global/system file search paths · 5540d947
      The goal of this work is to expose the search logic for "global",
      "system", and "xdg" files through the git_libgit2_opts() interface.
      
      Behind the scenes, I changed the logic for finding files to have a
      notion of a git_strarray that represents a search path and to store
      a separate search path for each of the three tiers of config file.
      For each tier, I implemented a function to initialize it to default
      values (generally based on environment variables), and then general
      interfaces to get it, set it, reset it, and prepend new directories
      to it.
      
      Next, I exposed these interfaces through the git_libgit2_opts
      interface, reusing the GIT_CONFIG_LEVEL_SYSTEM, etc., constants
      for the user to control which search path they were modifying.
      There are alternative designs for the opts interface / argument
      ordering, so I'm putting this phase out for discussion.
      
      Additionally, I ended up doing a little bit of clean up regarding
      attr.h and attr_file.h, adding a new attrcache.h so the other two
      files wouldn't have to be included in so many places.
      Russell Belfer committed
  16. 20 Nov, 2012 1 commit
  17. 15 Oct, 2012 1 commit
    • Fix single-file ignore checks · 52032ae5
      To answer if a single given file should be ignored, the path to
      that file has to be processed progressively checking that there
      are no intermediate ignored directories in getting to the file
      in question.  This enables that, fixing the broken old behavior,
      and adds tests to exercise various ignore situations.
      Russell Belfer committed
  18. 08 Oct, 2012 1 commit
  19. 17 Sep, 2012 1 commit
  20. 24 Aug, 2012 1 commit
  21. 22 Aug, 2012 2 commits
  22. 24 Jul, 2012 1 commit
  23. 11 Jun, 2012 1 commit
  24. 17 May, 2012 2 commits
  25. 04 May, 2012 1 commit
  26. 03 May, 2012 1 commit
    • Support reading attributes from index · f917481e
      Depending on the operation, we need to consider gitattributes
      in both the work dir and the index.  This adds a parameter to
      all of the gitattributes related functions that allows user
      control of attribute reading behavior (i.e. prefer workdir,
      prefer index, only use index).
      
      This fix also covers allowing us to check attributes (and
      hence do diff and status) on bare repositories.
      
      This was a somewhat larger change that I hoped because it had
      to change the cache key used for gitattributes files.
      Russell Belfer committed
  27. 26 Apr, 2012 1 commit
  28. 25 Apr, 2012 1 commit
  29. 30 Mar, 2012 1 commit
  30. 16 Mar, 2012 1 commit