1. 02 1月, 2008 1 次提交
    • J
      config: handle lack of newline at end of file better · 02e5ba4a
      Jeff King 提交于
      The config parsing routines use the static global
      'config_file' to store the FILE* pointing to the current
      config file being parsed. The function get_next_char()
      automatically converts an EOF on this file to a newline for
      the convenience of its callers, and it sets config_file to
      NULL to indicate that EOF was reached.
      
      This throws away useful information, though, since some
      routines want to call ftell on 'config_file' to find out
      exactly _where_ the routine ended. In the case of a key
      ending at EOF boundary, we ended up segfaulting in some
      cases (changing that key or adding another key in its
      section), or failing to provide the necessary newline
      (adding a new section).
      
      This patch adds a new flag to indicate EOF and uses that
      instead of setting config_file to NULL. It also makes sure
      to add newlines where necessary for truncated input. All
      three included tests fail without the patch.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      02e5ba4a
  2. 27 12月, 2007 1 次提交
    • S
      Improve error messages when int/long cannot be parsed from config · c8deb5a1
      Shawn O. Pearce 提交于
      If a config file has become mildly corrupted due to a missing LF
      we may discover some other option joined up against the end of a
      numeric value.  For example:
      
      	[section]
      	number = 1auto
      
      where the "auto" flag was meant to occur on the next line, below
      "number", but the missing LF has caused it to no longer be its
      own option.  Instead the word "auto" is parsed as a 'unit factor'
      for the value of "number".
      
      Before this change we got the confusing error message:
      
        fatal: unknown unit: 'auto'
      
      which told us nothing about where the problem appeared.  Now we get:
      
        fatal: bad config value for 'aninvalid.unit'
      
      which at least points the user in the right direction of where to
      search for the incorrectly formatted configuration file.
      
      Noticed by erikh on #git, which received the original error from
      a simple `git checkout -b` due to a midly corrupted config.
      Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c8deb5a1
  3. 15 12月, 2007 1 次提交
  4. 09 12月, 2007 1 次提交
  5. 06 12月, 2007 1 次提交
    • J
      Use gitattributes to define per-path whitespace rule · cf1b7869
      Junio C Hamano 提交于
      The `core.whitespace` configuration variable allows you to define what
      `diff` and `apply` should consider whitespace errors for all paths in
      the project (See gitlink:git-config[1]).  This attribute gives you finer
      control per path.
      
      For example, if you have these in the .gitattributes:
      
          frotz   whitespace
          nitfol  -whitespace
          xyzzy   whitespace=-trailing
      
      all types of whitespace problems known to git are noticed in path 'frotz'
      (i.e. diff shows them in diff.whitespace color, and apply warns about
      them), no whitespace problem is noticed in path 'nitfol', and the
      default types of whitespace problems except "trailing whitespace" are
      noticed for path 'xyzzy'.  A project with mixed Python and C might want
      to have:
      
          *.c    whitespace
          *.py   whitespace=-indent-with-non-tab
      
      in its toplevel .gitattributes file.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      cf1b7869
  6. 17 11月, 2007 1 次提交
    • J
      core.excludesfile clean-up · dcf0c16e
      Junio C Hamano 提交于
      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
         changed.
      
       * 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
         files.
      
       * 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
      script.
      
      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: NJunio C Hamano <gitster@pobox.com>
      dcf0c16e
  7. 15 11月, 2007 3 次提交
    • J
      Allow ETC_GITCONFIG to be a relative path. · 7f0e39fa
      Johannes Sixt 提交于
      If ETC_GITCONFIG is not an absolute path, interpret it relative to
      --exec-dir. This makes the installed binaries relocatable because the
      prefix is not compiled-in.
      Signed-off-by: NJohannes Sixt <johannes.sixt@telecom.at>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      7f0e39fa
    • J
      Introduce git_etc_gitconfig() that encapsulates access of ETC_GITCONFIG. · 506b17b1
      Johannes Sixt 提交于
      In a subsequent patch the path to the system-wide config file will be
      computed. This is a preparation for that change. It turns all accesses
      of ETC_GITCONFIG into function calls. There is no change in behavior.
      
      As a consequence, config.c is the only file that needs the definition of
      ETC_GITCONFIG. Hence, -DETC_GITCONFIG is removed from the CFLAGS and a
      special build rule for config.c is introduced. As a side-effect, changing
      the defintion of ETC_GITCONFIG (e.g. in config.mak) does not trigger a
      complete rebuild anymore.
      Signed-off-by: NJohannes Sixt <johannes.sixt@telecom.at>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      506b17b1
    • J
      core.excludesfile clean-up · 039bc64e
      Junio C Hamano 提交于
      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
         changed.
      
       * 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
         files.
      
       * 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
      script.
      
      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: NJunio C Hamano <gitster@pobox.com>
      039bc64e
  8. 03 11月, 2007 2 次提交
    • J
      git-diff: complain about >=8 consecutive spaces in initial indent · 459fa6d0
      Junio C Hamano 提交于
      This introduces a new whitespace error type, "indent-with-non-tab".
      The error is about starting a line with 8 or more SP, instead of
      indenting it with a HT.
      
      This is not enabled by default, as some projects employ an
      indenting policy to use only SPs and no HTs.
      
      The kernel folks and git contributors may want to enable this
      detection with:
      
      	[core]
      		whitespace = indent-with-non-tab
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      459fa6d0
    • J
      War on whitespace: first, a bit of retreat. · a9cc857a
      Junio C Hamano 提交于
      This introduces core.whitespace configuration variable that lets
      you specify the definition of "whitespace error".
      
      Currently there are two kinds of whitespace errors defined:
      
       * trailing-space: trailing whitespaces at the end of the line.
      
       * space-before-tab: a SP appears immediately before HT in the
         indent part of the line.
      
      You can specify the desired types of errors to be detected by
      listing their names (unique abbreviations are accepted)
      separated by comma.  By default, these two errors are always
      detected, as that is the traditional behaviour.  You can disable
      detection of a particular type of error by prefixing a '-' in
      front of the name of the error, like this:
      
      	[core]
      		whitespace = -trailing-space
      
      This patch teaches the code to output colored diff with
      DIFF_WHITESPACE color to highlight the detected whitespace
      errors to honor the new configuration.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      a9cc857a
  9. 27 7月, 2007 1 次提交
  10. 22 7月, 2007 1 次提交
  11. 13 7月, 2007 1 次提交
  12. 05 7月, 2007 1 次提交
  13. 25 6月, 2007 1 次提交
    • J
      Add core.quotepath configuration variable. · 9378c161
      Junio C Hamano 提交于
      We always quote "unusual" byte values in a pathname using
      C-string style, to make it safer for parsing scripts that do not
      handle NUL separated records well (or just too lazy to bother).
      The absolute minimum bytes that need to be quoted for this
      purpose are TAB, LF (and other control characters), double quote
      and backslash.
      
      However, we have also always quoted the bytes in high 8-bit
      range; this was partly because we were lazy and partly because
      we were being cautious.
      
      This introduces an internal "quote_path_fully" variable, and
      core.quotepath configuration variable to control it.  When set
      to false, it does not quote bytes in high 8-bit range anymore
      but passes them intact.
      
      The variable defaults to "true" to retain the traditional
      behaviour for now.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      9378c161
  14. 13 6月, 2007 1 次提交
  15. 07 6月, 2007 1 次提交
    • J
      War on whitespace · a6080a0a
      Junio C Hamano 提交于
      This uses "git-apply --whitespace=strip" to fix whitespace errors that have
      crept in to our source files over time.  There are a few files that need
      to have trailing whitespaces (most notably, test vectors).  The results
      still passes the test, and build result in Documentation/ area is unchanged.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      a6080a0a
  16. 13 5月, 2007 1 次提交
  17. 11 5月, 2007 2 次提交
    • D
      Custom compression levels for objects and packs · 960ccca6
      Dana How 提交于
      Add config variables pack.compression and core.loosecompression ,
      and switch --compression=level to pack-objects.
      
      Loose objects will be compressed using core.loosecompression if set,
      else core.compression if set, else Z_BEST_SPEED.
      Packed objects will be compressed using --compression=level if seen,
      else pack.compression if set, else core.compression if set,
      else Z_DEFAULT_COMPRESSION.  This is the "pack compression level".
      
      Loose objects added to a pack undeltified will be recompressed
      to the pack compression level if it is unequal to the current
      loose compression level by the preceding rules,  or if the loose
      object was written while core.legacyheaders = true.  Newly
      deltified loose objects are always compressed to the current
      pack compression level.
      
      Previously packed objects added to a pack are recompressed
      to the current pack compression level exactly when their
      deltification status changes,  since the previous pack data
      cannot be reused.
      
      In either case,  the --no-reuse-object switch from the first
      patch below will always force recompression to the current pack
      compression level,  instead of assuming the pack compression level
      hasn't changed and pack data can be reused when possible.
      
      This applies on top of the following patches from Nicolas Pitre:
      [PATCH] allow for undeltified objects not to be reused
      [PATCH] make "repack -f" imply "pack-objects --no-reuse-object"
      Signed-off-by: NDana L. How <danahow@gmail.com>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      960ccca6
    • N
      deprecate the new loose object header format · 726f852b
      Nicolas Pitre 提交于
      Now that we encourage and actively preserve objects in a packed form
      more agressively than we did at the time the new loose object format and
      core.legacyheaders were introduced, that extra loose object format
      doesn't appear to be worth it anymore.
      
      Because the packing of loose objects has to go through the delta match
      loop anyway, and since most of them should end up being deltified in
      most cases, there is really little advantage to have this parallel loose
      object format as the CPU savings it might provide is rather lost in the
      noise in the end.
      
      This patch gets rid of core.legacyheaders, preserve the legacy format as
      the only writable loose object format and deprecate the other one to
      keep things simpler.
      Signed-off-by: NNicolas Pitre <nico@cam.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      726f852b
  18. 06 4月, 2007 1 次提交
  19. 19 3月, 2007 1 次提交
    • S
      Limit the size of the new delta_base_cache · 18bdec11
      Shawn O. Pearce 提交于
      The new configuration variable core.deltaBaseCacheLimit allows the
      user to control how much memory they are willing to give to Git for
      caching base objects of deltas.  This is not normally meant to be
      a user tweakable knob; the "out of the box" settings are meant to
      be suitable for almost all workloads.
      
      We default to 16 MiB under the assumption that the cache is not
      meant to consume all of the user's available memory, and that the
      cache's main purpose was to cache trees, for faster path limiters
      during revision traversal.  Since trees tend to be relatively small
      objects, this relatively small limit should still allow a large
      number of objects.
      
      On the other hand we don't want the cache to start storing 200
      different versions of a 200 MiB blob, as this could easily blow
      the entire address space of a 32 bit process.
      
      We evict OBJ_BLOB from the cache first (credit goes to Junio) as
      we want to favor OBJ_TREE within the cache.  These are the objects
      that have the highest inflate() startup penalty, as they tend to
      be small and thus don't have that much of a chance to ammortize
      that penalty over the entire data.
      Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      18bdec11
  20. 16 3月, 2007 1 次提交
  21. 08 3月, 2007 1 次提交
    • S
      Cast 64 bit off_t to 32 bit size_t · dc49cd76
      Shawn O. Pearce 提交于
      Some systems have sizeof(off_t) == 8 while sizeof(size_t) == 4.
      This implies that we are able to access and work on files whose
      maximum length is around 2^63-1 bytes, but we can only malloc or
      mmap somewhat less than 2^32-1 bytes of memory.
      
      On such a system an implicit conversion of off_t to size_t can cause
      the size_t to wrap, resulting in unexpected and exciting behavior.
      Right now we are working around all gcc warnings generated by the
      -Wshorten-64-to-32 option by passing the off_t through xsize_t().
      
      In the future we should make xsize_t on such problematic platforms
      detect the wrapping and die if such a file is accessed.
      Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      dc49cd76
  22. 04 3月, 2007 1 次提交
  23. 03 3月, 2007 1 次提交
    • J
      Add core.symlinks to mark filesystems that do not support symbolic links. · 78a8d641
      Johannes Sixt 提交于
      Some file systems that can host git repositories and their working copies
      do not support symbolic links. But then if the repository contains a symbolic
      link, it is impossible to check out the working copy.
      
      This patch enables partial support of symbolic links so that it is possible
      to check out a working copy on such a file system.  A new flag
      core.symlinks (which is true by default) can be set to false to indicate
      that the filesystem does not support symbolic links. In this case, symbolic
      links that exist in the trees are checked out as small plain files, and
      checking in modifications of these files preserve the symlink property in
      the database (as long as an entry exists in the index).
      
      Of course, this does not magically make symbolic links work on such defective
      file systems; hence, this solution does not help if the working copy relies
      on that an entry is a real symbolic link.
      Signed-off-by: NJohannes Sixt <johannes.sixt@telecom.at>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      78a8d641
  24. 20 2月, 2007 1 次提交
  25. 15 2月, 2007 3 次提交
    • J
      Make sure packedgitwindowsize is multiple of (pagesize * 2) · 5faaf246
      Junio C Hamano 提交于
      The next patch depends on this.
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      5faaf246
    • L
      Make AutoCRLF ternary variable. · d7f46334
      Linus Torvalds 提交于
      This allows you to do:
      
      	[core]
      		AutoCRLF = input
      
      and it should do only the CRLF->LF translation (ie it simplifies CRLF only
      when reading working tree files, but when checking out files, it leaves
      the LF alone, and doesn't turn it into a CRLF).
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      d7f46334
    • L
      Lazy man's auto-CRLF · 6c510bee
      Linus Torvalds 提交于
      It currently does NOT know about file attributes, so it does its
      conversion purely based on content. Maybe that is more in the "git
      philosophy" anyway, since content is king, but I think we should try to do
      the file attributes to turn it off on demand.
      
      Anyway, BY DEFAULT it is off regardless, because it requires a
      
      	[core]
      		AutoCRLF = true
      
      in your config file to be enabled. We could make that the default for
      Windows, of course, the same way we do some other things (filemode etc).
      
      But you can actually enable it on UNIX, and it will cause:
      
       - "git update-index" will write blobs without CRLF
       - "git diff" will diff working tree files without CRLF
       - "git checkout" will write files to the working tree _with_ CRLF
      
      and things work fine.
      
      Funnily, it actually shows an odd file in git itself:
      
      	git clone -n git test-crlf
      	cd test-crlf
      	git config core.autocrlf true
      	git checkout
      	git diff
      
      shows a diff for "Documentation/docbook-xsl.css". Why? Because we have
      actually checked in that file *with* CRLF! So when "core.autocrlf" is
      true, we'll always generate a *different* hash for it in the index,
      because the index hash will be for the content _without_ CRLF.
      
      Is this complete? I dunno. It seems to work for me. It doesn't use the
      filename at all right now, and that's probably a deficiency (we could
      certainly make the "is_binary()" heuristics also take standard filename
      heuristics into account).
      
      I don't pass in the filename at all for the "index_fd()" case
      (git-update-index), so that would need to be passed around, but this
      actually works fine.
      
      NOTE NOTE NOTE! The "is_binary()" heuristics are totally made-up by yours
      truly. I will not guarantee that they work at all reasonable. Caveat
      emptor. But it _is_ simple, and it _is_ safe, since it's all off by
      default.
      
      The patch is pretty simple - the biggest part is the new "convert.c" file,
      but even that is really just basic stuff that anybody can write in
      "Teaching C 101" as a final project for their first class in programming.
      Not to say that it's bug-free, of course - but at least we're not talking
      about rocket surgery here.
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      6c510bee
  26. 04 2月, 2007 1 次提交
  27. 20 1月, 2007 1 次提交
  28. 12 1月, 2007 1 次提交
  29. 09 1月, 2007 2 次提交
  30. 08 1月, 2007 1 次提交
  31. 31 12月, 2006 1 次提交
  32. 30 12月, 2006 2 次提交
    • S
      Replace mmap with xmmap, better handling MAP_FAILED. · c4712e45
      Shawn O. Pearce 提交于
      In some cases we did not even bother to check the return value of
      mmap() and just assume it worked.  This is bad, because if we are
      out of virtual address space the kernel returned MAP_FAILED and we
      would attempt to dereference that address, segfaulting without any
      real error output to the user.
      
      We are replacing all calls to mmap() with xmmap() and moving all
      MAP_FAILED checking into that single location.  If a mmap call
      fails we try to release enough least-recently-used pack windows
      to possibly succeed, then retry the mmap() attempt.  If we cannot
      mmap even after releasing pack memory then we die() as none of our
      callers have any reasonable recovery strategy for a failed mmap.
      Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      c4712e45
    • S
      Ensure core.packedGitWindowSize cannot be less than 2 pages. · 40be8272
      Shawn O. Pearce 提交于
      We cannot allow a window to be smaller than 2 system pages.
      This limitation is necessary to support the feature of use_pack()
      where we always supply at least 20 bytes after the offset to help
      the object header and delta base parsing routines.
      
      If packedGitWindowSize were allowed to be as small as 1 system page
      then we would be completely unable to access an object header which
      spanned over a page as we would never be able to arrange a mapping
      such that the header was contiguous in virtual memory.
      Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      40be8272