1. 22 3月, 2007 1 次提交
  2. 21 2月, 2007 1 次提交
    • J
      Mechanical conversion to use prefixcmp() · cc44c765
      Junio C Hamano 提交于
      This mechanically converts strncmp() to use prefixcmp(), but only when
      the parameters match specific patterns, so that they can be verified
      easily.  Leftover from this will be fixed in a separate step, including
      idiotic conversions like
      
          if (!strncmp("foo", arg, 3))
      
        =>
      
          if (!(-prefixcmp(arg, "foo")))
      
      This was done by using this script in px.perl
      
         #!/usr/bin/perl -i.bak -p
         if (/strncmp\(([^,]+), "([^\\"]*)", (\d+)\)/ && (length($2) == $3)) {
                 s|strncmp\(([^,]+), "([^\\"]*)", (\d+)\)|prefixcmp($1, "$2")|;
         }
         if (/strncmp\("([^\\"]*)", ([^,]+), (\d+)\)/ && (length($1) == $3)) {
                 s|strncmp\("([^\\"]*)", ([^,]+), (\d+)\)|(-prefixcmp($2, "$1"))|;
         }
      
      and running:
      
         $ git grep -l strncmp -- '*.c' | xargs perl px.perl
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      cc44c765
  3. 06 12月, 2006 2 次提交
  4. 24 8月, 2006 1 次提交
    • S
      Convert memcpy(a,b,20) to hashcpy(a,b). · e702496e
      Shawn Pearce 提交于
      This abstracts away the size of the hash values when copying them
      from memory location to memory location, much as the introduction
      of hashcmp abstracted away hash value comparsion.
      
      A few call sites were using char* rather than unsigned char* so
      I added the cast rather than open hashcpy to be void*.  This is a
      reasonable tradeoff as most call sites already use unsigned char*
      and the existing hashcmp is also declared to be unsigned char*.
      
      [jc: Splitted the patch to "master" part, to be followed by a
       patch for merge-recursive.c which is not in "master" yet.
      
       Fixed the cast in the latter hunk to combine-diff.c which was
       wrong in the original.
      
       Also converted ones left-over in combine-diff.c, diff-lib.c and
       upload-pack.c ]
      Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      e702496e
  5. 16 8月, 2006 1 次提交
  6. 13 8月, 2006 1 次提交
    • J
      Better error message when we are unable to lock the index file · 40aaae88
      Junio C Hamano 提交于
      Most of the callers except the one in refs.c use the function to
      update the index file.  Among the index writers, everybody
      except write-tree dies if they cannot open it for writing.
      
      This gives the function an extra argument, to tell it to die
      when it cannot create a new file as the lockfile.
      
      The only caller that does not have to die is write-tree, because
      updating the index for the cache-tree part is optional and not
      being able to do so does not affect the correctness.  I think we
      do not have to be so careful and make the failure into die() the
      same way as other callers, but that would be a different patch.
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      40aaae88
  7. 04 8月, 2006 1 次提交
  8. 31 7月, 2006 2 次提交
  9. 29 7月, 2006 1 次提交
  10. 17 7月, 2006 1 次提交
  11. 10 7月, 2006 1 次提交
    • S
      Avoid C99 initializers · 344c52ae
      Shawn Pearce 提交于
      In a handful places, we use C99 structure and array
      initializers, which some compilers do not support.
      
      This can be handy when you are trying to compile GIT on a
      Solaris system that has an older C compiler, for example.
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      344c52ae
  12. 08 7月, 2006 1 次提交
  13. 19 6月, 2006 1 次提交
  14. 07 6月, 2006 1 次提交
  15. 06 6月, 2006 1 次提交
  16. 04 6月, 2006 2 次提交
    • J
      Fix earlier mismerges. · b266b123
      Junio C Hamano 提交于
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      b266b123
    • J
      read-tree --reset: update working tree file for conflicted paths. · b0d6e646
      Junio C Hamano 提交于
      The earlier "git reset --hard" simplification stopped removing
      leftover working tree files from a failed automerge, when
      switching back to the HEAD version that does not have the
      paths.
      
      This patch, instead of removing the unmerged paths from the
      index, drops them down to stage#0 but marks them with mode=0
      (the same "to be deleted" marker we internally use for paths
      deleted by the merge).  one_way_merge() function and the
      functions it calls already know what to do with them -- if the
      tree we are reading has the path the working tree file is
      overwritten, and if it doesn't the working tree file is
      removed.
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      b0d6e646
  17. 31 5月, 2006 1 次提交
    • L
      tree_entry(): new tree-walking helper function · 4c068a98
      Linus Torvalds 提交于
      This adds a "tree_entry()" function that combines the common operation of
      doing a "tree_entry_extract()" + "update_tree_entry()".
      
      It also has a simplified calling convention, designed for simple loops
      that traverse over a whole tree: the arguments are pointers to the tree
      descriptor and a name_entry structure to fill in, and it returns a boolean
      "true" if there was an entry left to be gotten in the tree.
      
      This allows tree traversal with
      
      	struct tree_desc desc;
      	struct name_entry entry;
      
      	desc.buf = tree->buffer;
      	desc.size = tree->size;
      	while (tree_entry(&desc, &entry) {
      		... use "entry.{path, sha1, mode, pathlen}" ...
      	}
      
      which is not only shorter than writing it out in full, it's hopefully less
      error prone too.
      
      [ It's actually a tad faster too - we don't need to recalculate the entry
        pathlength in both extract and update, but need to do it only once.
        Also, some callers can avoid doing a "strlen()" on the result, since
        it's returned as part of the name_entry structure.
      
        However, by now we're talking just 1% speedup on "git-rev-list --objects
        --all", and we're definitely at the point where tree walking is no
        longer the issue any more. ]
      
      NOTE! Not everybody wants to use this new helper function, since some of
      the tree walkers very much on purpose do the descriptor update separately
      from the entry extraction. So the "extract + update" sequence still
      remains as the core sequence, this is just a simplified interface.
      
      We should probably add a silly two-line inline helper function for
      initializing the descriptor from the "struct tree" too, just to cut down
      on the noise from that common "desc" initializer.
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      4c068a98
  18. 30 5月, 2006 6 次提交
  19. 29 5月, 2006 3 次提交
    • L
      Remove "tree->entries" tree-entry list from tree parser · 097dc3d8
      Linus Torvalds 提交于
      This finally removes the tree-entry list from "struct tree", since most of
      the users can just use the tree-walk infrastructure to walk the raw tree
      buffers instead of the tree-entry list.
      
      The tree-entry list is inefficient, and generates tons of small
      allocations for no good reason. The tree-walk infrastructure is generally
      no harder to use than following a linked list, and allows us to do most
      tree parsing in-place.
      
      Some programs still use the old tree-entry lists, and are a bit painful to
      convert without major surgery. For them we have a helper function that
      creates a temporary tree-entry list on demand. We can convert those too
      eventually, but with this they no longer affect any users who don't need
      the explicit lists.
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      097dc3d8
    • L
      Make "tree_entry" have a SHA1 instead of a union of object pointers · a755dfe4
      Linus Torvalds 提交于
      This is preparatory work for further cleanups, where we try to make
      tree_entry look more like the more efficient tree-walk descriptor.
      
      Instead of having a union of pointers to blob/tree/objects, this just
      makes "struct tree_entry" have the raw SHA1, and makes all the users use
      that instead (often that implies adding a "lookup_tree(..)" on the sha1,
      but sometimes the user just wanted the SHA1 in the first place, and it
      just avoids an unnecessary indirection).
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      a755dfe4
    • L
      Add raw tree buffer info to "struct tree" · d2eafb76
      Linus Torvalds 提交于
      This allows us to avoid allocating information for names etc, because
      we can just use the information from the tree buffer directly.
      
      We still keep the old "tree_entry_list" in struct tree as well, so old
      users aren't affected, apart from the fact that the allocations are
      different (if you free a tree entry, you should no longer free the name
      allocation for it, since it's allocated as part of "tree->buffer")
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      d2eafb76
  20. 24 5月, 2006 1 次提交
  21. 17 5月, 2006 2 次提交
  22. 16 5月, 2006 1 次提交
  23. 15 5月, 2006 2 次提交
    • J
      read-tree -u one-way merge fix to check out locally modified paths. · 613f0273
      Junio C Hamano 提交于
      The "-u" flag means "update the working tree files", but to
      other types of merges, it also implies "I want to keep my local
      changes" -- because they prevent local changes from getting lost
      by using verify_uptodate.  The one-way merge is different from
      other merges in that its purpose is opposite of doing something
      else while keeping unrelated local changes.  The point of
      one-way merge is to nuke local changes.  So while it feels
      somewhat wrong that this actively loses local changes, it is the
      right thing to do.
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      613f0273
    • L
      Allow one-way tree merge to remove old files · 76b99b81
      Linus Torvalds 提交于
      For some random reason (probably just because nobody noticed), the one-way
      merge strategy didn't mark deleted files as deleted, so if you used
      
      	git-read-tree -m -u <newtree>
      
      it would update the files that got changed in the index, but it would not
      delete the files that got deleted.
      
      This should fix it, and I can't imagine that anybody depends on the old
      strange "update only existing files" behaviour.
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      76b99b81
  24. 09 5月, 2006 1 次提交
  25. 08 5月, 2006 1 次提交
  26. 04 5月, 2006 1 次提交
  27. 02 5月, 2006 1 次提交
    • J
      read-tree: --prefix=<path>/ option. · f4c6f2d3
      Junio C Hamano 提交于
      With "--prefix=<path>/" option, read-tree keeps the current
      index contents, and reads the contents of named tree-ish under
      directory at `<prefix>`.  The original index file cannot have
      anything at the path `<prefix>` itself, and have nothing in
      `<prefix>/` directory.  This can be used to graft an
      independent tree into a subdirectory of the current index.
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      f4c6f2d3
  28. 27 4月, 2006 1 次提交
    • J
      read-tree: teach 1-way merege and plain read to prime cache-tree. · 7927a55d
      Junio C Hamano 提交于
      This teaches read-tree to fully populate valid cache-tree when
      reading a tree from scratch, or reading a single tree into an
      existing index, reusing only the cached stat information (i.e.
      one-way merge).  We have already taught update-index about cache-tree,
      so "git checkout" followed by updates to a few path followed by
      a "git commit" would become very efficient.
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      7927a55d