1. 24 3月, 2007 3 次提交
    • J
      Fix path-limited "rev-list --bisect" termination condition. · a4e9d71e
      Junio C Hamano 提交于
      In a path-limited bisection, when the $bad commit is not
      changing the limited path, and the number of suspects is 1, the
      code miscounted and returned $bad from find_bisection(), which
      is not marked with TREECHANGE.  This is of course filtered by
      the output routine, resulting in an empty output, in turn
      causing git-bisect driver to say "$bad was both good and bad".
      
      Illustration.  Suppose you have these four commits, and only C
      changes path P.  You know D is bad and A is good.
      
      	A---B---C*--D
      
      git-bisect driver runs this to find a bisection point:
      
      	$ git rev-list --bisect A..D -- P
      
      which calls find_bisection() with B, C and D.  The set of
      commits that is given to this function is the same set of
      commits as rev-list without --bisect option and pathspec
      returns.  Among them, only C is marked with TREECHANGE.  Let's
      call the set of commits given to find_bisection() that are
      marked with TREECHANGE (or all of them if no path limiter is in
      effect) "the bisect set".  In the above example, the size of the
      bisect set is 1 (contains only "C").
      
      For each commit in its input, find_bisection() computes the
      number of commits it can reach in the bisect set.  For a commit
      in the bisect set, this number includes itself, so the number is
      1 or more.  This number is called "depth", and computed by
      count_distance() function.
      
      When you have a bisect set of N commits, and a commit has depth
      D, how good is your bisection if you returned that commit?  How
      good this bisection is can be measured by how many commits are
      effectively tested "together" by testing one commit.
      
      Currently you have (N-1) untested commits (the tip of the bisect
      set, although it is included in the bisect set, is already known
      to be bad).  If the commit with depth D turns out to be bad,
      then your next bisect set will have D commits and you will have
      (D-1) untested commits left, which means you tested (N-1)-(D-1)
      = (N-D) commits with this bisection.  If it turns out to be good, then
      your next bisect set will have (N-D) commits, and you will have
      (N-D-1) untested commits left, which means you tested
      (N-1)-(N-D-1) = D commits with this bisection.
      
      Therefore, the goodness of this bisection is is min(N-D, D), and
      find_bisection() function tries to find a commit that maximizes
      this, by initializing "closest" variable to 0 and whenever a
      commit with the goodness that is larger than the current
      "closest" is found, that commit and its goodness are remembered
      by updating "closest" variable.  The "the commit with the best
      goodness so far" is kept in "best" variable, and is initialized
      to a commit that happens to be at the beginning of the list of
      commits given to this function (which may or may not be in the
      bisect set when path-limit is in use).
      
      However, when N is 1, then the sole tree-changing commit has
      depth of 1, and min(N-D, D) evaluates to 0.  This is not larger
      than the initial value of "closest", and the "so far the best
      one" commit is never replaced in the loop.
      
      When path-limit is not in use, this is not a problem, as any
      commit in the input set is tree-changing.  But when path-limit
      is in use, and when the starting "bad" commit does not change
      the specified path, it is not correct to return it.
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      a4e9d71e
    • J
      git-bisect.sh: properly dq $GIT_DIR · 12cb8137
      Junio C Hamano 提交于
      Otherwise you would be in trouble if your GIT_DIR has IFS letters in it.
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      12cb8137
    • J
      git-bisect: typofix · 673e5838
      Junio C Hamano 提交于
      The branch you are on while bisecting is always "bisect", and
      checking for "refs/heads/bisect*" is wrong.  Only check if it is
      exactly "refs/heads/bisect".
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      673e5838
  2. 23 3月, 2007 5 次提交
  3. 22 3月, 2007 13 次提交
  4. 21 3月, 2007 10 次提交
    • B
      [PATCH] prefer "git COMMAND" over "git-COMMAND" in gitk · 1ce09dd6
      Brandon Casey 提交于
      Preferring git _space_ COMMAND over git _dash_ COMMAND allows the
      user to have only git and gitk in their path. e.g. when git and gitk
      are symbolic links in a personal bin directory to the real git and gitk.
      Signed-off-by: NPaul Mackerras <paulus@samba.org>
      1ce09dd6
    • M
      fix typo in git-am manpage · a947ab79
      Michael S. Tsirkin 提交于
      Fix typo in git-am manpage
      Signed-off-by: NMichael S. Tsirkin <mst@dev.mellanox.co.il>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      a947ab79
    • J
      blame: cmp_suspect is not "cmp" anymore. · 171dccd5
      Junio C Hamano 提交于
      The earlier round makes the function return "is it different"
      and it does not return a value suitable for sorting anymore.  Reverse
      the logic to return "are they the same suspect" instead, and rename
      it to "same_suspect()".
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      171dccd5
    • N
      minor git-prune optimization · 3254d218
      Nicolas Pitre 提交于
      Don't try to remove the containing directory for every pruned object but
      try only once after the directory has been scanned instead.
      Signed-off-by: NNicolas Pitre <nico@cam.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      3254d218
    • N
      improve checkout message when asking for same branch · 57216856
      Nicolas Pitre 提交于
      Change the feedback message if doing 'git checkout foo' when already on
      branch "foo".
      Signed-off-by: NNicolas Pitre <nico@cam.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      57216856
    • L
      Be more careful about zlib return values · ac54c277
      Linus Torvalds 提交于
      When creating a new object, we use "deflate(stream, Z_FINISH)" in a loop
      until it no longer returns Z_OK, and then we do "deflateEnd()" to finish
      up business.
      
      That should all work, but the fact is, it's not how you're _supposed_ to
      use the zlib return values properly:
      
       - deflate() should never return Z_OK in the first place, except if we
         need to increase the output buffer size (which we're not doing, and
         should never need to do, since we pre-allocated a buffer that is
         supposed to be able to hold the output in full). So the "while()" loop
         was incorrect: Z_OK doesn't actually mean "ok, continue", it means "ok,
         allocate more memory for me and continue"!
      
       - if we got an error return, we would consider it to be end-of-stream,
         but it could be some internal zlib error.  In short, we should check
         for Z_STREAM_END explicitly, since that's the only valid return value
         anyway for the Z_FINISH case.
      
       - we never checked deflateEnd() return codes at all.
      
      Now, admittedly, none of these issues should ever happen, unless there is
      some internal bug in zlib. So this patch should make zero difference, but
      it seems to be the right thing to do.
      
      We should probablybe anal and check the return value of "deflateInit()"
      too!
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      ac54c277
    • L
      Don't ever return corrupt objects from "parse_object()" · acdeec62
      Linus Torvalds 提交于
      Looking at the SHA1 validation code due to the corruption that Alexander
      Litvinov is seeing under Cygwin, I notice that one of the most central
      places where we read objects, we actually do end up verifying the SHA1 of
      the result, but then we happily parse it anyway.
      
      And using "printf" to write the error message means that it not only can
      get lost, but will actually mess up stdout, and cause other strange and
      hard-to-debug failures downstream.
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      acdeec62
    • N
      index-pack: more validation checks and cleanups · 9096c660
      Nicolas Pitre 提交于
      When appending objects to a pack, make sure the appended data is really
      what we expect instead of simply loading potentially corrupted objects
      and legitimating them by computing a SHA1 of that corrupt data.
      
      With this the sha1_object() can lose its test_for_collision parameter
      which is now redundent.
      Signed-off-by: NNicolas Pitre <nico@cam.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      9096c660
    • N
      index-pack: use hash_sha1_file() · ce9fbf16
      Nicolas Pitre 提交于
      Use hash_sha1_file() instead of duplicating code to compute object SHA1.
      While at it make it accept a const pointer.
      Signed-off-by: NNicolas Pitre <nico@cam.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      ce9fbf16
    • N
      don't ever allow SHA1 collisions to exist by fetching a pack · 8685da42
      Nicolas Pitre 提交于
      Waaaaaaay back Git was considered to be secure as it never overwrote
      an object it already had.  This was ensured by always unpacking the
      packfile received over the network (both in fetch and receive-pack)
      and our already existing logic to not create a loose object for an
      object we already have.
      
      Lately however we keep "large-ish" packfiles on both fetch and push
      by running them through index-pack instead of unpack-objects.  This
      would let an attacker perform a birthday attack.
      
      How?  Assume the attacker knows a SHA-1 that has two different
      data streams.  He knows the client is likely to have the "good"
      one.  So he sends the "evil" variant to the other end as part of
      a "large-ish" packfile.  The recipient keeps that packfile, and
      indexes it.  Now since this is a birthday attack there is a SHA-1
      collision; two objects exist in the repository with the same SHA-1.
      They have *very* different data streams.  One of them is "evil".
      
      Currently the poor recipient cannot tell the two objects apart,
      short of by examining the timestamp of the packfiles.  But lets
      say the recipient repacks before he realizes he's been attacked.
      We may wind up packing the "evil" version of the object, and deleting
      the "good" one.  This is made *even more likely* by Junio's recent
      rearrange_packed_git patch (b867092f).
      
      It is extremely unlikely for a SHA1 collisions to occur, but if it
      ever happens with a remote (hence untrusted) object we simply must
      not let the fetch succeed.
      
      Normally received packs should not contain objects we already have.
      But when they do we must ensure duplicated objects with the same SHA1
      actually contain the same data.
      Signed-off-by: NNicolas Pitre <nico@cam.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      8685da42
  5. 20 3月, 2007 9 次提交