1. 23 2月, 2008 1 次提交
    • L
      Fix name re-hashing semantics · a22c6371
      Linus Torvalds 提交于
      We handled the case of removing and re-inserting cache entries badly,
      which is something that merging commonly needs to do (removing the
      different stages, and then re-inserting one of them as the merged
      state).
      
      We even had a rather ugly special case for this failure case, where
      replace_index_entry() basically turned itself into a no-op if the new
      and the old entries were the same, exactly because the hash routines
      didn't handle it on their own.
      
      So what this patch does is to not just have the UNHASHED bit, but a
      HASHED bit too, and when you insert an entry into the name hash, that
      involves:
      
       - clear the UNHASHED bit, because now it's valid again for lookup
         (which is really all that UNHASHED meant)
      
       - if we're being lazy, we're done here (but we still want to clear the
         UNHASHED bit regardless of lazy mode, since we can become unlazy
         later, and so we need the UNHASHED bit to always be set correctly,
         even if we never actually insert the entry into the hash list)
      
       - if it was already hashed, we just leave it on the list
      
       - otherwise mark it HASHED and insert it into the list
      
      this all means that unhashing and rehashing a name all just works
      automatically.  Obviously, you cannot change the name of an entry (that
      would be a serious bug), but nothing can validly do that anyway (you'd
      have to allocate a new struct cache_entry anyway since the name length
      could change), so that's not a new limitation.
      
      The code actually gets simpler in many ways, although the lazy hashing
      does mean that there are a few odd cases (ie something can be marked
      unhashed even though it was never on the hash in the first place, and
      isn't actually marked hashed!).
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      a22c6371
  2. 23 1月, 2008 4 次提交
    • J
      lazy index hashing · 9cb76b8c
      Junio C Hamano 提交于
      This delays the hashing of index names until it becomes necessary for
      the first time.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      9cb76b8c
    • L
      Create pathname-based hash-table lookup into index · cf558704
      Linus Torvalds 提交于
      This creates a hash index of every single file added to the index.
      Right now that hash index isn't actually used for much: I implemented a
      "cache_name_exists()" function that uses it to efficiently look up a
      filename in the index without having to do the O(logn) binary search,
      but quite frankly, that's not why this patch is interesting.
      
      No, the whole and only reason to create the hash of the filenames in the
      index is that by modifying the hash function, you can fairly easily do
      things like making it always hash equivalent names into the same bucket.
      
      That, in turn, means that suddenly questions like "does this name exist
      in the index under an _equivalent_ name?" becomes much much cheaper.
      
      Guiding principles behind this patch:
      
       - it shouldn't be too costly. In fact, my primary goal here was to
         actually speed up "git commit" with a fully populated kernel tree, by
         being faster at checking whether a file already existed in the index. I
         did succeed, but only barely:
      
      	Best before:
      		[torvalds@woody linux]$ time git commit > /dev/null
      		real    0m0.255s
      		user    0m0.168s
      		sys     0m0.088s
      
      	Best after:
      
      		[torvalds@woody linux]$ time ~/git/git commit > /dev/null
      		real    0m0.233s
      		user    0m0.144s
      		sys     0m0.088s
      
         so some things are actually faster (~8%).
      
         Caveat: that's really the best case. Other things are invariably going
         to be slightly slower, since we populate that index cache, and quite
         frankly, few things really use it to look things up.
      
         That said, the cost is really quite small. The worst case is probably
         doing a "git ls-files", which will do very little except puopulate the
         index, and never actually looks anything up in it, just lists it.
      
      	Before:
      		[torvalds@woody linux]$ time git ls-files > /dev/null
      		real    0m0.016s
      		user    0m0.016s
      		sys     0m0.000s
      
      	After:
      		[torvalds@woody linux]$ time ~/git/git ls-files > /dev/null
      		real    0m0.021s
      		user    0m0.012s
      		sys     0m0.008s
      
         and while the thing has really gotten relatively much slower, we're
         still talking about something almost unmeasurable (eg 5ms). And that
         really should be pretty much the worst case.
      
         So we lose 5ms on one "benchmark", but win 22ms on another. Pick your
         poison - this patch has the advantage that it will _likely_ speed up
         the cases that are complex and expensive more than it slows down the
         cases that are already so fast that nobody cares. But if you look at
         relative speedups/slowdowns, it doesn't look so good.
      
       - It should be simple and clean
      
         The code may be a bit subtle (the reasons I do hash removal the way I
         do etc), but it re-uses the existing hash.c files, so it really is
         fairly small and straightforward apart from a few odd details.
      
      Now, this patch on its own doesn't really do much, but I think it's worth
      looking at, if only because if done correctly, the name hashing really can
      make an improvement to the whole issue of "do we have a filename that
      looks like this in the index already". And at least it gets real testing
      by being used even by default (ie there is a real use-case for it even
      without any insane filesystems).
      
      NOTE NOTE NOTE! The current hash is a joke. I'm ashamed of it, I'm just
      not ashamed of it enough to really care. I took all the numbers out of my
      nether regions - I'm sure it's good enough that it works in practice, but
      the whole point was that you can make a really much fancier hash that
      hashes characters not directly, but by their upper-case value or something
      like that, and thus you get a case-insensitive hash, while still keeping
      the name and the index itself totally case sensitive.
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      cf558704
    • J
      read-cache.c: introduce is_racy_timestamp() helper · 6d91da6d
      Junio C Hamano 提交于
      This moves a common boolean expression into a helper function,
      and makes the comparison between filesystem timestamp and index
      timestamp done in the function in line with the other places.
      st.st_mtime should be casted to (unsigned int) when compared to
      an index timestamp ce_mtime.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      6d91da6d
    • J
      read-cache.c: fix a couple more CE_REMOVE conversion · 077c48df
      Junio C Hamano 提交于
      It is a D/F conflict if you want to add "foo/bar" to the index
      when "foo" already exists.  Also it is a conflict if you want to
      add a file "foo" when "foo/bar" exists.
      
      An exception is when the existing entry is there only to mark "I
      used to be here but I am being removed".  This is needed for
      operations such as "git read-tree -m -u" that update the index
      and then reflect the result to the work tree --- we need to
      remember what to remove somewhere, and we use the index for
      that.  In such a case, an existing file "foo" is being removed
      and we can create "foo/" directory and hang "bar" underneath it
      without any conflict.
      
      We used to use (ce->ce_mode == 0) to mark an entry that is being
      removed, but (CE_REMOVE & ce->ce_flags) is used for that purpose
      these days.  An earlier commit forgot to convert the logic in
      the code that checks D/F conflict condition.
      
      The old code knew that "to be removed" entries cannot be at
      higher stage and actively checked that condition, but it was an
      unnecessary check.  This patch removes the extra check as well.
      Acked-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      077c48df
  3. 22 1月, 2008 3 次提交
    • J
      Avoid running lstat(2) on the same cache entry. · eadb5831
      Junio C Hamano 提交于
      Aside from the lstat(2) done for work tree files, there are
      quite many lstat(2) calls in refname dwimming codepath.  This
      patch is not about reducing them.
      
       * It adds a new ce_flag, CE_UPTODATE, that is meant to mark the
         cache entries that record a regular file blob that is up to
         date in the work tree.  If somebody later walks the index and
         wants to see if the work tree has changes, they do not have
         to be checked with lstat(2) again.
      
       * fill_stat_cache_info() marks the cache entry it just added
         with CE_UPTODATE.  This has the effect of marking the paths
         we write out of the index and lstat(2) immediately as "no
         need to lstat -- we know it is up-to-date", from quite a lot
         fo callers:
      
          - git-apply --index
          - git-update-index
          - git-checkout-index
          - git-add (uses add_file_to_index())
          - git-commit (ditto)
          - git-mv (ditto)
      
       * refresh_cache_ent() also marks the cache entry that are clean
         with CE_UPTODATE.
      
       * write_index is changed not to write CE_UPTODATE out to the
         index file, because CE_UPTODATE is meant to be transient only
         in core.  For the same reason, CE_UPDATE is not written to
         prevent an accident from happening.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      eadb5831
    • J
      index: be careful when handling long names · 7fec10b7
      Junio C Hamano 提交于
      We currently use lower 12-bit (masked with CE_NAMEMASK) in the
      ce_flags field to store the length of the name in cache_entry,
      without checking the length parameter given to
      create_ce_flags().  This can make us store incorrect length.
      
      Currently we are mostly protected by the fact that many
      codepaths first copy the path in a variable of size PATH_MAX,
      which typically is 4096 that happens to match the limit, but
      that feels like a bug waiting to happen.  Besides, that would
      not allow us to shorten the width of CE_NAMEMASK to use the bits
      for new flags.
      
      This redefines the meaning of the name length stored in the
      cache_entry.  A name that does not fit is represented by storing
      CE_NAMEMASK in the field, and the actual length needs to be
      computed by actually counting the bytes in the name[] field.
      This way, only the unusually long paths need to suffer.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      7fec10b7
    • L
      Make on-disk index representation separate from in-core one · 7a51ed66
      Linus Torvalds 提交于
      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: NLinus Torvalds <torvalds@linux-foundation.org>
      7a51ed66
  4. 10 11月, 2007 2 次提交
    • J
      git-add: make the entry stat-clean after re-adding the same contents · fb63d7f8
      Junio C Hamano 提交于
      Earlier in commit 0781b8a9
      (add_file_to_index: skip rehashing if the cached stat already
      matches), add_file_to_index() were taught not to re-add the path
      if it already matches the index.
      
      The change meant well, but was not executed quite right.  It
      used ie_modified() to see if the file on the work tree is really
      different from the index, and skipped adding the contents if the
      function says "not modified".
      
      This was wrong.  There are three possible comparison results
      between the index and the file in the work tree:
      
       - with lstat(2) we _know_ they are different.  E.g. if the
         length or the owner in the cached stat information is
         different from the length we just obtained from lstat(2), we
         can tell the file is modified without looking at the actual
         contents.
      
       - with lstat(2) we _know_ they are the same.  The same length,
         the same owner, the same everything (but this has a twist, as
         described below).
      
       - we cannot tell from lstat(2) information alone and need to go
         to the filesystem to actually compare.
      
      The last case arises from what we call 'racy git' situation,
      that can be caused with this sequence:
      
          $ echo hello >file
          $ git add file
          $ echo aeiou >file ;# the same length
      
      If the second "echo" is done within the same filesystem
      timestamp granularity as the first "echo", then the timestamp
      recorded by "git add" and the timestamp we get from lstat(2)
      will be the same, and we can mistakenly say the file is not
      modified.  The path is called 'racily clean'.  We need to
      reliably detect racily clean paths are in fact modified.
      
      To solve this problem, when we write out the index, we mark the
      index entry that has the same timestamp as the index file itself
      (that is the time from the point of view of the filesystem) to
      tell any later code that does the lstat(2) comparison not to
      trust the cached stat info, and ie_modified() then actually goes
      to the filesystem to compare the contents for such a path.
      
      That's all good, but it should not be used for this "git add"
      optimization, as the goal of "git add" is to actually update the
      path in the index and make it stat-clean.  With the false
      optimization, we did _not_ cause any data loss (after all, what
      we failed to do was only to update the cached stat information),
      but it made the following sequence leave the file stat dirty:
      
          $ echo hello >file
          $ git add file
          $ echo hello >file ;# the same contents
          $ git add file
      
      The solution is not to use ie_modified() which goes to the
      filesystem to see if it is really clean, but instead use
      ie_match_stat() with "assume racily clean paths are dirty"
      option, to force re-adding of such a path.
      
      There was another problem with "git add -u".  The codepath
      shares the same issue when adding the paths that are found to be
      modified, but in addition, it asked "git diff-files" machinery
      run_diff_files() function (which is "git diff-files") to list
      the paths that are modified.  But "git diff-files" machinery
      uses the same ie_modified() call so that it does not report
      racily clean _and_ actually clean paths as modified, which is
      not what we want.
      
      The patch allows the callers of run_diff_files() to pass the
      same "assume racily clean paths are dirty" option, and makes
      "git-add -u" codepath to use that option, to discover and re-add
      racily clean _and_ actually clean paths.
      
      We could further optimize on top of this patch to differentiate
      the case where the path really needs re-adding (i.e. the content
      of the racily clean entry was indeed different) and the case
      where only the cached stat information needs to be refreshed
      (i.e. the racily clean entry was actually clean), but I do not
      think it is worth it.
      
      This patch applies to maint and all the way up.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      fb63d7f8
    • J
      ce_match_stat, run_diff_files: use symbolic constants for readability · 4bd5b7da
      Junio C Hamano 提交于
      ce_match_stat() can be told:
      
       (1) to ignore CE_VALID bit (used under "assume unchanged" mode)
           and perform the stat comparison anyway;
      
       (2) not to perform the contents comparison for racily clean
           entries and report mismatch of cached stat information;
      
      using its "option" parameter.  Give them symbolic constants.
      
      Similarly, run_diff_files() can be told not to report anything
      on removed paths.  Also give it a symbolic constant for that.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      4bd5b7da
  5. 18 10月, 2007 1 次提交
    • L
      git-blame shouldn't crash if run in an unmerged tree · cd8ae201
      Linus Torvalds 提交于
      If we are in the middle of resolving a merge conflict there may be
      one or more files whose entries in the index represent an unmerged
      state (index entries in the higher-order stages).
      
      Attempting to run git-blame on any file in such a working directory
      resulted in "fatal: internal error: ce_mode is 0" as we use the magic
      marker for an unmerged entry is 0 (set up by things like diff-lib.c's
      do_diff_cache() and builtin-read-tree.c's read_tree_unmerged())
      and the ce_match_stat_basic() function gets upset about this.
      
      I'm not entirely sure that the whole "ce_mode = 0" case is a good
      idea to begin with, and maybe the right thing to do is to remove
      that horrid freakish special case, but removing the internal error
      seems to be the simplest fix for now.
      
                      Linus
      
      [sp: Thanks to Björn Steinbrink for the test case]
      Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
      cd8ae201
  6. 27 9月, 2007 1 次提交
  7. 26 9月, 2007 1 次提交
  8. 14 9月, 2007 1 次提交
    • J
      Simplify cache API · 09d5dc32
      Junio C Hamano 提交于
      Earlier, add_file_to_index() invalidated the path in the cache-tree
      but remove_file_from_cache() did not, and the user of the latter
      needed to invalidate the entry himself.  This led to a few bugs due to
      missed invalidate calls already.  This patch makes the management of
      cache-tree less error prone by making more invalidate calls from lower
      level cache API functions.
      
      The rules are:
      
       - If you are going to write the index, you should either maintain
         cache_tree correctly.
      
         - If you cannot, alternatively you can remove the entire cache_tree
           by calling cache_tree_free() before you call write_cache().
      
         - When you modify the index, cache_tree_invalidate_path() should be
           called with the path you are modifying, to discard the entry from
           the cache-tree structure.
      
       - The following cache API functions exported from read-cache.c (and
         the macro whose names have "cache" instead of "index")
         automatically call cache_tree_invalidate_path() for you:
      
         - remove_file_from_index();
         - add_file_to_index();
         - add_index_entry();
      
         You can modify the index bypassing the above API functions
         (e.g. find an existing cache entry from the index and modify it in
         place).  You need to call cache_tree_invalidate_path() yourself in
         such a case.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      09d5dc32
  9. 13 9月, 2007 1 次提交
  10. 14 8月, 2007 1 次提交
  11. 11 8月, 2007 1 次提交
    • J
      Optimize "diff --cached" performance. · af3785dc
      Junio C Hamano 提交于
      The read_tree() function is called only from the call chain to
      run "git diff --cached" (this includes the internal call made by
      git-runstatus to run_diff_index()).  The function vacates stage
      without any funky "merge" magic.  The caller then goes and
      compares stage #1 entries from the tree with stage #0 entries
      from the original index.
      
      When adding the cache entries this way, it used the general
      purpose add_cache_entry().  This function looks for an existing
      entry to replace or if there is none to find where to insert the
      new entry, resolves D/F conflict and all the other things.
      
      For the purpose of reading entries into an empty stage, none of
      that processing is needed.  We can instead append everything and
      then sort the result at the end.
      
      This commit changes read_tree() to first make sure that there is
      no existing cache entries at specified stage, and if that is the
      case, it runs add_cache_entry() with ADD_CACHE_JUST_APPEND flag
      (new), and then sort the resulting cache using qsort().
      
      This new flag tells add_cache_entry() to omit all the checks
      such as "Does this path already exist?  Does adding this path
      remove other existing entries because it turns a directory to a
      file?" and instead append the given cache entry straight at the
      end of the active cache.  The caller of course is expected to
      sort the resulting cache at the end before using the result.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      af3785dc
  12. 31 7月, 2007 1 次提交
  13. 02 7月, 2007 1 次提交
  14. 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
  15. 22 5月, 2007 1 次提交
  16. 26 4月, 2007 1 次提交
  17. 23 4月, 2007 2 次提交
    • J
      Make read-cache.c "the_index" free. · 4aab5b46
      Junio C Hamano 提交于
      This makes all low-level functions defined in read-cache.c to
      take an explicit index_state structure as their first parameter,
      to specify which index to work on.  These functions
      traditionally operated on "the_index" and were named foo_cache();
      the counterparts this patch introduces are called foo_index().
      
      The traditional foo_cache() functions are made into macros that
      give "the_index" to their corresponding foo_index() functions.
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      4aab5b46
    • J
      Move index-related variables into a structure. · 228e94f9
      Junio C Hamano 提交于
      This defines a index_state structure and moves index-related
      global variables into it.  Currently there is one instance of
      it, the_index, and everybody accesses it, so there is no code
      change.
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      228e94f9
  18. 14 4月, 2007 1 次提交
    • L
      Fix gitlink index entry filesystem matching · a8ee75bc
      Linus Torvalds 提交于
      The code to match up index entries with the filesystem was stupidly
      broken.  We shouldn't compare the filesystem stat() information with
      S_IFDIRLNK, since that's purely a git-internal value, and not what the
      filesystem uses (on the filesystem, it's just a regular directory).
      
      Also, don't bother to make the stat() time comparisons etc for DIRLNK
      entries in ce_match_stat_basic(), since we do an exact match for these
      things, and the hints in the stat data simply doesn't matter.
      
      This fixes "git status" with submodules that haven't been checked out in
      the supermodule.
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      a8ee75bc
  19. 12 4月, 2007 2 次提交
    • L
      Teach directory traversal about subprojects · 09595258
      Linus Torvalds 提交于
      This is the promised cleaned-up version of teaching directory traversal
      (ie the "read_directory()" logic) about subprojects. That makes "git add"
      understand to add/update subprojects.
      
      It now knows to look at the index file to see if a directory is marked as
      a subproject, and use that as information as whether it should be recursed
      into or not.
      
      It also generally cleans up the handling of directory entries when
      traversing the working tree, by splitting up the decision-making process
      into small functions of their own, and adding a fair number of comments.
      
      Finally, it teaches "add_file_to_cache()" that directory names can have
      slashes at the end, since the directory traversal adds them to make the
      difference between a file and a directory clear (it always did that, but
      my previous too-ugly-to-apply subproject patch had a totally different
      path for subproject directories and avoided the slash for that case).
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      09595258
    • L
      Fix thinko in subproject entry sorting · 1833a925
      Linus Torvalds 提交于
      This fixes a total thinko in my original series: subprojects do *not* sort
      like directories, because the index is sorted purely by full pathname, and
      since a subproject shows up in the index as a normal NUL-terminated
      string, it never has the issues with sorting with the '/' at the end.
      
      So if you have a subproject "proj" and a file "proj.c", the subproject
      sorts alphabetically before the file in the index (and must thus also sort
      that way in a tree object, since trees sort as the index).
      
      In contrast, it you have two files "proj/file" and "proj.c", the "proj.c"
      will sort alphabetically before "proj/file" in the index. The index
      itself, of course, does not actually contain an entry "proj/", but in the
      *tree* that gets written out, the tree entry "proj" will sort after the
      file entry "proj.c", which is the only real magic sorting rule.
      
      In other words: the magic sorting rule only affects tree entries, and
      *only* affects tree entries that point to other trees (ie are of the type
      S_IFDIR).
      
      Anyway, that thinko just means that we should remove the special case to
      make S_ISDIRLNK entries sort like S_ISDIR entries. They don't.  They sort
      like normal files.
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      1833a925
  20. 11 4月, 2007 1 次提交
  21. 06 4月, 2007 3 次提交
    • J
      Rename add_file_to_index() to add_file_to_cache() · fd1c3bf0
      Junio C Hamano 提交于
      This function was not called "add_file_to_cache()" only because
      an ancient program, update-cache, used that name as an internal
      function name that does something slightly different.  Now that
      is gone, we can take over the better name.
      
      The plan is to name all functions that operate on the default
      index xxx_cache().  Later patches create a variant of them that
      take an explicit parameter xxx_index(), and then turn
      xxx_cache() functions into macros that use "the_index".
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      fd1c3bf0
    • J
      Propagate cache error internal to refresh_cache() via parameter. · ec0cc704
      Junio C Hamano 提交于
      The function refresh_cache() is the only user of cache_errno
      that switches its behaviour based on what internal function
      refresh_cache_entry() finds; pass the error status back in a
      parameter passed down to it, to get rid of the global variable
      cache_errno.
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      ec0cc704
    • J
      Fix bogus error message from merge-recursive error path · 0424138d
      Junio C Hamano 提交于
      This error message should not usually trigger, but the function
      make_cache_entry() called by add_cacheinfo() can return early
      without calling into refresh_cache_entry() that sets cache_errno.
      
      Also the error message had a wrong function name reported, and
      it did not say anything about which path failed either.
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      0424138d
  22. 04 4月, 2007 1 次提交
  23. 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
  24. 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
  25. 01 3月, 2007 2 次提交
  26. 27 2月, 2007 1 次提交
    • N
      convert object type handling from a string to a number · 21666f1a
      Nicolas Pitre 提交于
      We currently have two parallel notation for dealing with object types
      in the code: a string and a numerical value.  One of them is obviously
      redundent, and the most used one requires more stack space and a bunch
      of strcmp() all over the place.
      
      This is an initial step for the removal of the version using a char array
      found in object reading code paths.  The patch is unfortunately large but
      there is no sane way to split it in smaller parts without breaking the
      system.
      Signed-off-by: NNicolas Pitre <nico@cam.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      21666f1a
  27. 17 2月, 2007 1 次提交
    • J
      Do not take mode bits from index after type change. · 185c975f
      Junio C Hamano 提交于
      When we do not trust executable bit from lstat(2), we copied
      existing ce_mode bits without checking if the filesystem object
      is a regular file (which is the only thing we apply the "trust
      executable bit" business) nor if the blob in the index is a
      regular file (otherwise, we should do the same as registering a
      new regular file, which is to default non-executable).
      
      Noticed by Johannes Sixt.
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      185c975f
  28. 12 1月, 2007 1 次提交
  29. 09 1月, 2007 1 次提交