Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Commits on Jun 28, 2012
  1. @gitster

    Merge branch 'nd/exclude-workaround-top-heavy'

    gitster authored
    Attempt to optimize matching with an exclude pattern with a deep
    directory hierarchy by taking the part that specifies leading path
    without wildcard literally.
Commits on Jun 21, 2012
  1. @gitster

    Merge branch 'jc/ls-files-i-dir'

    gitster authored
    "git ls-files --exclude=t -i" did not consider anything under t/
    as excluded, as it did not pay attention to exclusion of leading
    paths while walking the index.  Other two users of excluded() are
    also updated.
    * jc/ls-files-i-dir:
      dir.c: make excluded() file scope static
      unpack-trees.c: use path_excluded() in check_ok_to_remove()
      builtin/add.c: use path_excluded()
      path_excluded(): update API to less cache-entry centric
      ls-files -i: micro-optimize path_excluded()
      ls-files -i: pay attention to exclusion of leading paths
Commits on Jun 7, 2012
  1. @pclouds @gitster

    exclude: do strcmp as much as possible before fnmatch

    pclouds authored gitster committed
    this also avoids calling fnmatch() if the non-wildcard prefix is
    longer than basename
    Signed-off-by: Nguyễn Thái Ngọc Duy <>
    Signed-off-by: Junio C Hamano <>
Commits on Jun 6, 2012
  1. @gitster

    dir.c: make excluded() file scope static

    gitster authored
    Now there no longer is external callers of this interface, so we can
    make it static.
    Signed-off-by: Junio C Hamano <>
  2. @gitster

    path_excluded(): update API to less cache-entry centric

    gitster authored
    It was stupid of me to make the API too much cache-entry specific;
    the caller may want to check arbitrary pathname without having a
    corresponding cache-entry to see if a path is ignored.
    Signed-off-by: Junio C Hamano <>
Commits on Jun 3, 2012
  1. @gitster

    ls-files -i: pay attention to exclusion of leading paths

    gitster authored
    "git ls-files --exclude=t/ -i" does not show paths in directory t/
    that have been added to the index, but it should.
    The excluded() API was designed for callers who walk the tree from
    the top, checking each level of the directory hierarchy as it
    descends if it is excluded, and not even bothering to recurse into
    an excluded directory.  This would allow us optimize for a common
    case by not having to check if the exclude pattern "foo/" matches
    when looking at "foo/bar", because the caller should have noticed
    that "foo" is excluded and did not even bother to read "foo/bar"
    out of opendir()/readdir() to call it.
    The code for "ls-files -i" however walks the index linearly, feeding
    paths without checking if the leading directory is already excluded.
    Introduce a helper function path_excluded() to let this caller
    properly call excluded() check for higher hierarchies as necessary.
    Signed-off-by: Junio C Hamano <>
Commits on Mar 15, 2012
  1. @gitster

    remove_dir_recursively(): Add flag for skipping removal of toplevel dir

    gitster authored
    Add the REMOVE_DIR_KEEP_TOPLEVEL flag to remove_dir_recursively() for
    deleting everything inside the given directory, but _not_ the given
    directory itself.
    Note that this does not pass the REMOVE_DIR_KEEP_NESTED_GIT flag, if set,
    to the recursive invocations of remove_dir_recursively().  It is likely to
    be a a bug that has been present since REMOVE_DIR_KEEP_NESTED_GIT was
    introduced (a0f4afb), but this commit keeps the same behaviour for now.
    Signed-off-by: Johan Herland <>
    Signed-off-by: Junio C Hamano <>
Commits on Sep 12, 2011
  1. @drizzd @gitster

    rename pathspec_prefix() to common_prefix() and move to dir.[ch]

    drizzd authored gitster committed
    Also make common_prefix_len() static as this refactoring makes dir.c
    itself the only caller of this helper function.
    Signed-off-by: Clemens Buchacher <>
    Signed-off-by: Junio C Hamano <>
Commits on Sep 6, 2011
  1. @gitster

    consolidate pathspec_prefix and common_prefix

    gitster authored
    The implementation from pathspec_prefix (slightly modified) replaces the
    current common_prefix, because it also respects glob characters.
    Based on a patch by Clemens Buchacher.
    Signed-off-by: Junio C Hamano <>
Commits on May 2, 2011
  1. @gitster

    Merge branch 'nd/maint-setup'

    gitster authored
    * nd/maint-setup:
      Kill off get_relative_cwd()
      setup: return correct prefix if worktree is '/'
Commits on Mar 29, 2011
  1. @pclouds @gitster

    Kill off get_relative_cwd()

    pclouds authored gitster committed
    Function dir_inside_of() does something similar (correctly), but looks
    easier to understand and does not bundle cwd to its business. Given
    get_relative_cwd's only user is is_inside_dir, we can kill it for
    Signed-off-by: Nguyễn Thái Ngọc Duy <>
    Signed-off-by: Junio C Hamano <>
  2. @pclouds @gitster

    setup: return correct prefix if worktree is '/'

    pclouds authored gitster committed
    The same old problem reappears after setup code is reworked.  We tend
    to assume there is at least one path component in a path and forget
    that path can be simply '/'.
    Reported-by: Matthijs Kooijman <>
    Signed-off-by: Nguyễn Thái Ngọc Duy <>
    Signed-off-by: Junio C Hamano <>
Commits on Feb 3, 2011
  1. @pclouds @gitster

    pathspec: add match_pathspec_depth()

    pclouds authored gitster committed
    match_pathspec_depth() is a clone of match_pathspec() except that it
    can take depth limit. Computation is a bit lighter compared to
    match_pathspec() because it's usually precomputed and stored in struct
    In long term, match_pathspec() and match_one() should be removed in
    favor of this function.
    Signed-off-by: Nguyễn Thái Ngọc Duy <>
    Signed-off-by: Junio C Hamano <>
  2. @pclouds @gitster

    tree_entry_interesting(): support depth limit

    pclouds authored gitster committed
    This is needed to replace pathspec_matches() in builtin/grep.c.
    max_depth == -1 means infinite depth. Depth limit is only effective
    when pathspec.recursive == 1. When pathspec.recursive == 0, the
    behavior depends on match functions: non-recursive for
    tree_entry_interesting() and recursive for match_pathspec{,_depth}
    Signed-off-by: Nguyễn Thái Ngọc Duy <>
    Signed-off-by: Junio C Hamano <>
Commits on Dec 22, 2010
  1. @gitster

    Merge branch 'nd/maint-fix-add-typo-detection'

    gitster authored
    * nd/maint-fix-add-typo-detection:
      Revert "excluded_1(): support exclude files in index"
      unpack-trees: fix sparse checkout's "unable to match directories"
      unpack-trees: move all skip-worktree checks back to unpack_trees()
      dir.c: add free_excludes()
      cache.h: realign and use (1 << x) form for CE_* constants
Commits on Nov 29, 2010
  1. @pclouds @gitster

    dir.c: add free_excludes()

    pclouds authored gitster committed
    Signed-off-by: Nguyễn Thái Ngọc Duy <>
    Signed-off-by: Junio C Hamano <>
Commits on Oct 6, 2010
  1. @jjensen @gitster

    Add string comparison functions that respect the ignore_case variable.

    jjensen authored gitster committed
    Multiple locations within this patch series alter a case sensitive
    string comparison call such as strcmp() to be a call to a string
    comparison call that selects case comparison based on the global
    ignore_case variable. Behaviorally, when core.ignorecase=false, the
    *_icase() versions are functionally equivalent to their C runtime
    counterparts.  When core.ignorecase=true, the *_icase() versions perform
    a case insensitive comparison.
    Like Linus' earlier ignorecase patch, these may ignore filename
    conventions on certain file systems. By isolating filename comparisons
    to certain functions, support for those filename conventions may be more
    easily met.
    Signed-off-by: Joshua Jensen <>
    Signed-off-by: Johannes Sixt <>
    Signed-off-by: Junio C Hamano <>
Commits on Jul 12, 2010
  1. @jlehmann @gitster

    git add: Add the "--ignore-missing" option for the dry run

    jlehmann authored gitster committed
    Sometimes it is useful to know if a file or directory will be ignored
    before it is added to the work tree. An example is "git submodule add",
    where it would be really nice to be able to fail with an appropriate
    error message before the submodule is cloned and checked out.
    Signed-off-by: Jens Lehmann <>
    Signed-off-by: Junio C Hamano <>
Commits on Jan 13, 2010
  1. @gitster

    Merge branch 'nd/sparse'

    gitster authored
    * nd/sparse: (25 commits)
      t7002: test for not using external grep on skip-worktree paths
      t7002: set test prerequisite "external-grep" if supported
      grep: do not do external grep on skip-worktree entries
      commit: correctly respect skip-worktree bit
      ie_match_stat(): do not ignore skip-worktree bit with CE_MATCH_IGNORE_VALID
      tests: rename duplicate t1009
      sparse checkout: inhibit empty worktree
      Add tests for sparse checkout
      read-tree: add --no-sparse-checkout to disable sparse checkout support
      unpack-trees(): ignore worktree check outside checkout area
      unpack_trees(): apply $GIT_DIR/info/sparse-checkout to the final index
      unpack-trees(): "enable" sparse checkout and load $GIT_DIR/info/sparse-checkout
      unpack-trees.c: generalize verify_* functions
      unpack-trees(): add CE_WT_REMOVE to remove on worktree alone
      Introduce "sparse checkout"
      dir.c: export excluded_1() and add_excludes_from_file_1()
      excluded_1(): support exclude files in index
      unpack-trees(): carry skip-worktree bit over in merged_entry()
      Read .gitignore from index if it is skip-worktree
      Avoid writing to buffer in add_excludes_from_file_1()
Commits on Aug 24, 2009
  1. @pclouds @gitster

    dir.c: export excluded_1() and add_excludes_from_file_1()

    pclouds authored gitster committed
    These functions are used to handle .gitignore. They are now exported
    so that sparse checkout can reuse.
    Signed-off-by: Nguyễn Thái Ngọc Duy <>
    Signed-off-by: Junio C Hamano <>
Commits on Jul 29, 2009
  1. @gitster

    clean: require double -f options to nuke nested git repository and wo…

    gitster authored
    …rk tree
    When you have an embedded git work tree in your work tree (be it
    an orphaned submodule, or an independent checkout of an unrelated
    project), "git clean -d -f" blindly descended into it and removed
    everything.  This is rarely what the user wants.
    Signed-off-by: Junio C Hamano <>
Commits on Jul 9, 2009
  1. @torvalds @gitster

    Simplify read_directory[_recursive]() arguments

    torvalds authored gitster committed
    Stop the insanity with separate 'path' and 'base' arguments that must
    match.  We don't need that crazy interface any more, since we cleaned up
    handling of 'path' in commit da4b3e8.
    Signed-off-by: Linus Torvalds <>
    Signed-off-by: Junio C Hamano <>
  2. @torvalds @gitster

    Add 'fill_directory()' helper function for directory traversal

    torvalds authored gitster committed
    Most of the users of "read_directory()" actually want a much simpler
    interface than the whole complex (but rather powerful) one.
    In fact 'git add' had already largely abstracted out the core interface
    issues into a private "fill_directory()" function that was largely
    applicable almost as-is to a number of callers.  Yes, 'git add' wants to
    do some extra work of its own, specific to the add semantics, but we can
    easily split that out, and use the core as a generic function.
    This function does exactly that, and now that much simplified
    'fill_directory()' function can be shared with a number of callers,
    while also ensuring that the rather more complex calling conventions of
    read_directory() are used by fewer call-sites.
    This also makes the 'common_prefix()' helper function private to dir.c,
    since all callers are now in that file.
    Signed-off-by: Linus Torvalds <>
    Signed-off-by: Junio C Hamano <>
Commits on Feb 18, 2009
  1. @dscho @gitster

    Turn the flags in struct dir_struct into a single variable

    dscho authored gitster committed
    By having flags represented as bits in the new member variable 'flags',
    it will be easier to use parse_options when dir_struct is involved.
    Signed-off-by: Johannes Schindelin <>
    Signed-off-by: Junio C Hamano <>
Commits on Jan 11, 2009
  1. @aspotashev @gitster

    Allow cloning to an existing empty directory

    aspotashev authored gitster committed
    The die() message updated accordingly.
    The previous behaviour was to only allow cloning when the destination
    directory doesn't exist.
    [jc: added trivial tests]
    Signed-off-by: Alexander Potashev <>
    Signed-off-by: Junio C Hamano <>
  2. @aspotashev @gitster

    add is_dot_or_dotdot inline function

    aspotashev authored gitster committed
    A new inline function is_dot_or_dotdot is used to check if the
    directory name is either "." or "..". It returns a non-zero value if
    the given string is "." or "..". It's applicable to a lot of Git
    source code.
    Signed-off-by: Alexander Potashev <>
    Signed-off-by: Junio C Hamano <>
Commits on Oct 3, 2008
  1. @spearce

    dir.c: make dir_add_name() and dir_add_ignored() static

    Nanako Shiraishi authored spearce committed
    These functions are not used by any other file.
    Signed-off-by: Nanako Shiraishi <>
    Signed-off-by: Shawn O. Pearce <>
Commits on Sep 29, 2008
  1. @raalkml @spearce

    Add remove_path: a function to remove as much as possible of a path

    raalkml authored spearce committed
    The function has two potential users which both managed to get wrong
    their implementations (the one in builtin-rm.c one has a memleak, and
    builtin-merge-recursive.c scribles over its const argument).
    Signed-off-by: Alex Riesen <>
    Signed-off-by: Shawn O. Pearce <>
Commits on Feb 5, 2008
  1. @gitster

    gitignore: lazily find dtype

    gitster authored
    When we process "foo/" entries in gitignore files on a system
    that does not have d_type member in "struct dirent", the earlier
    implementation ran lstat(2) separately when matching with
    entries that came from the command line, in-tree .gitignore
    files, and $GIT_DIR/info/excludes file.
    This optimizes it by delaying the lstat(2) call until it becomes
    absolutely necessary.
    The initial idea for this change was by Jeff King, but I
    optimized it further to pass pointers to around.
    Signed-off-by: Junio C Hamano <>
  2. @gitster

    gitignore(5): Allow "foo/" in ignore list to match directory "foo"

    gitster authored
    A pattern "foo/" in the exclude list did not match directory
    "foo", but a pattern "foo" did.  This attempts to extend the
    exclude mechanism so that it would while not matching a regular
    file or a symbolic link "foo".  In order to differentiate a
    directory and non directory, this passes down the type of path
    being checked to excluded() function.
    A downside is that the recursive directory walk may need to run
    lstat(2) more often on systems whose "struct dirent" do not give
    the type of the entry; earlier it did not have to do so for an
    excluded path, but we now need to figure out if a path is a
    directory before deciding to exclude it.  This is especially bad
    because an idea similar to the earlier CE_UPTODATE optimization
    to reduce number of lstat(2) calls would by definition not apply
    to the codepaths involved, as (1) directories will not be
    registered in the index, and (2) excluded paths will not be in
    the index anyway.
    Signed-off-by: Junio C Hamano <>
Commits on Nov 29, 2007
  1. @gitster

    per-directory-exclude: lazily read .gitignore files

    gitster authored
    Operations that walk directories or trees, which potentially need to
    consult the .gitignore files, used to always try to open the .gitignore
    file every time they entered a new directory, even when they ended up
    not needing to call excluded() function to see if a path in the
    directory is ignored.  This was done by push/pop exclude_per_directory()
    functions that managed the data in a stack.
    This changes the directory walking API to remove the need to call these
    two functions.  Instead, the directory walk data structure caches the
    data used by excluded() function the last time, and lazily reuses it as
    much as possible.  Among the data the last check used, the ones from
    deeper directories that the path we are checking is outside are
    discarded, data from the common leading directories are reused, and then
    the directories between the common directory and the directory the path
    being checked is in are checked for .gitignore file.  This is very
    similar to the way gitattributes are handled.
    This API change also fixes "ls-files -c -i", which called excluded()
    without setting up the gitignore data via the old push/pop functions.
    Signed-off-by: Junio C Hamano <>
Commits on Nov 14, 2007
  1. @gitster

    core.excludesfile clean-up

    gitster authored
    There are inconsistencies in the way commands currently handle
    the core.excludesfile configuration variable.  The problem is
    the variable is too new to be noticed by anything other than
    git-add and git-status.
     * git-ls-files does not notice any of the "ignore" files by
       default, as it predates the standardized set of ignore files.
       The calling scripts established the convention to use
       .git/info/exclude, .gitignore, and later core.excludesfile.
     * git-add and git-status know about it because they call
       add_excludes_from_file() directly with their own notion of
       which standard set of ignore files to use.  This is just a
       stupid duplication of code that need to be updated every time
       the definition of the standard set of ignore files is
     * git-read-tree takes --exclude-per-directory=<gitignore>,
       not because the flexibility was needed.  Again, this was
       because the option predates the standardization of the ignore
     * git-merge-recursive uses hardcoded per-directory .gitignore
       and nothing else.  git-clean (scripted version) does not
       honor core.* because its call to underlying ls-files does not
       know about it.  git-clean in C (parked in 'pu') doesn't either.
    We probably could change git-ls-files to use the standard set
    when no excludes are specified on the command line and ignore
    processing was asked, or something like that, but that will be a
    change in semantics and might break people's scripts in a subtle
    way.  I am somewhat reluctant to make such a change.
    On the other hand, I think it makes perfect sense to fix
    git-read-tree, git-merge-recursive and git-clean to follow the
    same rule as other commands.  I do not think of a valid use case
    to give an exclude-per-directory that is nonstandard to
    read-tree command, outside a "negative" test in the t1004 test
    This patch is the first step to untangle this mess.
    The next step would be to teach read-tree, merge-recursive and
    clean (in C) to use setup_standard_excludes().
    Signed-off-by: Junio C Hamano <>
Commits on Oct 30, 2007
  1. @gitster

    Speedup scanning for excluded files.

    Lars Knoll authored gitster committed
    Try to avoid a lot of work scanning for excluded files,
    by caching some more information when setting up the exclusion
    data structure.
    Speeds up 'git runstatus' on a repository containing the Qt sources by 30% and
    reduces the amount of instructions executed (as measured by valgrind) by a
    factor of 2.
    Signed-off-by: Junio C Hamano <>
Commits on Sep 30, 2007
  1. @dscho @gitster

    Introduce remove_dir_recursively()

    dscho authored gitster committed
    There was a function called remove_empty_dir_recursive() buried
    in refs.c.  Expose a slightly enhanced version in dir.h: it can now
    optionally remove a non-empty directory.
    Signed-off-by: Johannes Schindelin <>
    Signed-off-by: Junio C Hamano <>
Commits on Aug 1, 2007
  1. @dscho @gitster

    Add functions get_relative_cwd() and is_inside_dir()

    dscho authored gitster committed
    The function get_relative_cwd() works just as getcwd(), only that it
    takes an absolute path as additional parameter, returning the prefix
    of the current working directory relative to the given path.  If the
    cwd is no subdirectory of the given path, it returns NULL.
    is_inside_dir() is just a trivial wrapper over get_relative_cwd().
    Signed-off-by: Johannes Schindelin <>
    Signed-off-by: Junio C Hamano <>
Something went wrong with that request. Please try again.