1. 13 11月, 2007 1 次提交
  2. 12 11月, 2007 1 次提交
    • A
      Simplify strchrnul() compat code · 9e79f00f
      Andreas Ericsson 提交于
      strchrnul() was introduced in glibc in April 1999 and included in
      glibc-2.1. Checking for that version means the majority of all git
      users would get to use the optimized version in glibc. Of the
      remaining few some might get to use a slightly slower version
      than necessary but probably not slower than what we have today.
      
      Unfortunately, __GLIBC_PREREQ() macro was not available in glibc 2.1.1
      which was short lived but already supported strchrnul().  Odd minority
      users of that library needs to live with our compatibility inline version.
      Rediffed-against-next-by: NRene Scharfe <rene.scharfe@lsrfire.ath.cx>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      9e79f00f
  3. 09 11月, 2007 1 次提交
  4. 27 10月, 2007 1 次提交
    • J
      revert/cherry-pick: work on merge commits as well · 7791ecbc
      Junio C Hamano 提交于
      Usually you cannot revert a merge because you do not know which
      side of the merge should be considered the mainline (iow, what
      change to reverse).
      
      With this patch, cherry-pick and revert learn -m (--mainline)
      option that lets you specify the parent number (starting from 1)
      of the mainline, so that you can:
      
      	git revert -m 1 $merge
      
      to reverse the changes introduced by the $merge commit relative
      to its first parent, and:
      
      	git cherry-pick -m 2 $merge
      
      to replay the changes introduced by the $merge commit relative
      to its second parent.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      7791ecbc
  5. 21 10月, 2007 1 次提交
  6. 18 9月, 2007 1 次提交
  7. 07 9月, 2007 1 次提交
    • R
      add memmem() · b21b9f1d
      René Scharfe 提交于
      memmem() is a nice GNU extension for searching a length limited string
      in another one.
      
      This compat version is based on the version found in glibc 2.2 (GPL 2);
      I only removed the optimization of checking the first char by hand, and
      generally tried to keep the code simple.  We can add it back if memcmp
      shows up high in a profile, but for now I prefer to keep it (almost
      trivially) simple.
      
      Since I don't really know which platforms beside those with a glibc
      have their own memmem(), I used a heuristic: if NO_STRCASESTR is set,
      then NO_MEMMEM is set, too.
      Signed-off-by: NRene Scharfe <rene.scharfe@lsrfire.ath.cx>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b21b9f1d
  8. 15 8月, 2007 1 次提交
  9. 28 6月, 2007 1 次提交
  10. 16 6月, 2007 1 次提交
  11. 16 5月, 2007 1 次提交
    • A
      git name-rev writes beyond the end of malloc() with large generations · cf606e3d
      Andy Whitcroft 提交于
      When using git name-rev on my kernel tree I triggered a malloc()
      corruption warning from glibc.
      
      apw@pinky$ git log --pretty=one $N/base.. | git name-rev --stdin
      *** glibc detected *** malloc(): memory corruption: 0x0bff8950 ***
      Aborted
      
      This comes from name_rev() which is building the name of the revision
      in a malloc'd string, which it sprintf's into:
      
      	char *new_name = xmalloc(len + 8);
      	[...]
      		sprintf(new_name, "%.*s~%d^%d", len, tip_name,
      				generation, parent_number);
      
      This allocation is only sufficient if the generation number is
      less than 5 digits, in my case generation was 13432.  In reality
      parent_number can be up to 16 so that also can require two digits,
      reducing us to 3 digits before we are at risk of blowing this
      allocation.
      
      This patch introduces a decimal_length() which approximates the
      number of digits a type may hold, it produces the following:
      
      Type                 Longest Value          Len  Est
      ----                 -------------          ---  ---
      unsigned char        256                      3    4
      unsigned short       65536                    5    6
      unsigned long        4294967296              10   11
      unsigned long long   18446744073709551616    20   21
      char                 -128                     4    4
      short                -32768                   6    6
      long                 -2147483648             11   11
      long long            -9223372036854775808    20   21
      
      This is then used to size the new_name.
      Signed-off-by: NAndy Whitcroft <apw@shadowen.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      cf606e3d
  12. 04 5月, 2007 1 次提交
  13. 26 4月, 2007 1 次提交
    • S
      Actually handle some-low memory conditions · d1efefa4
      Shawn O. Pearce 提交于
      Tim Ansell discovered his Debian server didn't permit git-daemon to
      use as much memory as it needed to handle cloning a project with
      a 128 MiB packfile.  Filtering the strace provided by Tim of the
      rev-list child showed this gem of a sequence:
      
        open("./objects/pack/pack-*.pack", O_RDONLY|O_LARGEFILE <unfinished ...>
        <... open resumed> )              = 5
      
      OK, so the packfile is fd 5...
      
        mmap2(NULL, 33554432, PROT_READ, MAP_PRIVATE, 5, 0 <unfinished ...>
         <... mmap2 resumed> )             = 0xb5e2d000
      
      and we mapped one 32 MiB window from it at position 0...
      
         mmap2(NULL, 31020635, PROT_READ, MAP_PRIVATE, 5, 0x6000 <unfinished ...>
         <... mmap2 resumed> )             = -1 ENOMEM (Cannot allocate memory)
      
      And we asked for another window further into the file.  But got
      denied.  In Tim's case this was due to a resource limit on the
      git-daemon process, and its children.
      
      Now where are we in the code?  We're down inside use_pack(),
      after we have called unuse_one_window() enough times to make sure
      we stay within our allowed maximum window size.  However since we
      didn't unmap the prior window at 0xb5e2d000 we aren't exceeding
      the current limit (which probably was just the defaults).
      
      But we're actually down inside xmmap()...
      
      So we release the window we do have (by calling release_pack_memory),
      assuming there is some memory pressure...
      
         munmap(0xb5e2d000, 33554432 <unfinished ...>
         <... munmap resumed> )            = 0
         close(5 <unfinished ...>
         <... close resumed> )             = 0
      
      And that was the last window in this packfile.  So we closed it.
      Way to go us.  Our xmmap did not expect release_pack_memory to
      close the fd its about to map...
      
         mmap2(NULL, 31020635, PROT_READ, MAP_PRIVATE, 5, 0x6000 <unfinished ...>
         <... mmap2 resumed> )             = -1 EBADF (Bad file descriptor)
      
      And so the Linux kernel happily tells us f' off.
      
         write(2, "fatal: ", 7 <unfinished ...>
         <... write resumed> )             = 7
         write(2, "Out of memory? mmap failed: Bad "..., 47 <unfinished ...>
         <... write resumed> )             = 47
      
      And we report the bad file descriptor error, and not the ENOMEM,
      and die, claiming we are out of memory.  But actually that mmap
      should have succeeded, as we had enough memory for that window,
      seeing as how we released the prior one.
      
      Originally when I developed the sliding window mmap feature I had
      this exact same bug in fast-import, and I dealt with it by handing
      in the struct packed_git* we want to open the new window for, as the
      caller wasn't prepared to reopen the packfile if unuse_one_window
      closed it.  The same is true here from xmmap, but the caller doesn't
      have the struct packed_git* handy.  So I'm using the file descriptor
      instead to perform the same test.
      Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      d1efefa4
  14. 15 4月, 2007 1 次提交
    • J
      sscanf/strtoul: parse integers robustly · 61d6ed13
      Jim Meyering 提交于
      * builtin-grep.c (strtoul_ui): Move function definition from here, to...
      * git-compat-util.h (strtoul_ui): ...here, with an added "base" parameter.
      * builtin-grep.c (cmd_grep): Update use of strtoul_ui to include base, "10".
      * builtin-update-index.c (read_index_info): Diagnose an invalid mode integer
      that is out of range or merely larger than INT_MAX.
      (cmd_update_index): Use strtoul_ui, not sscanf.
      * convert-objects.c (write_subdirectory): Likewise.
      Signed-off-by: NJim Meyering <jim@meyering.net>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      61d6ed13
  15. 12 4月, 2007 1 次提交
    • J
      sscanf/strtoul: parse integers robustly · 6aead43d
      Jim Meyering 提交于
      * builtin-grep.c (strtoul_ui): Move function definition from here, to...
      * git-compat-util.h (strtoul_ui): ...here, with an added "base" parameter.
      * builtin-grep.c (cmd_grep): Update use of strtoul_ui to include base, "10".
      * builtin-update-index.c (read_index_info): Diagnose an invalid mode integer
      that is out of range or merely larger than INT_MAX.
      (cmd_update_index): Use strtoul_ui, not sscanf.
      * convert-objects.c (write_subdirectory): Likewise.
      Signed-off-by: NJim Meyering <jim@meyering.net>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      6aead43d
  16. 11 4月, 2007 1 次提交
  17. 31 3月, 2007 1 次提交
    • T
      Rename warn() to warning() to fix symbol conflicts on BSD and Mac OS · 46efd2d9
      Theodore Ts'o 提交于
      This fixes a problem reported by Randal Schwartz:
      
      >I finally tracked down all the (albeit inconsequential) errors I was getting
      >on both OpenBSD and OSX.  It's the warn() function in usage.c.  There's
      >warn(3) in BSD-style distros.  It'd take a "great rename" to change it, but if
      >someone with better C skills than I have could do that, my linker and I would
      >appreciate it.
      
      It was annoying to me, too, when I was doing some mergetool testing on
      Mac OS X, so here's a fix.
      Signed-off-by: N"Theodore Ts'o" <tytso@mit.edu>
      Cc: "Randal L. Schwartz" <merlyn@stonehenge.com>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      46efd2d9
  18. 08 3月, 2007 2 次提交
    • 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
    • S
      Use off_t when we really mean a file offset. · c4001d92
      Shawn O. Pearce 提交于
      Not all platforms have declared 'unsigned long' to be a 64 bit value,
      but we want to support a 64 bit packfile (or close enough anyway)
      in the near future as some projects are getting large enough that
      their packed size exceeds 4 GiB.
      
      By using off_t, the POSIX type that is declared to mean an offset
      within a file, we support whatever maximum file size the underlying
      operating system will handle.  For most modern systems this is up
      around 2^60 or higher.
      Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      c4001d92
  19. 04 3月, 2007 1 次提交
  20. 21 2月, 2007 2 次提交
  21. 20 2月, 2007 1 次提交
  22. 15 2月, 2007 1 次提交
  23. 26 1月, 2007 1 次提交
  24. 19 1月, 2007 2 次提交
  25. 16 1月, 2007 2 次提交
  26. 12 1月, 2007 1 次提交
    • L
      Better error messages for corrupt databases · 9130ac1e
      Linus Torvalds 提交于
      This fixes another problem that Andy's case showed: git-fsck-objects
      reports nonsensical results for corrupt objects.
      
      There were actually two independent and confusing problems:
      
       - when we had a zero-sized file and used map_sha1_file, mmap() would
         return EINVAL, and git-fsck-objects would report that as an insane and
         confusing error. I don't know when this was introduced, it might have
         been there forever.
      
       - when "parse_object()" returned NULL, fsck would say "object not found",
         which can be very confusing, since obviously the object might "exist",
         it's just unparseable because it's totally corrupt.
      
      So this just makes "xmmap()" return NULL for a zero-sized object (which is
      a valid thing pointer, exactly the same way "malloc()" can return NULL for
      a zero-sized allocation). That fixes the first problem (but we could have
      fixed it in the caller too - I don't personally much care whichever way it
      goes, but maybe somebody should check that the NO_MMAP case does
      something sane in this case too?).
      
      And the second problem is solved by just making the error message slightly
      clearer - the failure to parse an object may be because it's missing or
      corrupt, not necessarily because it's not "found".
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      9130ac1e
  27. 10 1月, 2007 1 次提交
  28. 07 1月, 2007 2 次提交
  29. 30 12月, 2006 3 次提交
    • 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
      Release pack windows before reporting out of memory. · 97bfeb34
      Shawn O. Pearce 提交于
      If we are about to fail because this process has run out of memory we
      should first try to automatically control our appetite for address
      space by releasing enough least-recently-used pack windows to gain
      back enough memory such that we might actually be able to meet the
      current allocation request.
      
      This should help users who have fairly large repositories but are
      working on systems with relatively small virtual address space.
      Many times we see reports on the mailing list of these users running
      out of memory during various Git operations.  Dynamically decreasing
      the amount of pack memory used when the demand for heap memory is
      increasing is an intelligent solution to this problem.
      Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      97bfeb34
    • S
      Default core.packdGitWindowSize to 1 MiB if NO_MMAP. · 8c82534d
      Shawn O. Pearce 提交于
      If the compiler has asked us to disable use of mmap() on their
      platform then we are forced to use git_mmap and its emulation via
      pread.  In this case large (e.g. 32 MiB) windows for pack access
      are simply too big as a command will wind up reading a lot more
      data than it will ever need, significantly reducing response time.
      
      To prevent a high latency when NO_MMAP has been selected we now
      use a default of 1 MiB for core.packedGitWindowSize.  Credit goes
      to Linus and Junio for recommending this more reasonable setting.
      
      [jc: upcased the name of the symbolic constant, and made another
       hardcoded constant into a symbolic constant while at it. ]
      Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      8c82534d
  30. 24 12月, 2006 1 次提交
  31. 23 12月, 2006 1 次提交
  32. 22 12月, 2006 2 次提交