1. 03 Sep, 2014 1 commit
  2. 06 Jun, 2013 1 commit
    • Jeff King's avatar
      clear parsed flag when we free tree buffers · 6e454b9a
      Jeff King authored
      Many code paths will free a tree object's buffer and set it
      to NULL after finishing with it in order to keep memory
      usage down during a traversal. However, out of 8 sites that
      do this, only one actually unsets the "parsed" flag back.
      Those sites that don't are setting a trap for later users of
      the tree object; even after calling parse_tree, the buffer
      will remain NULL, causing potential segfaults.
      
      It is not known whether this is triggerable in the current
      code. Most commands do not do an in-memory traversal
      followed by actually using the objects again. However, it
      does not hurt to be safe for future callers.
      
      In most cases, we can abstract this out to a
      "free_tree_buffer" helper. However, there are two
      exceptions:
      
        1. The fsck code relies on the parsed flag to know that we
           were able to parse the object at one point. We can
           switch this to using a flag in the "flags" field.
      
        2. The index-pack code sets the buffer to NULL but does
           not free it (it is freed by a caller). We should still
           unset the parsed flag here, but we cannot use our
           helper, as we do not want to free the buffer.
      Signed-off-by: default avatarJeff King <peff@peff.net>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      6e454b9a
  3. 17 Mar, 2013 1 commit
    • Jeff King's avatar
      use parse_object_or_die instead of die("bad object") · f7892d18
      Jeff King authored
      Some call-sites do:
      
        o = parse_object(sha1);
        if (!o)
      	  die("bad object %s", some_name);
      
      We can now handle that as a one-liner, and get more
      consistent output.
      
      In the third case of this patch, it looks like we are losing
      information, as the existing message also outputs the sha1
      hex; however, parse_object will already have written a more
      specific complaint about the sha1, so there is no point in
      repeating it here.
      Signed-off-by: default avatarJeff King <peff@peff.net>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      f7892d18
  4. 08 Nov, 2011 2 commits
  5. 22 Mar, 2011 1 commit
  6. 30 Aug, 2010 1 commit
  7. 09 Apr, 2009 1 commit
    • Björn Steinbrink's avatar
      process_{tree,blob}: Remove useless xstrdup calls · de551d47
      Björn Steinbrink authored
      The name of the processed object was duplicated for passing it to
      add_object(), but that already calls path_name, which allocates a new
      string anyway. So the memory allocated by the xstrdup calls just went
      nowhere, leaking memory.
      
      This reduces the RSS usage for a "rev-list --all --objects" by about 10% on
      the gentoo repo (fully packed) as well as linux-2.6.git:
      
          gentoo:
                          | old           | new
          ----------------|-------------------------------
          RSS             |       1537284 |       1388408
          VSZ             |       1816852 |       1667952
          time elapsed    |       1:49.62 |       1:48.99
          min. page faults|        417178 |        379919
      
          linux-2.6.git:
                          | old           | new
          ----------------|-------------------------------
          RSS             |        324452 |        292996
          VSZ             |        491792 |        460376
          time elapsed    |       0:14.53 |       0:14.28
          min. page faults|         89360 |         81613
      Signed-off-by: default avatarBjörn Steinbrink <B.Steinbrink@gmx.de>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      de551d47
  8. 19 Feb, 2008 3 commits
  9. 18 Feb, 2008 1 commit
  10. 21 Jan, 2008 1 commit
    • Linus Torvalds's avatar
      Make on-disk index representation separate from in-core one · 7a51ed66
      Linus Torvalds authored
      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: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      7a51ed66
  11. 02 Jul, 2007 1 commit
    • Andy Parkins's avatar
      Make git-prune submodule aware (and fix a SEGFAULT in the process) · 8d2244ba
      Andy Parkins authored
      I ran git-prune on a repository and got this:
      
       $ git-prune
       error: Object 228f8065b930120e35fc0c154c237487ab02d64a is a blob, not a commit
       Segmentation fault (core dumped)
      
      This repository was a strange one in that it was being used to provide
      its own submodule.  That is, the repository was cloned into a
      subdirectory, an independent branch checked out in that subdirectory,
      and then it was marked as a submodule.  git-prune then failed in the
      above manner.
      
      The problem was that git-prune was not submodule aware in two areas.
      
      Linus said:
      
       > So what happens is that something traverses a tree object, looks at each
       > entry, sees that it's not a tree, and tries to look it up as a blob. But
       > subprojects are commits, not blobs, and then when you look at the object
       > more closely, you get the above kind of object type confusion.
      
      and included a patch to add an S_ISGITLINK() test to reachable.c's
      process_tree() function.  That fixed the first git-prune error, and
      stopped it from trying to process the gitlink entries in trees as if
      they were pointers to other trees (and of course failing, because
      gitlinks _aren't_ trees).  That part of this patch is his.
      
      The second area is add_cache_refs().  This is called before starting the
      reachability analysis, and was calling lookup_blob() on every object
      hash found in the index.  However, it is no longer true that every hash
      in the index is a pointer to a blob, some of them are gitlinks, and are
      not backed by any object at all, they are commits in another repository.
      Normally this bug was not causing any problems, but in the case of the
      self-referencing repository described above, it meant that the gitlink
      hash was being marked as being of type OBJ_BLOB by add_cache_refs() call
      to lookup_blob().  Then later, because that hash was also pointed to by
      a ref, add_one_ref() would treat it as a commit; lookup_commit() would
      return a NULL because that object was already noted as being an
      OBJ_BLOB, not an OBJ_COMMIT; and parse_commit_buffer() would SEGFAULT on
      that NULL pointer.
      
      The fix made by this patch is to not blindly call lookup_blob() in
      reachable.c's add_cache_refs(), and instead skip any index entries that
      are S_ISGITLINK().
      Signed-off-by: default avatarAndy Parkins <andyparkins@gmail.com>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      8d2244ba
  12. 21 Mar, 2007 1 commit
  13. 03 Feb, 2007 1 commit
  14. 09 Jan, 2007 1 commit
    • Johannes Schindelin's avatar
      Sanitize for_each_reflog_ent() · 883d60fa
      Johannes Schindelin authored
      It used to ignore the return value of the helper function; now, it
      expects it to return 0, and stops iteration upon non-zero return
      values; this value is then passed on as the return value of
      for_each_reflog_ent().
      
      Further, it makes no sense to force the parsing upon the helper
      functions; for_each_reflog_ent() now calls the helper function with
      old and new sha1, the email, the timestamp & timezone, and the message.
      Signed-off-by: Johannes Schindelin's avatarJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: default avatarJunio C Hamano <junkio@cox.net>
      883d60fa
  15. 07 Jan, 2007 3 commits
  16. 05 Jan, 2007 1 commit
    • Junio C Hamano's avatar
      builtin-prune: memory diet. · 16157b80
      Junio C Hamano authored
      Somehow we forgot to turn save_commit_buffer off while walking
      the reachable objects.  Releasing the memory for commit object
      data that we do not use matters for large projects (for example,
      about 90MB is saved while traversing linux-2.6 history).
      Signed-off-by: default avatarJunio C Hamano <junkio@cox.net>
      16157b80
  17. 21 Dec, 2006 1 commit
  18. 24 Nov, 2006 1 commit
  19. 22 Nov, 2006 1 commit
    • Andy Parkins's avatar
      Improve git-prune -n output · 21f88ac8
      Andy Parkins authored
      prune_object() in show_only mode would previously just show the path to the
      object that would be deleted.  The path the object is stored in shouldn't be
      shown to users, they only know about sha1 identifiers so show that instead.
      
      Further, the sha1 alone isn't that useful for examining what is going to be
      deleted.  This patch also adds the object type to the output, which makes it
      easy to pick out, say, the commits and use git-show to display them.
      Signed-off-by: default avatarAndy Parkins <andyparkins@gmail.com>
      Signed-off-by: default avatarJunio C Hamano <junkio@cox.net>
      21f88ac8
  20. 22 Oct, 2006 1 commit
    • J. Bruce Fields's avatar
      Make prune also run prune-packed · 2eb53e65
      J. Bruce Fields authored
      Both the git-prune manpage and everday.txt say that git-prune should also prune
      unpacked objects that are also found in packs, by running git prune-packed.
      
      Junio thought this was "a regression when prune was rewritten as a built-in."
      
      So modify prune to call prune-packed again.
      Signed-off-by: default avatarJ. Bruce Fields <bfields@citi.umich.edu>
      2eb53e65
  21. 21 Sep, 2006 2 commits
    • Junio C Hamano's avatar
      Tell between packed, unpacked and symbolic refs. · 8da19775
      Junio C Hamano authored
      This adds a "int *flag" parameter to resolve_ref() and makes
      for_each_ref() family to call callback function with an extra
      "int flag" parameter.  They are used to give two bits of
      information (REF_ISSYMREF and REF_ISPACKED) about the ref.
      Signed-off-by: default avatarJunio C Hamano <junkio@cox.net>
      8da19775
    • Junio C Hamano's avatar
      Add callback data to for_each_ref() family. · cb5d709f
      Junio C Hamano authored
      This is a long overdue fix to the API for for_each_ref() family
      of functions.  It allows the callers to specify a callback data
      pointer, so that the caller does not have to use static
      variables to communicate with the callback funciton.
      
      The updated for_each_ref() family takes a function of type
      
      	int (*fn)(const char *, const unsigned char *, void *)
      
      and a void pointer as parameters, and calls the function with
      the name of the ref and its SHA-1 with the caller-supplied void
      pointer as parameters.
      
      The commit updates two callers, builtin-name-rev.c and
      builtin-pack-refs.c as an example.
      Signed-off-by: default avatarJunio C Hamano <junkio@cox.net>
      cb5d709f
  22. 02 Sep, 2006 1 commit
    • Shawn Pearce's avatar
      Replace uses of strdup with xstrdup. · 9befac47
      Shawn Pearce authored
      Like xmalloc and xrealloc xstrdup dies with a useful message if
      the native strdup() implementation returns NULL rather than a
      valid pointer.
      
      I just tried to use xstrdup in new code and found it to be missing.
      However I expected it to be present as xmalloc and xrealloc are
      already commonly used throughout the code.
      
      [jc: removed the part that deals with last_XXX, which I am
       finding more and more dubious these days.]
      Signed-off-by: default avatarShawn O. Pearce <spearce@spearce.org>
      Signed-off-by: default avatarJunio C Hamano <junkio@cox.net>
      9befac47
  23. 16 Aug, 2006 1 commit
  24. 04 Aug, 2006 1 commit
  25. 29 Jul, 2006 2 commits
  26. 14 Jul, 2006 1 commit
  27. 09 Jul, 2006 1 commit
    • Linus Torvalds's avatar
      builtin "git prune" · ba84a797
      Linus Torvalds authored
      This actually removes the objects to be pruned, unless you specify "-n"
      (at which point it will just tell you which files it would prune).
      
      This doesn't do the pack-file pruning that the shell-script used to do,
      but if somebody really wants to, they could add it easily enough. I wonder
      how useful it is, though, considering that "git repack -a -d" is just a
      lot more efficient and generates a better end result.
      Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
      Signed-off-by: default avatarJunio C Hamano <junkio@cox.net>
      ba84a797