1. 15 7月, 2014 6 次提交
  2. 28 5月, 2014 2 次提交
    • J
      remote prune: optimize "dangling symref" check/warning · e6bea66d
      Jens Lindström 提交于
      When 'git remote prune' was used to delete many refs in a repository
      with many refs, a lot of time was spent checking for (now) dangling
      symbolic refs pointing to the deleted ref, since warn_dangling_symref()
      was once per deleted ref to check all other refs in the repository.
      
      Avoid this using the new warn_dangling_symrefs() function which
      makes one pass over all refs and checks for all the deleted refs in
      one go, after they have all been deleted.
      Signed-off-by: NJens Lindström <jl@opera.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      e6bea66d
    • J
      remote: repack packed-refs once when deleting multiple refs · c9e768bb
      Jens Lindström 提交于
      When 'git remote rm' or 'git remote prune' were used in a repository
      with many refs, and needed to delete many remote-tracking refs, a lot
      of time was spent deleting those refs since for each deleted ref,
      repack_without_refs() was called to rewrite packed-refs without just
      that deleted ref.
      
      To avoid this, call repack_without_refs() first to repack without all
      the refs that will be deleted, before calling delete_ref() to delete
      each one completely.  The call to repack_without_ref() in delete_ref()
      then becomes a no-op, since packed-refs already won't contain any of
      the deleted refs.
      Signed-off-by: NJens Lindström <jl@opera.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c9e768bb
  3. 09 5月, 2014 1 次提交
    • R
      refs.c: add new functions reflog_exists and delete_reflog · 4da58835
      Ronnie Sahlberg 提交于
      Add two new functions, reflog_exists and delete_reflog, to hide the internal
      reflog implementation (that they are files under .git/logs/...) from callers.
      Update checkout.c to use these functions in update_refs_for_switch instead of
      building pathnames and calling out to file access functions. Update reflog.c
      to use these to check if the reflog exists. Now there are still many places
      in reflog.c where we are still leaking the reflog storage implementation but
      this at least reduces the number of such dependencies by one. Finally
      change two places in refs.c itself to use the new function to check if a ref
      exists or not isntead of build-path-and-stat(). Now, this is strictly not all
      that important since these are in parts of refs that are implementing the
      actual file storage backend but on the other hand it will not hurt either.
      Signed-off-by: NRonnie Sahlberg <sahlberg@google.com>
      Acked-by: NMichael Haggerty <mhagger@alum.mit.edu>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      4da58835
  4. 08 4月, 2014 5 次提交
  5. 28 10月, 2013 1 次提交
  6. 05 9月, 2013 1 次提交
    • B
      refs: add update_refs for multiple simultaneous updates · 98aee92d
      Brad King 提交于
      Add 'struct ref_update' to encode the information needed to update or
      delete a ref (name, new sha1, optional old sha1, no-deref flag).  Add
      function 'update_refs' accepting an array of updates to perform.  First
      sort the input array to order locks consistently everywhere and reject
      multiple updates to the same ref.  Then acquire locks on all refs with
      verified old values.  Then update or delete all refs accordingly.  Fail
      if any one lock cannot be obtained or any one old value does not match.
      
      Though the refs themselves cannot be modified together in a single
      atomic transaction, this function does enable some useful semantics.
      For example, a caller may create a new branch starting from the head of
      another branch and rewind the original branch at the same time.  This
      transfers ownership of commits between branches without risk of losing
      commits added to the original branch by a concurrent process, or risk of
      a concurrent process creating the new branch first.
      Signed-off-by: NBrad King <brad.king@kitware.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      98aee92d
  7. 31 8月, 2013 1 次提交
  8. 21 6月, 2013 1 次提交
  9. 03 6月, 2013 1 次提交
    • M
      refs: document the lifetime of the args passed to each_ref_fn · 4f78c24c
      Michael Haggerty 提交于
      The lifetime of the memory pointed to by the refname and sha1
      arguments to each_ref_fn was never documented, but some callers used
      to assume that it was essentially permanent.  In fact the API does
      *not* guarantee that these objects live beyond a single callback
      invocation.
      
      In the current code, the lifetimes are bound together with the
      lifetimes of the ref_caches.  Since these are usually long, the
      callers usually got away with their sloppiness.  But even today, if a
      ref_cache is invalidated the memory can be freed.  And planned changes
      to reference caching, needed to eliminate race conditions, will
      probably need to shorten the lifetimes of these objects.
      
      The commits leading up to this have (hopefully) fixed all of the
      callers of the for_each_ref()-like functions.  This commit does the
      last step: documents what each_ref_fn callbacks can assume about
      object lifetimes.
      Signed-off-by: NMichael Haggerty <mhagger@alum.mit.edu>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      4f78c24c
  10. 02 5月, 2013 3 次提交
  11. 09 3月, 2013 1 次提交
    • J
      reflog: add for_each_reflog_ent_reverse() API · 98f85ff4
      Junio C Hamano 提交于
      "git checkout -" is a short-hand for "git checkout @{-1}" and the
      "@{nth}" notation for a negative number is to find nth previous
      checkout in the reflog of the HEAD to determine the name of the
      branch the user was on.  We would want to find the nth most recent
      reflog entry that matches "checkout: moving from X to Y" for this.
      
      Unfortunately, reflog is implemented as an append-only file, and the
      API to iterate over its entries, for_each_reflog_ent(), reads the
      file in order, giving the entries from the oldest to newer.  For the
      purpose of finding nth most recent one, this API forces us to record
      the last n entries in a rotating buffer and give the result out only
      after we read everything.  To optimize for a common case of finding
      the nth most recent one for a small value of n, we also have a side
      API for_each_recent_reflog_ent() that starts reading near the end of
      the file, but it still has to read the entries in the "wrong" order.
      The implementation of understanding @{-1} uses this interface.
      
      This all becomes unnecessary if we add an API to let us iterate over
      reflog entries in the reverse order, from the newest to older.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      98f85ff4
  12. 08 2月, 2013 1 次提交
    • J
      upload/receive-pack: allow hiding ref hierarchies · daebaa78
      Junio C Hamano 提交于
      A repository may have refs that are only used for its internal
      bookkeeping purposes that should not be exposed to the others that
      come over the network.
      
      Teach upload-pack to omit some refs from its initial advertisement
      by paying attention to the uploadpack.hiderefs multi-valued
      configuration variable.  Do the same to receive-pack via the
      receive.hiderefs variable.  As a convenient short-hand, allow using
      transfer.hiderefs to set the value to both of these variables.
      
      Any ref that is under the hierarchies listed on the value of these
      variable is excluded from responses to requests made by "ls-remote",
      "fetch", etc. (for upload-pack) and "push" (for receive-pack).
      
      Because these hidden refs do not count as OUR_REF, an attempt to
      fetch objects at the tip of them will be rejected, and because these
      refs do not get advertised, "git push :" will not see local branches
      that have the same name as them as "matching" ones to be sent.
      
      An attempt to update/delete these hidden refs with an explicit
      refspec, e.g. "git push origin :refs/hidden/22", is rejected.  This
      is not a new restriction.  To the pusher, it would appear that there
      is no such ref, so its push request will conclude with "Now that I
      sent you all the data, it is time for you to update the refs.  I saw
      that the ref did not exist when I started pushing, and I want the
      result to point at this commit".  The receiving end will apply the
      compare-and-swap rule to this request and rejects the push with
      "Well, your update request conflicts with somebody else; I see there
      is such a ref.", which is the right thing to do. Otherwise a push to
      a hidden ref will always be "the last one wins", which is not a good
      default.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      daebaa78
  13. 11 4月, 2012 1 次提交
    • M
      refs: store references hierarchically · 432ad41e
      Michael Haggerty 提交于
      Store references hierarchically in a tree that matches the
      pseudo-directory structure of the reference names.  Add a new kind of
      ref_entry (with flag REF_DIR) to represent a whole subdirectory of
      references.  Sort ref_dirs one subdirectory at a time.
      
      NOTE: the dirs can now be sorted as a side-effect of other function
      calls.  Therefore, it would be problematic to do something from a
      each_ref_fn callback that could provoke the sorting of a directory
      that is currently being iterated over (i.e., the directory containing
      the entry that is being processed or any of its parents).
      
      This is a bit far-fetched, because a directory is always sorted just
      before being iterated over.  Therefore, read-only accesses cannot
      trigger the sorting of a directory whose iteration has already
      started.  But if a callback function would add a reference to a parent
      directory of the reference in the iteration, then try to resolve a
      reference under that directory, a re-sort could be triggered and cause
      the iteration to work incorrectly.
      
      Nevertheless...add a comment in refs.h warning against modifications
      during iteration.
      Signed-off-by: NMichael Haggerty <mhagger@alum.mit.edu>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      432ad41e
  14. 13 2月, 2012 1 次提交
  15. 18 1月, 2012 1 次提交
  16. 13 12月, 2011 3 次提交
  17. 20 10月, 2011 1 次提交
  18. 17 10月, 2011 1 次提交
  19. 06 10月, 2011 3 次提交
  20. 01 10月, 2011 1 次提交
    • P
      receive-pack: don't pass non-existent refs to post-{receive,update} hooks · 160b81ed
      Pang Yan Han 提交于
      When a push specifies deletion of non-existent refs, the post post-receive and
      post-update hooks receive them as input/arguments.
      
      For instance, for the following push, where refs/heads/nonexistent is a ref
      which does not exist on the remote side:
      
      	git push origin :refs/heads/nonexistent
      
      the post-receive hook receives from standard input:
      
      	<null-sha1> SP <null-sha1> SP refs/heads/nonexistent
      
      and the post-update hook receives as arguments:
      
      	refs/heads/nonexistent
      
      which does not make sense since it is a no-op.
      
      Teach receive-pack not to pass non-existent refs to the post-receive and
      post-update hooks. If the push only attempts to delete non-existent refs,
      these hooks are not even called.
      
      The update and pre-receive hooks are still notified about attempted
      deletion of non-existent refs to give them a chance to inspect the
      situation and act on it.
      
      [jc: mild fix-ups to avoid introducing an extra list; also added fixes to
      some tests]
      Signed-off-by: NPang Yan Han <pangyanhan@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      160b81ed
  21. 07 7月, 2011 1 次提交
    • J
      ref namespaces: infrastructure · a1bea2c1
      Josh Triplett 提交于
      Add support for dividing the refs of a single repository into multiple
      namespaces, each of which can have its own branches, tags, and HEAD.
      Git can expose each namespace as an independent repository to pull from
      and push to, while sharing the object store, and exposing all the refs
      to operations such as git-gc.
      
      Storing multiple repositories as namespaces of a single repository
      avoids storing duplicate copies of the same objects, such as when
      storing multiple branches of the same source.  The alternates mechanism
      provides similar support for avoiding duplicates, but alternates do not
      prevent duplication between new objects added to the repositories
      without ongoing maintenance, while namespaces do.
      
      To specify a namespace, set the GIT_NAMESPACE environment variable to
      the namespace.  For each ref namespace, git stores the corresponding
      refs in a directory under refs/namespaces/.  For example,
      GIT_NAMESPACE=foo will store refs under refs/namespaces/foo/.  You can
      also specify namespaces via the --namespace option to git.
      
      Note that namespaces which include a / will expand to a hierarchy of
      namespaces; for example, GIT_NAMESPACE=foo/bar will store refs under
      refs/namespaces/foo/refs/namespaces/bar/.  This makes paths in
      GIT_NAMESPACE behave hierarchically, so that cloning with
      GIT_NAMESPACE=foo/bar produces the same result as cloning with
      GIT_NAMESPACE=foo and cloning from that repo with GIT_NAMESPACE=bar.  It
      also avoids ambiguity with strange namespace paths such as
      foo/refs/heads/, which could otherwise generate directory/file conflicts
      within the refs directory.
      
      Add the infrastructure for ref namespaces: handle the GIT_NAMESPACE
      environment variable and --namespace option, and support iterating over
      refs in a namespace.
      Signed-off-by: NJosh Triplett <josh@joshtriplett.org>
      Signed-off-by: NJamey Sharp <jamey@minilop.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      a1bea2c1
  22. 06 6月, 2011 1 次提交
    • J
      checkout -b <name>: correctly detect existing branch · c17b2294
      Junio C Hamano 提交于
      When create a new branch, we fed "refs/heads/<proposed name>" as a string
      to get_sha1() and expected it to fail when a branch already exists.
      
      The right way to check if a ref exists is to check with resolve_ref().
      
      A naïve solution that might appear attractive but does not work is to
      forbid slashes in get_describe_name() but that will not work. A describe
      name is is in the form of "ANYTHING-g<short sha1>", and that ANYTHING part
      comes from a original tag name used in the repository the user ran the
      describe command. A sick user could have a confusing hierarchical tag
      whose name is "refs/heads/foobar" (stored as refs/tags/refs/heads/foobar")
      to generate a describe name "refs/heads/foobar-6-g02ac9837", and we should
      be able to use that name to refer to the object whose name is 02ac9837.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c17b2294
  23. 08 7月, 2010 1 次提交
  24. 13 6月, 2010 1 次提交