1. 30 5月, 2012 1 次提交
  2. 12 5月, 2012 2 次提交
  3. 09 5月, 2012 1 次提交
    • R
      dir: convert to strbuf · 49dc2cc2
      René Scharfe 提交于
      The functions read_directory_recursive() and treat_leading_path() both
      use buffers sized to fit PATH_MAX characters.  The latter can be made to
      overrun its buffer, e.g. like this:
      
      	$ a=0123456789abcdef
      	$ a=$a$a$a$a$a$a$a$a
      	$ a=$a$a$a$a$a$a$a$a
      	$ a=$a$a$a$a$a$a$a$a
      	$ git add $a/a
      
      Instead of trying to add a check and potentionally forgetting to address
      similar cases, convert the involved functions and their helpers to use
      struct strbuf.  The patch is suprisingly large because the helpers
      treat_path() and treat_one_path() modify the buffer as well and thus need
      to be converted, too.
      Signed-off-by: NRene Scharfe <rene.scharfe@lsrfire.ath.cx>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      49dc2cc2
  4. 16 3月, 2012 2 次提交
    • J
      clean: preserve nested git worktree in subdirectories · ae2f203e
      Junio C Hamano 提交于
      remove_dir_recursively() has a check to avoid removing the directory it
      was asked to remove without recursing into it and report success when the
      directory is the top level of a working tree of a nested git repository,
      to protect such a repository from "clean -f" (without double -f). If a
      working tree of a nested git repository is in a subdirectory of a toplevel
      project, however, this protection did not apply by mistake; we forgot to
      pass the REMOVE_DIR_KEEP_NESTED_GIT down to the recursive removal
      codepath.
      
      This requires us to also teach the higher level not to remove the
      directory it is asked to remove, when the recursed invocation did not
      remove the directory it was asked to remove due to a nested git
      repository, as it is not an error to leave the parent directories of such
      a nested repository.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ae2f203e
    • J
      remove_dir_recursively(): Add flag for skipping removal of toplevel dir · c844a803
      Junio C Hamano 提交于
      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 (a0f4afbe), but this commit keeps the same behaviour for now.
      Signed-off-by: NJohan Herland <johan@herland.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c844a803
  5. 28 10月, 2011 1 次提交
  6. 13 9月, 2011 1 次提交
  7. 07 9月, 2011 1 次提交
  8. 06 4月, 2011 1 次提交
  9. 02 4月, 2011 1 次提交
  10. 29 3月, 2011 2 次提交
  11. 18 3月, 2011 1 次提交
  12. 04 2月, 2011 5 次提交
  13. 01 12月, 2010 1 次提交
  14. 30 11月, 2010 1 次提交
  15. 24 11月, 2010 1 次提交
  16. 09 11月, 2010 1 次提交
  17. 07 10月, 2010 4 次提交
    • J
      Add case insensitivity support when using git ls-files · 21444f18
      Joshua Jensen 提交于
      When mydir/filea.txt is added, mydir/ is renamed to MyDir/, and
      MyDir/fileb.txt is added, running git ls-files mydir only shows
      mydir/filea.txt. Running git ls-files MyDir shows MyDir/fileb.txt.
      Running git ls-files mYdIR shows nothing.
      
      With this patch running git ls-files for mydir, MyDir, and mYdIR shows
      mydir/filea.txt and MyDir/fileb.txt.
      
      Wildcards are not handled case insensitively in this patch. Example:
      MyDir/aBc/file.txt is added. git ls-files MyDir/a* works fine, but git
      ls-files mydir/a* does not.
      Signed-off-by: NJoshua Jensen <jjensen@workspacewhiz.com>
      Signed-off-by: NJohannes Sixt <j6t@kdbg.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      21444f18
    • J
      Add case insensitivity support for directories when using git status · 5102c617
      Joshua Jensen 提交于
      When using a case preserving but case insensitive file system, directory
      case can differ but still refer to the same physical directory.  git
      status reports the directory with the alternate case as an Untracked
      file.  (That is, when mydir/filea.txt is added to the repository and
      then the directory on disk is renamed from mydir/ to MyDir/, git status
      shows MyDir/ as being untracked.)
      
      Support has been added in name-hash.c for hashing directories with a
      terminating slash into the name hash. When index_name_exists() is called
      with a directory (a name with a terminating slash), the name is not
      found via the normal cache_name_compare() call, but it is found in the
      slow_same_name() function.
      
      Additionally, in dir.c, directory_exists_in_index_icase() allows newly
      added directories deeper in the directory chain to be identified.
      
      Ultimately, it would be better if the file list was read in case
      insensitive alphabetical order from disk, but this change seems to
      suffice for now.
      
      The end result is the directory is looked up in a case insensitive
      manner and does not show in the Untracked files list.
      Signed-off-by: NJoshua Jensen <jjensen@workspacewhiz.com>
      Signed-off-by: NJohannes Sixt <j6t@kdbg.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      5102c617
    • J
      Case insensitivity support for .gitignore via core.ignorecase · 10d4b02b
      Joshua Jensen 提交于
      This is especially beneficial when using Windows and Perforce and the
      git-p4 bridge. Internally, Perforce preserves a given file's full path
      including its case at the time it was added to the Perforce repository.
      When syncing a file down via Perforce, missing directories are created,
      if necessary, using the case as stored with the filename. Unfortunately,
      two files in the same directory can have differing cases for their
      respective paths, such as /diRa/file1.c and /DirA/file2.c. Depending on
      sync order, DirA/ may get created instead of diRa/.
      
      It is possible to handle directory names in a case insensitive manner
      without this patch, but it is highly inconvenient, requiring each
      character to be specified like so: [Bb][Uu][Ii][Ll][Dd]. With this patch, the
      gitignore exclusions honor the core.ignorecase=true configuration
      setting and make the process less error prone. The above is specified
      like so: Build
      Signed-off-by: NJoshua Jensen <jjensen@workspacewhiz.com>
      Signed-off-by: NJohannes Sixt <j6t@kdbg.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      10d4b02b
    • J
      Add string comparison functions that respect the ignore_case variable. · 8cf2a84e
      Joshua Jensen 提交于
      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: NJoshua Jensen <jjensen@workspacewhiz.com>
      Signed-off-by: NJohannes Sixt <j6t@kdbg.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      8cf2a84e
  18. 28 9月, 2010 1 次提交
  19. 13 7月, 2010 1 次提交
  20. 17 6月, 2010 1 次提交
    • J
      common_prefix: simplify and fix scanning for prefixes · 42f9852f
      Junio C Hamano 提交于
      common_prefix() scans backwards from the far end of each 'next'
      pathspec, starting from 'len', shortening the 'prefix' using 'path' as
      a reference.
      
      However, there is a small opportunity for an out-of-bounds access
      because len is unconditionally set to prefix-1 after a "direct match"
      test failed.  This means that if 'next' is shorter than prefix+2, we
      read past it.
      
      Instead of a minimal fix, simplify the loop: scan *forward* over the
      'next' entry, remembering the last '/' where it matched the prefix
      known so far.  This is far easier to read and also has the advantage
      that we only scan over each entry once.
      Acked-by: NThomas Rast <trast@student.ethz.ch>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      42f9852f
  21. 01 6月, 2010 1 次提交
    • G
      enums: omit trailing comma for portability · 4b05548f
      Gary V. Vaughan 提交于
      Without this patch at least IBM VisualAge C 5.0 (I have 5.0.2) on AIX
      5.1 fails to compile git.
      
      enum style is inconsistent already, with some enums declared on one
      line, some over 3 lines with the enum values all on the middle line,
      sometimes with 1 enum value per line... and independently of that the
      trailing comma is sometimes present and other times absent, often
      mixing with/without trailing comma styles in a single file, and
      sometimes in consecutive enum declarations.
      
      Clearly, omitting the comma is the more portable style, and this patch
      changes all enum declarations to use the portable omitted dangling
      comma style consistently.
      Signed-off-by: NGary V. Vaughan <gary@thewrittenword.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      4b05548f
  22. 29 5月, 2010 1 次提交
  23. 14 3月, 2010 1 次提交
    • J
      dir: fix COLLECT_IGNORED on excluded prefixes · 29209cbe
      Jeff King 提交于
      As we walk the directory tree, if we see an ignored path, we
      want to add it to the ignored list only if it matches any
      pathspec that we were given. We used to check for the
      pathspec to appear explicitly. E.g., if we see "subdir/file"
      and it is excluded, we check to see if we have "subdir/file"
      in our pathspec.
      
      However, this interacts badly with the optimization to avoid
      recursing into ignored subdirectories. If "subdir" as a
      whole is ignored, then we never recurse, and consider only
      whether "subdir" itself is in our pathspec.  It would not
      match a pathspec of "subdir/file" explicitly, even though it
      is the reason that subdir/file would be excluded.
      
      This manifests itself to the user as "git add subdir/file"
      failing to correctly note that the pathspec was ignored.
      
      This patch extends the in_pathspec logic to include prefix
      directory case.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      29209cbe
  24. 19 2月, 2010 1 次提交
  25. 21 1月, 2010 1 次提交
    • N
      Fix memory corruption when .gitignore does not end by \n · 45d76f17
      Nguyễn Thái Ngọc Duy 提交于
      Commit b5041c5f (Avoid writing to buffer in add_excludes_from_file_1())
      tried not to append '\n' at the end because the next commit
      may return a buffer that does not have extra space for that.
      
      Unfortunately it left this assignment in the loop:
      
        buf[i - (i && buf[i-1] == '\r')] = 0;
      
      that can corrupt memory if "buf" is not '\n' terminated. But even if
      it does not corrupt memory, the last line would not be
      NULL-terminated, leading to errors later inside add_exclude().
      
      This patch fixes it by reverting the faulty commit and make
      sure "buf" is always \n terminated.
      
      While at it, free unused memory properly.
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      45d76f17
  26. 09 1月, 2010 3 次提交
    • J
      ls-files: fix overeager pathspec optimization · 48ffef96
      Junio C Hamano 提交于
      Given pathspecs that share a common prefix, ls-files optimized its call
      into recursive directory reader by starting at the common prefix
      directory.
      
      If you have a directory "t" with an untracked file "t/junk" in it, but the
      top-level .gitignore file told us to ignore "t/", this resulted in:
      
          $ git ls-files -o --exclude-standard
          $ git ls-files -o --exclude-standard t/
          t/junk
          $ git ls-files -o --exclude-standard t/junk
          t/junk
          $ cd t && git ls-files -o --exclude-standard
          junk
      
      We could argue that you are overriding the ignore file by giving a
      patchspec that matches or being in that directory, but it is somewhat
      unexpected.  Worse yet, these behave differently:
      
          $ git ls-files -o --exclude-standard t/ .
          $ git ls-files -o --exclude-standard t/
          t/junk
      
      This patch changes the optimization so that it notices when the common
      prefix directory that it starts reading from is an ignored one.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      48ffef96
    • J
      read_directory(): further split treat_path() · 16e2cfa9
      Junio C Hamano 提交于
      The next caller I'll be adding won't have an access to struct dirent
      because it won't be reading from a directory stream.  Split the main
      part of the function further into a separate function to make it usable
      by a caller without passing a dirent as long as it knows what type is
      feeding the function.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      16e2cfa9
    • J
      read_directory_recursive(): refactor handling of a single path into a separate function · 53cc5356
      Junio C Hamano 提交于
      Primarily because I want to reuse it in a separate function later,
      but this de-dents a huge function by one tabstop which by itself is
      an improvement as well.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      53cc5356
  27. 24 8月, 2009 2 次提交