1. 12 May, 2015 4 commits
    • attr: less path mangling during attribute matching · 90997e40
      When handling attr matching, simply compare the directory path where the
      attribute file resides to the path being matched.  Skip over commonality
      to allow us to compare the contents of the attribute file to the remainder
      of the path.
      
      This allows us to more easily compare the pattern directly to the path,
      instead of trying to guess whether we want to compare the path's basename
      or the full path based on whether the match was inside a containing
      directory or not.
      
      This also allows us to do fewer translations on the pattern (trying to
      re-prefix it.)
      Edward Thomson committed
    • attr: don't mangle file path during attr matching · 9465bedb
      When determining whether some file matches an attr pattern, do
      not try to truncate the path to pass to fnmatch.  When there is
      no containing directory for an item (eg, from a .gitignore in the
      root) this will cause us to truncate our path, which means that
      we cannot do meaningful comparisons on it and we may have false
      positives when trying to determine whether a given file is actually
      a file or a folder (as we have lost the path's base information.)
      
      This mangling was to allow fnmatch to compare a directory on disk to
      the name of a directory, but it is unnecessary as our fnmatch accepts
      FNM_LEADING_DIR.
      Edward Thomson committed
    • attr: don't match files for folders · ef6d0722
      When ignoring a path "foo/", ensure that this is actually a directory,
      and not simply a file named "foo".
      Edward Thomson committed
  2. 28 Apr, 2015 1 commit
  3. 23 Apr, 2015 1 commit
  4. 04 Feb, 2015 2 commits
  5. 03 Feb, 2015 1 commit
    • attrcache: don't re-read attrs during checkout · 9f779aac
      During checkout, assume that the .gitattributes files aren't
      modified during the checkout.  Instead, create an "attribute session"
      during checkout.  Assume that attribute data read in the same
      checkout "session" hasn't been modified since the checkout started.
      (But allow subsequent checkouts to invalidate the cache.)
      
      Further, cache nonexistent git_attr_file data even when .gitattributes
      files are not found to prevent re-scanning for nonexistent files.
      Edward Thomson committed
  6. 29 Dec, 2014 1 commit
  7. 21 Nov, 2014 1 commit
    • attr_file: Do not assume ODB data is NULL-terminated · 72d00241
      That's a bad assumption to make, even though right now it holds
      (because of the way we've implemented decompression of packfiles),
      this may change in the future, given that ODB objects can be
      binary data.
      
      Furthermore, the ODB object can return a NULL pointer if the object
      is empty. Copying the NULL pointer to the strbuf lets us handle it
      like an empty string. Again, the NULL pointer is valid behavior because
      you're supposed to check the *size* of the object before working
      on it.
      Vicent Marti committed
  8. 06 Nov, 2014 1 commit
    • ignore: don't leak rules into higher directories · 6069042f
      A rule "src" in src/.gitignore must only match subdirectories of
      src/. The current code does not include this context in the match rule
      and would thus consider this rule to match the top-level src/ directory
      instead of the intended src/src/.
      
      Keep track fo the context in which the rule was defined so we can
      perform a prefix match.
      Carlos Martín Nieto committed
  9. 05 Nov, 2014 1 commit
  10. 08 Aug, 2014 2 commits
  11. 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
  12. 21 Apr, 2014 1 commit
  13. 18 Apr, 2014 3 commits
    • Minor fixes · ac16bd0a
      Only apply LEADING_DIR pattern munging to patterns in ignore and
      attribute files, not to pathspecs used to select files to operate
      on.  Also, allow internal macro definitions to be evaluated before
      loading all external ones (important so that external ones can
      make use of internal `binary` definition).
      Russell Belfer committed
    • Fix ignore difference from git with trailing /* · 916fcbd6
      Ignore patterns that ended with a trailing '/*' were still needing
      to match against another actual '/' character in the full path.
      This is not the same behavior as core Git.
      
      Instead, we strip a trailing '/*' off of any patterns that were
      matching and just take it to imply the FNM_LEADING_DIR behavior.
      Russell Belfer committed
    • Preload attribute files that may contain macros · e3a2a04c
      There was a latent bug where files that use macro definitions
      could be parsed before the macro definitions were loaded.  Because
      of attribute file caching, preloading files that are going to be
      used doesn't add a significant amount of overhead, so let's always
      preload any files that could contain macros before we assemble the
      actual vector of files to scan for attributes.
      Russell Belfer committed
  14. 17 Apr, 2014 5 commits
  15. 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
  16. 19 Sep, 2013 1 commit
  17. 09 Aug, 2013 1 commit
    • 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
  18. 20 Jun, 2013 1 commit
    • Add status flags to force output sort order · 22b6b82f
      Files in status will, be default, be sorted according to the case
      insensitivity of the filesystem that we're running on.  However,
      in some cases, this is not desirable.  Even on case insensitive
      file systems, 'git status' at the command line will generally use
      a case sensitive sort (like 'ls').  Some GUIs prefer to display a
      list of file case insensitively even on case-sensitive platforms.
      
      This adds two new flags: GIT_STATUS_OPT_SORT_CASE_SENSITIVELY
      and GIT_STATUS_OPT_SORT_CASE_INSENSITIVELY that will override the
      default sort order of the status output and give the user control.
      This includes tests for exercising these new options and makes
      the examples/status.c program emulate core Git and always use a
      case sensitive sort.
      Russell Belfer committed
  19. 29 May, 2013 1 commit
  20. 15 Apr, 2013 1 commit
  21. 11 Apr, 2013 1 commit
  22. 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
  23. 27 Jan, 2013 1 commit
  24. 17 Sep, 2012 2 commits
  25. 22 Aug, 2012 1 commit
    • Add template dir and set gid to repo init · ca1b6e54
      This extends git_repository_init_ext further with support for
      initializing the repository from an external template directory
      and with support for the "create shared" type flags that make a
      set GID repository directory.
      
      This also adds tests for much of the new functionality to the
      existing `repo/init.c` test suite.
      
      Also, this adds a bunch of new utility functions including a
      very general purpose `git_futils_mkdir` (with the ability to
      make paths and to chmod the paths post-creation) and a file
      tree copying function `git_futils_cp_r`.  Also, this includes
      some new path functions that were useful to keep the code
      simple.
      Russell Belfer committed
  26. 01 Aug, 2012 1 commit
    • attr: Do not export variables externally · 0c9eacf3
      Fixes #824
      
      Exporting variables in a dynamic library is a PITA. Let's keep
      these values internally and wrap them through a helper method.
      
      This doesn't break the external API. @arrbee, aren't you glad I turned
      the `GIT_ATTR_` macros into function macros? :sparkles:
      Vicent Marti committed
  27. 24 Jul, 2012 2 commits