1. 24 8月, 2009 1 次提交
  2. 09 7月, 2009 1 次提交
    • L
      Add 'fill_directory()' helper function for directory traversal · 1d8842d9
      Linus Torvalds 提交于
      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: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      1d8842d9
  3. 25 5月, 2009 1 次提交
  4. 09 5月, 2009 1 次提交
    • J
      parseopt: add OPT_NEGBIT · e9008b9a
      Jeff King 提交于
      On Thu, May 07, 2009 at 09:44:17PM +0200, René Scharfe wrote:
      Subject: [PATCH] ls-files: make --no-empty-directory properly negatable
      
      This option was specified to parseopt as an OPT_BIT; however, we
      actually want to _set_ the bit on --no-empty-directory. Thus the
      existing implementation used --no-empty-directory, and required
      --no-no-empty-directory to negate it.
      
      Now that OPT_NEGBIT exists, we can properly support it as
      --empty-directory and --no-empty-directory (but of course
      still defaulting to showing empty directories).
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      e9008b9a
  5. 23 4月, 2009 1 次提交
  6. 22 3月, 2009 1 次提交
  7. 18 3月, 2009 1 次提交
  8. 08 3月, 2009 1 次提交
  9. 19 2月, 2009 2 次提交
  10. 08 2月, 2009 1 次提交
  11. 15 1月, 2009 1 次提交
  12. 16 11月, 2008 2 次提交
  13. 18 10月, 2008 1 次提交
    • J
      refactor handling of "other" files in ls-files and status · 98fa4738
      Jeff King 提交于
      When the "git status" display code was originally converted
      to C, we copied the code from ls-files to discover whether a
      pathname returned by read_directory was an "other", or
      untracked, file.
      
      Much later, 5698454e updated the code in ls-files to handle
      some new cases caused by gitlinks.  This left the code in
      wt-status.c broken: it would display submodule directories
      as untracked directories. Nobody noticed until now, however,
      because unless status.showUntrackedFiles was set to "all",
      submodule directories were not actually reported by
      read_directory. So the bug was only triggered in the
      presence of a submodule _and_ this config option.
      
      This patch pulls the ls-files code into a new function,
      cache_name_is_other, and uses it in both places. This should
      leave the ls-files functionality the same and fix the bug
      in status.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      98fa4738
  14. 01 9月, 2008 1 次提交
  15. 14 7月, 2008 1 次提交
    • S
      Make usage strings dash-less · 1b1dd23f
      Stephan Beyer 提交于
      When you misuse a git command, you are shown the usage string.
      But this is currently shown in the dashed form.  So if you just
      copy what you see, it will not work, when the dashed form
      is no longer supported.
      
      This patch makes git commands show the dash-less version.
      
      For shell scripts that do not specify OPTIONS_SPEC, git-sh-setup.sh
      generates a dash-less usage string now.
      Signed-off-by: NStephan Beyer <s-beyer@gmx.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      1b1dd23f
  16. 15 5月, 2008 1 次提交
  17. 07 3月, 2008 1 次提交
  18. 05 2月, 2008 3 次提交
    • J
      gitignore: lazily find dtype · 6831a88a
      Junio C Hamano 提交于
      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: NJunio C Hamano <gitster@pobox.com>
      6831a88a
    • J
      gitignore(5): Allow "foo/" in ignore list to match directory "foo" · d6b8fc30
      Junio C Hamano 提交于
      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: NJunio C Hamano <gitster@pobox.com>
      d6b8fc30
    • J
      setup: sanitize absolute and funny paths in get_pathspec() · d089ebaa
      Junio C Hamano 提交于
      The prefix_path() function called from get_pathspec() is
      responsible for translating list of user-supplied pathspecs to
      list of pathspecs that is relative to the root of the work
      tree.  When working inside a subdirectory, the user-supplied
      pathspecs are taken to be relative to the current subdirectory.
      
      Among special path components in pathspecs, we used to accept
      and interpret only "." ("the directory", meaning a no-op) and
      ".."  ("up one level") at the beginning.  Everything else was
      passed through as-is.
      
      For example, if you are in Documentation/ directory of the
      project, you can name Documentation/howto/maintain-git.txt as:
      
          howto/maintain-git.txt
          ../Documentation/howto/maitain-git.txt
          ../././Documentation/howto/maitain-git.txt
      
      but not as:
      
          howto/./maintain-git.txt
          $(pwd)/howto/maintain-git.txt
      
      This patch updates prefix_path() in several ways:
      
       - If the pathspec is not absolute, prefix (i.e. the current
         subdirectory relative to the root of the work tree, with
         terminating slash, if not empty) and the pathspec is
         concatenated first and used in the next step.  Otherwise,
         that absolute pathspec is used in the next step.
      
       - Then special path components "." (no-op) and ".." (up one
         level) are interpreted to simplify the path.  It is an error
         to have too many ".." to cause the intermediate result to
         step outside of the input to this step.
      
       - If the original pathspec was not absolute, the result from
         the previous step is the resulting "sanitized" pathspec.
         Otherwise, the result from the previous step is still
         absolute, and it is an error if it does not begin with the
         directory that corresponds to the root of the work tree.  The
         directory is stripped away from the result and is returned.
      
       - In any case, the resulting pathspec in the array
         get_pathspec() returns omit the ones that caused errors.
      
      With this patch, the last two examples also behave as expected.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      d089ebaa
  19. 22 1月, 2008 1 次提交
    • L
      Make on-disk index representation separate from in-core one · 7a51ed66
      Linus Torvalds 提交于
      This converts the index explicitly on read and write to its on-disk
      format, allowing the in-core format to contain more flags, and be
      simpler.
      
      In particular, the in-core format is now host-endian (as opposed to the
      on-disk one that is network endian in order to be able to be shared
      across machines) and as a result we can dispense with all the
      htonl/ntohl on accesses to the cache_entry fields.
      
      This will make it easier to make use of various temporary flags that do
      not exist in the on-disk format.
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      7a51ed66
  20. 23 11月, 2007 1 次提交
    • J
      Export three helper functions from ls-files · ee425e46
      Junio C Hamano 提交于
      This exports three helper functions from ls-files.
      
       * pathspec_match() checks if a given path matches a set of pathspecs
         and optionally records which pathspec was used.  This function used
         to be called "match()" but renamed to be a bit less vague.
      
       * report_path_error() takes a set of pathspecs and the record
         pathspec_match() above leaves, and gives error message.  This
         was split out of the main function of ls-files.
      
       * overlay_tree_on_cache() takes a tree-ish (typically "HEAD")
         and overlays it on the current in-core index.  By iterating
         over the resulting index, the caller can find out the paths
         in either the index or the HEAD.  This function used to be
         called "overlay_tree()" but renamed to be a bit more
         descriptive.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ee425e46
  21. 16 11月, 2007 1 次提交
  22. 06 11月, 2007 1 次提交
  23. 03 10月, 2007 1 次提交
    • K
      Must not modify the_index.cache as it may be passed to realloc at some point. · 95af39fc
      Keith Packard 提交于
      The index cache is not static, growing as new entries are added. If
      entries are added after prune_cache is called, cache will no longer
      point at the base of the allocation, and realloc will not be happy.
      
      I verified that this was the only place in the current source which
      modified any index_state.cache elements aside from the alloc/realloc
      calls in read-cache by changing the type of the element to 'struct
      cache_entry ** const cache' and recompiling.
      
      A more efficient patch would create a separate 'cache_base' value to
      track the allocation and then fix things up when reallocation was
      necessary, instead of the brute-force memmove used here.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      95af39fc
  24. 21 9月, 2007 1 次提交
    • P
      Full rework of quote_c_style and write_name_quoted. · 663af342
      Pierre Habouzit 提交于
      * quote_c_style works on a strbuf instead of a wild buffer.
      * quote_c_style is now clever enough to not add double quotes if not needed.
      
      * write_name_quoted inherits those advantages, but also take a different
        set of arguments. Now instead of asking for quotes or not, you pass a
        "terminator". If it's \0 then we assume you don't want to escape, else C
        escaping is performed. In any case, the terminator is also appended to the
        stream. It also no longer takes the prefix/prefix_len arguments, as it's
        seldomly used, and makes some optimizations harder.
      
      * write_name_quotedpfx is created to work like write_name_quoted and take
        the prefix/prefix_len arguments.
      
      Thanks to those API changes, diff.c has somehow lost weight, thanks to the
      removal of functions that were wrappers around the old write_name_quoted
      trying to give it a semantics like the new one, but performing a lot of
      allocations for this goal. Now we always write directly to the stream, no
      intermediate allocation is performed.
      
      As a side effect of the refactor in builtin-apply.c, the length of the bar
      graphs in diffstats are not affected anymore by the fact that the path was
      clipped.
      Signed-off-by: NPierre Habouzit <madcoder@debian.org>
      663af342
  25. 19 9月, 2007 1 次提交
  26. 18 9月, 2007 1 次提交
    • J
      git-commit: Allow partial commit of file removal. · 64586e75
      Junio C Hamano 提交于
      When making a partial commit, git-commit uses git-ls-files with
      the --error-unmatch option to expand and sanity check the user
      supplied path patterns.  When any path pattern does not match
      with the paths known to the index, it errors out, in order to
      catch a common mistake to say "git commit Makefiel cache.h"
      and end up with a commit that touches only cache.h (notice the
      misspelled "Makefile").  This detection however does not work
      well when the path has already been removed from the index.
      
      If you drop a path from the index and try to commit that
      partially, i.e.
      
      	$ git rm COPYING
      	$ git commit -m 'Remove COPYING' COPYING
      
      the command complains because git does not know anything about
      COPYING anymore.
      
      This introduces a new option --with-tree to git-ls-files and
      uses it in git-commit when we build a temporary index to
      write a tree object for the partial commit.
      
      When --with-tree=<tree-ish> option is specified, names from the
      given tree are added to the set of names the index knows about,
      so we can treat COPYING file in the example as known.
      
      Of course, there is no reason to use "git rm" and git-aware
      people have long time done:
      
      	$ rm COPYING
      	$ git commit -m 'Remove COPYING' COPYING
      
      which works just fine.  But this caused a constant confusion.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      64586e75
  27. 13 9月, 2007 1 次提交
    • J
      git-commit: Allow partial commit of file removal. · 80bffaf7
      Junio C Hamano 提交于
      When making a partial commit, git-commit uses git-ls-files with
      the --error-unmatch option to expand and sanity check the user
      supplied path patterns.  When any path pattern does not match
      with the paths known to the index, it errors out, in order to
      catch a common mistake to say "git commit Makefiel cache.h"
      and end up with a commit that touches only cache.h (notice the
      misspelled "Makefile").  This detection however does not work
      well when the path has already been removed from the index.
      
      If you drop a path from the index and try to commit that
      partially, i.e.
      
      	$ git rm COPYING
      	$ git commit -m 'Remove COPYING' COPYING
      
      the command complains because git does not know anything about
      COPYING anymore.
      
      This introduces a new option --with-tree to git-ls-files and
      uses it in git-commit when we build a temporary index to
      write a tree object for the partial commit.
      
      When --with-tree=<tree-ish> option is specified, names from the
      given tree are added to the set of names the index knows about,
      so we can treat COPYING file in the example as known.
      
      Of course, there is no reason to use "git rm" and git-aware
      people have long time done:
      
      	$ rm COPYING
      	$ git commit -m 'Remove COPYING' COPYING
      
      which works just fine.  But this caused a constant confusion.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      80bffaf7
  28. 30 8月, 2007 1 次提交
  29. 01 8月, 2007 1 次提交
    • J
      Clean up work-tree handling · e90fdc39
      Johannes Schindelin 提交于
      The old version of work-tree support was an unholy mess, barely readable,
      and not to the point.
      
      For example, why do you have to provide a worktree, when it is not used?
      As in "git status".  Now it works.
      
      Another riddle was: if you can have work trees inside the git dir, why
      are some programs complaining that they need a work tree?
      
      IOW it is allowed to call
      
      	$ git --git-dir=../ --work-tree=. bla
      
      when you really want to.  In this case, you are both in the git directory
      and in the working tree.  So, programs have to actually test for the right
      thing, namely if they are inside a working tree, and not if they are
      inside a git directory.
      
      Also, GIT_DIR=../.git should behave the same as if no GIT_DIR was
      specified, unless there is a repository in the current working directory.
      It does now.
      
      The logic to determine if a repository is bare, or has a work tree
      (tertium non datur), is this:
      
      --work-tree=bla overrides GIT_WORK_TREE, which overrides core.bare = true,
      which overrides core.worktree, which overrides GIT_DIR/.. when GIT_DIR
      ends in /.git, which overrides the directory in which .git/ was found.
      
      In related news, a long standing bug was fixed: when in .git/bla/x.git/,
      which is a bare repository, git formerly assumed ../.. to be the
      appropriate git dir.  This problem was reported by Shawn Pearce to have
      caused much pain, where a colleague mistakenly ran "git init" in "/" a
      long time ago, and bare repositories just would not work.
      Signed-off-by: NJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      e90fdc39
  30. 07 6月, 2007 2 次提交
  31. 15 4月, 2007 1 次提交
    • L
      Fix some "git ls-files -o" fallout from gitlinks · 5698454e
      Linus Torvalds 提交于
      Since "git ls-files" doesn't really pass down any details on what it
      really wants done to the directory walking code, the directory walking
      code doesn't really know whether the caller wants to know about gitlink
      directories, or whether it wants to just know about ignored files.
      
      So the directory walking code will return those gitlink directories unless
      the caller has explicitly told it not to ("dir->show_other_directories"
      tells the directory walker to only show "other" directories).
      
      This kind of confuses "git ls-files -o", because
       - it didn't really expect to see entries listed that were already in the
         index, unless they  were unmerged, and would die on that unexpected
         setup, rather than just "continue".
       - it didn't know how to match directory entries with the final "/"
      
      This trivial change updates the "show_other_files()" function to handle
      both of these issues gracefully. There really was no reason to die, when
      the obviously correct thing for the function was to just ignore files it
      already knew about (that's what "other" means here!).
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      5698454e
  32. 01 4月, 2007 1 次提交
    • L
      Optimize directory listing with pathspec limiter. · 9fc42d60
      Linus Torvalds 提交于
      The way things are set up, you can now pass a "pathspec" to the
      "read_directory()" function. If you pass NULL, it acts exactly
      like it used to do (read everything). If you pass a non-NULL
      pointer, it will simplify it into a "these are the prefixes
      without any special characters", and stop any readdir() early if
      the path in question doesn't match any of the prefixes.
      
      NOTE! This does *not* obviate the need for the caller to do the *exact*
      pathspec match later. It's a first-level filter on "read_directory()", but
      it does not do the full pathspec thing. Maybe it should. But in the
      meantime, builtin-add.c really does need to do first
      
      	read_directory(dir, .., pathspec);
      	if (pathspec)
      		prune_directory(dir, pathspec, baselen);
      
      ie the "prune_directory()" part will do the *exact* pathspec pruning,
      while the "read_directory()" will use the pathspec just to do some quick
      high-level pruning of the directories it will recurse into.
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      9fc42d60
  33. 21 2月, 2007 1 次提交
    • J
      Mechanical conversion to use prefixcmp() · cc44c765
      Junio C Hamano 提交于
      This mechanically converts strncmp() to use prefixcmp(), but only when
      the parameters match specific patterns, so that they can be verified
      easily.  Leftover from this will be fixed in a separate step, including
      idiotic conversions like
      
          if (!strncmp("foo", arg, 3))
      
        =>
      
          if (!(-prefixcmp(arg, "foo")))
      
      This was done by using this script in px.perl
      
         #!/usr/bin/perl -i.bak -p
         if (/strncmp\(([^,]+), "([^\\"]*)", (\d+)\)/ && (length($2) == $3)) {
                 s|strncmp\(([^,]+), "([^\\"]*)", (\d+)\)|prefixcmp($1, "$2")|;
         }
         if (/strncmp\("([^\\"]*)", ([^,]+), (\d+)\)/ && (length($1) == $3)) {
                 s|strncmp\("([^\\"]*)", ([^,]+), (\d+)\)|(-prefixcmp($2, "$1"))|;
         }
      
      and running:
      
         $ git grep -l strncmp -- '*.c' | xargs perl px.perl
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      cc44c765
  34. 06 2月, 2007 1 次提交
  35. 21 12月, 2006 1 次提交
    • J
      simplify inclusion of system header files. · 85023577
      Junio C Hamano 提交于
      This is a mechanical clean-up of the way *.c files include
      system header files.
      
       (1) sources under compat/, platform sha-1 implementations, and
           xdelta code are exempt from the following rules;
      
       (2) the first #include must be "git-compat-util.h" or one of
           our own header file that includes it first (e.g. config.h,
           builtin.h, pkt-line.h);
      
       (3) system headers that are included in "git-compat-util.h"
           need not be included in individual C source files.
      
       (4) "git-compat-util.h" does not have to include subsystem
           specific header files (e.g. expat.h).
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      85023577