1. 25 7月, 2017 1 次提交
  2. 03 3月, 2017 1 次提交
    • J
      interpret_branch_name: allow callers to restrict expansions · 0e9f62da
      Jeff King 提交于
      The interpret_branch_name() function converts names like
      @{-1} and @{upstream} into branch names. The expanded ref
      names are not fully qualified, and may be outside of the
      refs/heads/ namespace (e.g., "@" expands to "HEAD", and
      "@{upstream}" is likely to be in "refs/remotes/").
      
      This is OK for callers like dwim_ref() which are primarily
      interested in resolving the resulting name, no matter where
      it is. But callers like "git branch" treat the result as a
      branch name in refs/heads/.  When we expand to a ref outside
      that namespace, the results are very confusing (e.g., "git
      branch @" tries to create refs/heads/HEAD, which is
      nonsense).
      
      Callers can't know from the returned string how the
      expansion happened (e.g., did the user really ask for a
      branch named "HEAD", or did we do a bogus expansion?). One
      fix would be to return some out-parameters describing the
      types of expansion that occurred. This has the benefit that
      the caller can generate precise error messages ("I
      understood @{upstream} to mean origin/master, but that is a
      remote tracking branch, so you cannot create it as a local
      name").
      
      However, out-parameters make the function interface somewhat
      cumbersome. Instead, let's do the opposite: let the caller
      tell us which elements to expand. That's easier to pass in,
      and none of the callers give more precise error messages
      than "@{upstream} isn't a valid branch name" anyway (which
      should be sufficient).
      
      The strbuf_branchname() function needs a similar parameter,
      as most of the callers access interpret_branch_name()
      through it.
      
      We can break the callers down into two groups:
      
        1. Callers that are happy with any kind of ref in the
           result. We pass "0" here, so they continue to work
           without restrictions. This includes merge_name(),
           the reflog handling in add_pending_object_with_path(),
           and substitute_branch_name(). This last is what powers
           dwim_ref().
      
        2. Callers that have funny corner cases (mostly in
           git-branch and git-checkout). These need to make use of
           the new parameter, but I've left them as "0" in this
           patch, and will address them individually in follow-on
           patches.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      0e9f62da
  3. 25 2月, 2017 2 次提交
  4. 01 2月, 2017 1 次提交
    • C
      refs: add option core.logAllRefUpdates = always · 341fb286
      Cornelius Weig 提交于
      When core.logallrefupdates is true, we only create a new reflog for refs
      that are under certain well-known hierarchies. The reason is that we
      know that some hierarchies (like refs/tags) are not meant to change, and
      that unknown hierarchies might not want reflogs at all (e.g., a
      hypothetical refs/foo might be meant to change often and drop old
      history immediately).
      
      However, sometimes it is useful to override this decision and simply log
      for all refs, because the safety and audit trail is more important than
      the performance implications of keeping the log around.
      
      This patch introduces a new "always" mode for the core.logallrefupdates
      option which will log updates to everything under refs/, regardless
      where in the hierarchy it is (we still will not log things like
      ORIG_HEAD and FETCH_HEAD, which are known to be transient).
      Based-on-patch-by: NJeff King <peff@peff.net>
      Signed-off-by: NCornelius Weig <cornelius.weig@tngtech.com>
      Reviewed-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      341fb286
  5. 13 10月, 2016 1 次提交
  6. 10 9月, 2016 21 次提交
  7. 08 9月, 2016 1 次提交
  8. 02 8月, 2016 1 次提交
  9. 21 6月, 2016 1 次提交
    • M
      do_for_each_ref(): reimplement using reference iteration · 4c4de895
      Michael Haggerty 提交于
      Use the reference iterator interface to implement do_for_each_ref().
      Delete a bunch of code supporting the old for_each_ref() implementation.
      And now that do_for_each_ref() is generic code (it is no longer tied to
      the files backend), move it to refs.c.
      
      The implementation is via a new function, do_for_each_ref_iterator(),
      which takes a reference iterator as argument and calls a callback
      function for each of the references in the iterator.
      
      This change requires the current_ref performance hack for peel_ref() to
      be implemented via ref_iterator_peel() rather than peel_entry() because
      we don't have a ref_entry handy (it is hidden under three layers:
      file_ref_iterator, merge_ref_iterator, and cache_ref_iterator). So:
      
      * do_for_each_ref_iterator() records the active iterator in
        current_ref_iter while it is running.
      
      * peel_ref() checks whether current_ref_iter is pointing at the
        requested reference. If so, it asks the iterator to peel the
        reference (which it can do efficiently via its "peel" virtual
        function). For extra safety, we do the optimization only if the
        refname *addresses* are the same, not only if the refname *strings*
        are the same, to forestall possible mixups between refnames that come
        from different ref_iterators.
      
      Please note that this optimization of peel_ref() is only available when
      iterating via do_for_each_ref_iterator() (including all of the
      for_each_ref() functions, which call it indirectly). It would be
      complicated to implement a similar optimization when iterating directly
      using a reference iterator, because multiple reference iterators can be
      in use at the same time, with interleaved calls to
      ref_iterator_advance(). (In fact we do exactly that in
      merge_ref_iterator.)
      
      But that is not necessary. peel_ref() is only called while iterating
      over references. Callers who iterate using the for_each_ref() functions
      benefit from the optimization described above. Callers who iterate using
      reference iterators directly have access to the ref_iterator, so they
      can call ref_iterator_peel() themselves to get an analogous optimization
      in a more straightforward manner.
      
      If we rewrite all callers to use the reference iteration API, then we
      can remove the current_ref_iter hack permanently.
      Signed-off-by: NMichael Haggerty <mhagger@alum.mit.edu>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      4c4de895
  10. 14 6月, 2016 1 次提交
  11. 13 6月, 2016 4 次提交
  12. 05 5月, 2016 3 次提交
  13. 11 4月, 2016 2 次提交