1. 16 10月, 2014 13 次提交
  2. 02 10月, 2014 8 次提交
  3. 20 9月, 2014 1 次提交
    • D
      refs: make rev-parse --quiet actually quiet · c41a87dd
      David Aguilar 提交于
      When a reflog is deleted, e.g. when "git stash" clears its stashes,
      "git rev-parse --verify --quiet" dies:
      
      	fatal: Log for refs/stash is empty.
      
      The reason is that the get_sha1() code path does not allow us
      to suppress this message.
      
      Pass the flags bitfield through get_sha1_with_context() so that
      read_ref_at() can suppress the message.
      
      Use get_sha1_with_context1() instead of get_sha1() in rev-parse
      so that the --quiet flag is honored.
      Signed-off-by: NDavid Aguilar <davvid@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c41a87dd
  4. 13 9月, 2014 1 次提交
    • J
      refs: speed up is_refname_available · cbe73331
      Jeff King 提交于
      Our filesystem ref storage does not allow D/F conflicts; so
      if "refs/heads/a/b" exists, we do not allow "refs/heads/a"
      to exist (and vice versa). This falls out naturally for
      loose refs, where the filesystem enforces the condition. But
      for packed-refs, we have to make the check ourselves.
      
      We do so by iterating over the entire packed-refs namespace
      and checking whether each name creates a conflict. If you
      have a very large number of refs, this is quite inefficient,
      as you end up doing a large number of comparisons with
      uninteresting bits of the ref tree (e.g., we know that all
      of "refs/tags" is uninteresting in the example above, yet we
      check each entry in it).
      
      Instead, let's take advantage of the fact that we have the
      packed refs stored as a trie of ref_entry structs. We can
      find each component of the proposed refname as we walk
      through the trie, checking for D/F conflicts as we go. For a
      refname of depth N (i.e., 4 in the above example), we only
      have to visit N nodes. And at each visit, we can binary
      search the M names at that level, for a total complexity of
      O(N lg M). ("M" is different at each level, of course, but
      we can take the worst-case "M" as a bound).
      
      In a pathological case of fetching 30,000 fresh refs into a
      repository with 8.5 million refs, this dropped the time to
      run "git fetch" from tens of minutes to ~30s.
      
      This may also help smaller cases in which we check against
      loose refs (which we do when renaming a ref), as we may
      avoid a disk access for unrelated loose directories.
      
      Note that the tests we add appear at first glance to be
      redundant with what is already in t3210. However, the early
      tests are not robust; they are run with reflogs turned on,
      meaning that we are not actually testing
      is_refname_available at all! The operations will still fail
      because the reflogs will hit D/F conflicts in the
      filesystem. To get a true test, we must turn off reflogs
      (but we don't want to do so for the entire script, because
      the point of turning them on was to cover some other cases).
      Reviewed-by: NMichael Haggerty <mhagger@alum.mit.edu>
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      cbe73331
  5. 11 9月, 2014 1 次提交
    • J
      refs: write packed_refs file using stdio · 9540ce50
      Jeff King 提交于
      We write each line of a new packed-refs file individually
      using a write() syscall (and sometimes 2, if the ref is
      peeled). Since each line is only about 50-100 bytes long,
      this creates a lot of system call overhead.
      
      We can instead open a stdio handle around our descriptor and
      use fprintf to write to it. The extra buffering is not a
      problem for us, because nobody will read our new packed-refs
      file until we call commit_lock_file (by which point we have
      flushed everything).
      
      On a pathological repository with 8.5 million refs, this
      dropped the time to run `git pack-refs` from 20s to 6s.
      Signed-off-by: NJeff King <peff@peff.net>
      Reviewed-by: NMichael Haggerty <mhagger@alum.mit.edu>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      9540ce50
  6. 04 9月, 2014 11 次提交
  7. 26 8月, 2014 1 次提交
    • J
      pack-refs: prune top-level refs like "refs/foo" · afd11d3e
      Jeff King 提交于
      After we have packed all refs, we prune any loose refs that
      correspond to what we packed. We do so by first taking a
      lock with lock_ref_sha1, and then deleting the loose ref
      file.
      
      However, lock_ref_sha1 will refuse to take a lock on any
      refs that exist at the top-level of the "refs/" directory,
      and we skip pruning the ref.  This is almost certainly not
      what we want to happen here. The criteria to be pruned
      should not differ from that to be packed; if a ref makes it
      to prune_ref, it's because we want it both packed and
      pruned (if there are refs you do not want to be packed, they
      should be omitted much earlier by pack_ref_is_possible,
      which we do in this case if --all is not given).
      
      We can fix this by switching to lock_any_ref_for_update.
      This behaves exactly the same with the exception of this
      top-level check.
      Signed-off-by: NJeff King <peff@peff.net>
      Reviewed-by: NMichael Haggerty <mhagger@alum.mit.edu>
      Reviewed-by: NRonnie Sahlberg <sahlberg@google.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      afd11d3e
  8. 29 7月, 2014 3 次提交
    • J
      Revert "Merge branch 'dt/refs-check-refname-component-sse'" · 5e650228
      Junio C Hamano 提交于
      This reverts commit 6f92e5ff, reversing
      changes made to a02ad882.
      5e650228
    • J
      Revert "Merge branch 'dt/refs-check-refname-component-sse-fix'" · dad2e7f4
      Junio C Hamano 提交于
      This reverts commit 779c99fd, reversing
      changes made to df4d7d56.
      dad2e7f4
    • J
      add object_as_type helper for casting objects · c4ad00f8
      Jeff King 提交于
      When we call lookup_commit, lookup_tree, etc, the logic goes
      something like:
      
        1. Look for an existing object struct. If we don't have
           one, allocate and return a new one.
      
        2. Double check that any object we have is the expected
           type (and complain and return NULL otherwise).
      
        3. Convert an object with type OBJ_NONE (from a prior
           call to lookup_unknown_object) to the expected type.
      
      We can encapsulate steps 2 and 3 in a helper function which
      checks whether we have the expected object type, converts
      OBJ_NONE as appropriate, and returns the object.
      
      Not only does this shorten the code, but it also provides
      one central location for converting OBJ_NONE objects into
      objects of other types. Future patches will use that to
      enforce type-specific invariants.
      
      Since this is a refactoring, we would want it to behave
      exactly as the current code. It takes a little reasoning to
      see that this is the case:
      
        - for lookup_{commit,tree,etc} functions, we are just
          pulling steps 2 and 3 into a function that does the same
          thing.
      
        - for the call in peel_object, we currently only do step 3
          (but we want to consolidate it with the others, as
          mentioned above). However, step 2 is a noop here, as the
          surrounding conditional makes sure we have OBJ_NONE
          (which we want to keep to avoid an extraneous call to
          sha1_object_info).
      
        - for the call in lookup_commit_reference_gently, we are
          currently doing step 2 but not step 3. However, step 3
          is a noop here. The object we got will have just come
          from deref_tag, which must have figured out the type for
          each object in order to know when to stop peeling.
          Therefore the type will never be OBJ_NONE.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c4ad00f8
  9. 17 7月, 2014 1 次提交