1. 03 Jul, 2017 1 commit
    • Make sure to always include "common.h" first · 0c7f49dd
      Next to including several files, our "common.h" header also declares
      various macros which are then used throughout the project. As such, we
      have to make sure to always include this file first in all
      implementation files. Otherwise, we might encounter problems or even
      silent behavioural differences due to macros or defines not being
      defined as they should be. So in fact, our header and implementation
      files should make sure to always include "common.h" first.
      
      This commit does so by establishing a common include pattern. Header
      files inside of "src" will now always include "common.h" as its first
      other file, separated by a newline from all the other includes to make
      it stand out as special. There are two cases for the implementation
      files. If they do have a matching header file, they will always include
      this one first, leading to "common.h" being transitively included as
      first file. If they do not have a matching header file, they instead
      include "common.h" as first file themselves.
      
      This fixes the outlined problems and will become our standard practice
      for header and source files inside of the "src/" from now on.
      Patrick Steinhardt committed
  2. 13 Feb, 2017 1 commit
    • repository: use `git_repository_item_path` · c5f3da96
      The recent introduction of the commondir variable of a repository
      requires callers to distinguish whether their files are part of
      the dot-git directory or the common directory shared between
      multpile worktrees. In order to take the burden from callers and
      unify knowledge on which files reside where, the
      `git_repository_item_path` function has been introduced which
      encapsulate this knowledge.
      
      Modify most existing callers of `git_repository_path` to use
      `git_repository_item_path` instead, thus making them implicitly
      aware of the common directory.
      Patrick Steinhardt committed
  3. 28 Apr, 2015 1 commit
  4. 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
  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. 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
  7. 09 Aug, 2013 1 commit
    • 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
  8. 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
  9. 23 Apr, 2013 1 commit
  10. 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
  11. 08 Jan, 2013 1 commit
  12. 17 Sep, 2012 1 commit
  13. 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
  14. 21 Feb, 2012 1 commit
    • Uniform iterators for trees, index, and workdir · b6c93aef
      This create a new git_iterator type of object that provides a
      uniform interface for iterating over the index, an arbitrary
      tree, or the working directory of a repository.
      
      As part of this, git ignore support was extended to support
      push and pop of directory-based ignore files as the working
      directory is being traversed (so the array of ignores does
      not have to be recreated at each directory during traveral).
      
      There are a number of other small utility functions in buffer,
      path, vector, and fileops that are included in this patch
      that made the iterator implementation cleaner.
      Russell Belfer committed
  15. 13 Feb, 2012 1 commit
  16. 31 Jan, 2012 1 commit
    • Fix attr path is_dir check · adc9bdb3
      When building an attr path object, the code that checks if the
      file is a directory was evaluating the file as a relative path
      to the current working directory, instead of using the repo root.
      This lead to inconsistent behavior.
      Russell Belfer committed
  17. 16 Jan, 2012 1 commit
    • Patch cleanup for merge · cfbc880d
      After reviewing the gitignore support with Vicent, we came up
      with a list of minor cleanups to prepare for merge, including:
      
      * checking git_repository_config error returns
      * renaming git_ignore_is_ignored and moving to status.h
      * fixing next_line skipping to include \r skips
      * commenting on where ignores are and are not included
      Russell Belfer committed
  18. 12 Jan, 2012 1 commit
  19. 11 Jan, 2012 1 commit
    • Initial implementation of gitignore support · df743c7d
      Adds support for .gitignore files to git_status_foreach() and
      git_status_file().  This includes refactoring the gitattributes
      code to share logic where possible.  The GIT_STATUS_IGNORED flag
      will now be passed in for files that are ignored (provided they
      are not already in the index or the head of repo).
      Russell Belfer committed