1. 14 6月, 2014 19 次提交
  2. 04 3月, 2014 1 次提交
  3. 25 2月, 2014 5 次提交
  4. 06 2月, 2014 1 次提交
  5. 24 1月, 2014 1 次提交
    • J
      read-cache: use get_be32 instead of hand-rolled ntoh_l · c3d8da57
      Jeff King 提交于
      Commit d60c49c2 (read-cache.c: allow unaligned mapping of the
      index file, 2012-04-03) introduced helpers to access
      unaligned data. However, we already have get_be32, which has
      a few advantages:
      
        1. It's already written, so we avoid duplication.
      
        2. It's probably faster, since it does the endian
           conversion and the alignment fix at the same time.
      
        3. The get_be32 code is well-tested, having been in
           block-sha1 for a long time. By contrast, our custom
           helpers were probably almost never used, since the user
           needed to manually define a macro to enable them.
      
      We have to add a get_be16 implementation to the existing
      get_be32, but that is very simple to do.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c3d8da57
  6. 19 11月, 2013 2 次提交
    • K
      read-cache.c: fix memory leaks caused by removed cache entries · 5699d17e
      Karsten Blees 提交于
      When cache_entry structs are removed from index_state.cache, they are not
      properly freed. Freeing those entries wasn't possible before because we
      couldn't remove them from index_state.name_hash.
      
      Now that we _do_ remove the entries from name_hash, we can also free them.
      Add 'free(cache_entry)' to all call sites of name-hash.c::remove_name_hash
      in read-cache.c (we could free() directly in remove_name_hash(), but
      name-hash.c isn't concerned with cache_entry allocation at all).
      
      Accessing a cache_entry after removing it from the index is now no longer
      allowed, as the memory has been freed. The following functions need minor
      fixes (typically by copying ce->name before use):
       - builtin/rm.c::cmd_rm
       - builtin/update-index.c::do_reupdate
       - read-cache.c::read_index_unmerged
       - resolve-undo.c::unmerge_index_entry_at
      Signed-off-by: NKarsten Blees <blees@dcon.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      5699d17e
    • K
      name-hash.c: remove cache entries instead of marking them CE_UNHASHED · 419a597f
      Karsten Blees 提交于
      The new hashmap implementation supports remove, so really remove unused
      cache entries from the name hashmap instead of just marking them.
      
      The CE_UNHASHED flag and CE_STATE_MASK are no longer needed.
      
      Keep the CE_HASHED flag to prevent adding entries twice.
      Signed-off-by: NKarsten Blees <blees@dcon.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      419a597f
  7. 18 9月, 2013 2 次提交
    • E
      name-hash: stop storing trailing '/' on paths in index_state.dir_hash · d28eec26
      Eric Sunshine 提交于
      When 5102c617 (Add case insensitivity support for directories when using
      git status, 2010-10-03) added directories to the name-hash there was
      only a single hash table in which both real cache entries and leading
      directory prefixes were registered. To distinguish between the two types
      of entries, directories were stored with a trailing '/'.
      
      2092678c (name-hash.c: fix endless loop with core.ignorecase=true,
      2013-02-28), however, moved directories to a separate hash table
      (index_state.dir_hash) but retained the (now) redundant trailing '/',
      thus callers continue to bear the burden of ensuring the slash's
      presence before searching the index for a directory. Eliminate this
      redundancy by storing paths in the dir-hash without the trailing '/'.
      
      An important benefit of this change is that it eliminates undocumented
      and dangerous behavior of dir.c:directory_exists_in_index_icase() in
      which it assumes not only that it can validly access one character
      beyond the end of its incoming directory argument, but also that that
      character will unconditionally be a '/'. This perilous behavior was
      "tolerated" because the string passed in by its lone caller always had a
      '/' in that position, however, things broke [1] when 2eac2a4c (ls-files
      -k: a directory only can be killed if the index has a non-directory,
      2013-08-15) added a new caller which failed to respect the undocumented
      assumption.
      
      [1]: http://thread.gmane.org/gmane.comp.version-control.git/232727Signed-off-by: NEric Sunshine <sunshine@sunshineco.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      d28eec26
    • E
      employ new explicit "exists in index?" API · ebbd7439
      Eric Sunshine 提交于
      Each caller of index_name_exists() knows whether it is looking for a
      directory or a file, and can avoid the unnecessary indirection of
      index_name_exists() by instead calling index_dir_exists() or
      index_file_exists() directly.
      
      Invoking the appropriate search function explicitly will allow a
      subsequent patch to relieve callers of the artificial burden of having
      to add a trailing '/' to the pathname given to index_dir_exists().
      Signed-off-by: NEric Sunshine <sunshine@sunshineco.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ebbd7439
  8. 29 8月, 2013 1 次提交
    • J
      write_index: optionally allow broken null sha1s · 83bd7437
      Jeff King 提交于
      Commit 4337b585 (do not write null sha1s to on-disk index,
      2012-07-28) added a safety check preventing git from writing
      null sha1s into the index. The intent was to catch errors in
      other parts of the code that might let such an entry slip
      into the index (or worse, a tree).
      
      Some existing repositories may have invalid trees that
      contain null sha1s already, though.  Until 4337b585, a common
      way to clean this up would be to use git-filter-branch's
      index-filter to repair such broken entries.  That now fails
      when filter-branch tries to write out the index.
      
      Introduce a GIT_ALLOW_NULL_SHA1 environment variable to
      relax this check and make it easier to recover from such a
      history.
      
      It is tempting to not involve filter-branch in this commit
      at all, and instead require the user to manually invoke
      
      	GIT_ALLOW_NULL_SHA1=1 git filter-branch ...
      
      to perform an index-filter on a history with trees with null
      sha1s.  That would be slightly safer, but requires some
      specialized knowledge from the user.  So let's set the
      GIT_ALLOW_NULL_SHA1 variable automatically when checking out
      the to-be-filtered trees.  Advice on using filter-branch to
      remove such entries already exists on places like
      stackoverflow, and this patch makes it Just Work again on
      recent versions of git.
      
      Further commands that touch the index will still notice and
      fail, unless they actually remove the broken entries.  A
      filter-branch whose filters do not touch the index at all
      will not error out (since we complain of the null sha1 only
      on writing, not when making a tree out of the index), but
      this is acceptable, as we still print a loud warning, so the
      problem is unlikely to go unnoticed.
      Signed-off-by: NJeff King <peff@peff.net>
      Reviewed-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      83bd7437
  9. 21 8月, 2013 1 次提交
  10. 30 7月, 2013 1 次提交
  11. 16 7月, 2013 1 次提交
  12. 10 7月, 2013 1 次提交
    • N
      Convert "struct cache_entry *" to "const ..." wherever possible · 9c5e6c80
      Nguyễn Thái Ngọc Duy 提交于
      I attempted to make index_state->cache[] a "const struct cache_entry **"
      to find out how existing entries in index are modified and where. The
      question I have is what do we do if we really need to keep track of on-disk
      changes in the index. The result is
      
       - diff-lib.c: setting CE_UPTODATE
      
       - name-hash.c: setting CE_HASHED
      
       - preload-index.c, read-cache.c, unpack-trees.c and
         builtin/update-index: obvious
      
       - entry.c: write_entry() may refresh the checked out entry via
         fill_stat_cache_info(). This causes "non-const struct cache_entry
         *" in builtin/apply.c, builtin/checkout-index.c and
         builtin/checkout.c
      
       - builtin/ls-files.c: --with-tree changes stagemask and may set
         CE_UPDATE
      
      Of these, write_entry() and its call sites are probably most
      interesting because it modifies on-disk info. But this is stat info
      and can be retrieved via refresh, at least for porcelain
      commands. Other just uses ce_flags for local purposes.
      
      So, keeping track of "dirty" entries is just a matter of setting a
      flag in index modification functions exposed by read-cache.c. Except
      unpack-trees, the rest of the code base does not do anything funny
      behind read-cache's back.
      
      The actual patch is less valueable than the summary above. But if
      anyone wants to re-identify the above sites. Applying this patch, then
      this:
      
          diff --git a/cache.h b/cache.h
          index 430d021..1692891 100644
          --- a/cache.h
          +++ b/cache.h
          @@ -267,7 +267,7 @@ static inline unsigned int canon_mode(unsigned int mode)
           #define cache_entry_size(len) (offsetof(struct cache_entry,name) + (len) + 1)
      
           struct index_state {
          -	struct cache_entry **cache;
          +	const struct cache_entry **cache;
           	unsigned int version;
           	unsigned int cache_nr, cache_alloc, cache_changed;
           	struct string_list *resolve_undo;
      
      will help quickly identify them without bogus warnings.
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      9c5e6c80
  13. 21 6月, 2013 2 次提交
  14. 10 6月, 2013 1 次提交
    • R
      read-cache: free cache in discard_index · a0fc4db0
      René Scharfe 提交于
      discard_cache doesn't have to free the array of cache entries, because
      the next call of read_cache can simply reuse it, as they all operate on
      the global variable the_index.
      
      discard_index on the other hand does have to free it, because it can be
      used e.g. with index_state variables on the stack, in which case a
      missing free would cause an unrecoverable leak.  This patch releases the
      memory and removes a comment that was relevant for discard_cache but has
      become outdated.
      
      Since discard_cache is just a wrapper around discard_index nowadays, we
      lose the optimization that avoids reallocation of that array within
      loops of read_cache and discard_cache.  That doesn't cause a performance
      regression for me, however (HEAD = this patch, HEAD^ = master + p0002):
      
        Test           //              HEAD^             HEAD
        ---------------\\-----------------------------------------------------
        0002.1: read_ca// 1000 times   0.62(0.58+0.04)   0.61(0.58+0.02) -1.6%
      Suggested-by: NFelipe Contreras <felipe.contreras@gmail.com>
      Signed-off-by: NRené Scharfe <rene.scharfe@lsrfire.ath.cx>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      a0fc4db0
  15. 04 6月, 2013 1 次提交