Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Jun 16, 2014

  1. Junio C Hamano

    Merge branch 'jl/remote-rm-prune'

    "git remote rm" and "git remote prune" can involve removing many
    refs at once, which is not a very efficient thing to do when very
    many refs exist in the packed-refs file.
    
    * jl/remote-rm-prune:
      remote prune: optimize "dangling symref" check/warning
      remote: repack packed-refs once when deleting multiple refs
      remote rm: delete remote configuration as the last
    gitster authored

Jun 06, 2014

  1. Junio C Hamano

    Merge branch 'rs/reflog-exists'

    * rs/reflog-exists:
      checkout.c: use ref_exists instead of file_exist
      refs.c: add new functions reflog_exists and delete_reflog
    gitster authored

May 27, 2014

  1. Jens Lindström

    remote prune: optimize "dangling symref" check/warning

    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: Jens Lindström <jl@opera.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    jensl authored gitster committed
  2. Jens Lindström

    remote: repack packed-refs once when deleting multiple refs

    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: Jens Lindström <jl@opera.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    jensl authored gitster committed

May 08, 2014

  1. rsahlberg

    refs.c: add new functions reflog_exists and delete_reflog

    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: Ronnie Sahlberg <sahlberg@google.com>
    Acked-by: Michael Haggerty <mhagger@alum.mit.edu>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    rsahlberg authored gitster committed

Apr 07, 2014

  1. Michael Haggerty

    struct ref_update: rename field "ref_name" to "refname"

    This is consistent with the usual nomenclature.
    
    Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    mhagger authored gitster committed
  2. Michael Haggerty

    refs: remove API function update_refs()

    It has been superseded by reference transactions.  This also means
    that struct ref_update can become private.
    
    Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    mhagger authored gitster committed
  3. Michael Haggerty

    refs: add a concept of a reference transaction

    Build out the API for dealing with a bunch of reference checks and
    changes within a transaction.  Define an opaque ref_transaction type
    that is managed entirely within refs.c.  Introduce functions for
    beginning a transaction, adding updates to a transaction, and
    committing/rolling back a transaction.
    
    This API will soon replace update_refs().
    
    Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    mhagger authored gitster committed
  4. Michael Haggerty

    update_refs(): fix constness

    The old signature of update_refs() required a
    (const struct ref_update **) for its updates_orig argument.  The
    "const" is presumably there to promise that the function will not
    modify the contents of the structures.
    
    But this declaration does not permit the function to be called with a
    (struct ref_update **), which is perfectly legitimate.  C's type
    system is not powerful enough to express what we'd like.  So remove
    the first "const" from the declaration.
    
    On the other hand, the function *can* promise not to modify the
    pointers within the array that is passed to it without inconveniencing
    its callers.  So add a "const" that has that effect, making the final
    declaration
    (struct ref_update * const *).
    
    Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    mhagger authored gitster committed
  5. Michael Haggerty

    refs.h: rename the action_on_err constants

    Given that these constants are only being used when updating
    references, it is inappropriate to give them such generic names as
    "DIE_ON_ERR".  So prefix their names with "UPDATE_REFS_".
    
    Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    mhagger authored gitster committed

Nov 01, 2013

  1. Junio C Hamano

    Merge branch 'sb/refs-code-cleanup'

    * sb/refs-code-cleanup:
      cache: remove unused function 'have_git_dir'
      refs: remove unused function invalidate_ref_cache
    gitster authored

Oct 28, 2013

  1. stefanbeller

    refs: remove unused function invalidate_ref_cache

    The function 'invalidate_ref_cache' was introduced in 79c7ca5 (2011-10-17,
    invalidate_ref_cache(): rename function from invalidate_cached_refs())
    by a rename and elevated to be publicly usable in 8be8bde (2011-10-17,
    invalidate_ref_cache(): expose this function in the refs API)
    
    However it is not used anymore, as 8bf90dc (2011-10-17, write_ref_sha1():
    only invalidate the loose ref cache) and (much) later 506a760 (2013-04-22,
    refs: change how packed refs are deleted) removed any calls to this
    function. So it seems as if we don't need that function any more,
    good bye!
    
    Signed-off-by: Stefan Beller <stefanbeller@googlemail.com>
    Acked-by: Michael Haggerty <mhagger@alum.mit.edu>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    stefanbeller authored gitster committed

Sep 04, 2013

  1. Brad King

    refs: add update_refs for multiple simultaneous updates

    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: Brad King <brad.king@kitware.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    bradking authored gitster committed

Aug 30, 2013

  1. Brad King

    refs: report ref type from lock_any_ref_for_update

    Expose lock_ref_sha1_basic's type_p argument to callers of
    lock_any_ref_for_update.  Update all call sites to ignore it by passing
    NULL for now.
    
    Signed-off-by: Brad King <brad.king@kitware.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    bradking authored gitster committed

Jun 20, 2013

  1. Michael Haggerty

    refs: implement simple transactions for the packed-refs file

    Handle simple transactions for the packed-refs file at the
    packed_ref_cache level via new functions lock_packed_refs(),
    commit_packed_refs(), and rollback_packed_refs().
    
    Only allow the packed ref cache to be modified (via add_packed_ref())
    while the packed refs file is locked.
    
    Change clone to add the new references within a transaction.
    
    Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    mhagger authored gitster committed

Jun 14, 2013

  1. Junio C Hamano

    Merge branch 'mh/reflife'

    Define memory ownership and lifetime rules for what for-each-ref
    feeds to its callbacks (in short, "you do not own it, so make a
    copy if you want to keep it").
    
    * mh/reflife: (25 commits)
      refs: document the lifetime of the args passed to each_ref_fn
      register_ref(): make a copy of the bad reference SHA-1
      exclude_existing(): set existing_refs.strdup_strings
      string_list_add_refs_by_glob(): add a comment about memory management
      string_list_add_one_ref(): rename first parameter to "refname"
      show_head_ref(): rename first parameter to "refname"
      show_head_ref(): do not shadow name of argument
      add_existing(): do not retain a reference to sha1
      do_fetch(): clean up existing_refs before exiting
      do_fetch(): reduce scope of peer_item
      object_array_entry: fix memory handling of the name field
      find_first_merges(): remove unnecessary code
      find_first_merges(): initialize merges variable using initializer
      fsck: don't put a void*-shaped peg in a char*-shaped hole
      object_array_remove_duplicates(): rewrite to reduce copying
      revision: use object_array_filter() in implementation of gc_boundary()
      object_array: add function object_array_filter()
      revision: split some overly-long lines
      cmd_diff(): make it obvious which cases are exclusive of each other
      cmd_diff(): rename local variable "list" -> "entry"
      ...
    gitster authored

Jun 02, 2013

  1. Michael Haggerty

    refs: document the lifetime of the args passed to each_ref_fn

    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: Michael Haggerty <mhagger@alum.mit.edu>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    mhagger authored gitster committed

May 29, 2013

  1. Junio C Hamano

    Merge branch 'mh/packed-refs-various'

    Update reading and updating packed-refs file, correcting corner case
    bugs.
    
    * mh/packed-refs-various: (33 commits)
      refs: handle the main ref_cache specially
      refs: change do_for_each_*() functions to take ref_cache arguments
      pack_one_ref(): do some cheap tests before a more expensive one
      pack_one_ref(): use write_packed_entry() to do the writing
      pack_one_ref(): use function peel_entry()
      refs: inline function do_not_prune()
      pack_refs(): change to use do_for_each_entry()
      refs: use same lock_file object for both ref-packing functions
      pack_one_ref(): rename "path" parameter to "refname"
      pack-refs: merge code from pack-refs.{c,h} into refs.{c,h}
      pack-refs: rename handle_one_ref() to pack_one_ref()
      refs: extract a function write_packed_entry()
      repack_without_ref(): write peeled refs in the rewritten file
      t3211: demonstrate loss of peeled refs if a packed ref is deleted
      refs: change how packed refs are deleted
      search_ref_dir(): return an index rather than a pointer
      repack_without_ref(): silence errors for dangling packed refs
      t3210: test for spurious error messages for dangling packed refs
      refs: change the internal reference-iteration API
      refs: extract a function peel_entry()
      ...
    gitster authored

May 01, 2013

  1. Michael Haggerty

    pack-refs: merge code from pack-refs.{c,h} into refs.{c,h}

    pack-refs.c doesn't contain much code, and the code it does contain is
    closely related to reference handling.  Moreover, there is some
    duplication between pack_refs() and repack_without_ref().  Therefore,
    merge pack-refs.c into refs.c and pack-refs.h into refs.h.
    
    The code duplication will be addressed in future commits.
    
    Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    mhagger authored gitster committed
  2. Michael Haggerty

    peel_ref(): fix return value for non-peelable, not-current reference

    The old version was inconsistent: when a reference was
    REF_KNOWS_PEELED but with a null peeled value, it returned non-zero
    for the current reference but zero for other references.  Change the
    behavior for non-current references to match that of current_ref,
    which is what callers expect.  Document the behavior.
    
    Current callers only call peel_ref() from within a for_each_ref-style
    iteration and only for the current ref; therefore, the buggy code path
    was never reached.
    
    Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    mhagger authored gitster committed
  3. Michael Haggerty

    refs: document flags constants REF_*

    Document the bits that can appear in the "flags" parameter passed to
    an each_ref_function and/or in the ref_entry::flag field.
    
    Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    mhagger authored gitster committed

Mar 26, 2013

  1. Junio C Hamano

    Merge branch 'jc/reflog-reverse-walk'

    An internal function used to implement "git checkout @{-1}" was
    hard to use correctly.
    
    * jc/reflog-reverse-walk:
      refs.c: fix fread error handling
      reflog: add for_each_reflog_ent_reverse() API
      for_each_recent_reflog_ent(): simplify opening of a reflog file
      for_each_reflog_ent(): extract a helper to process a single entry
    gitster authored

Mar 08, 2013

  1. Junio C Hamano

    reflog: add for_each_reflog_ent_reverse() API

    "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: Junio C Hamano <gitster@pobox.com>
    gitster authored

Feb 07, 2013

  1. Junio C Hamano

    upload/receive-pack: allow hiding ref hierarchies

    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: Junio C Hamano <gitster@pobox.com>
    gitster authored

Apr 10, 2012

  1. Michael Haggerty

    refs: store references hierarchically

    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: Michael Haggerty <mhagger@alum.mit.edu>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    mhagger authored gitster committed

Feb 13, 2012

  1. Michael Haggerty

    refs: remove the extra_refs API

    The extra_refs provided a kludgy way to create fake references at a
    global level in the hope that they would only affect some particular
    code path.  The last user of this API been rewritten, so strip this
    stuff out before somebody else gets the bad idea of using it.
    
    Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    mhagger authored gitster committed

Jan 17, 2012

  1. Michael Haggerty

    add_packed_ref(): new function in the refs API.

    Add a new function add_packed_ref() that adds a reference directly to
    the in-memory packed reference cache.  This will be useful for
    creating local references while cloning.
    
    Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    mhagger authored gitster committed

Dec 12, 2011

  1. Michael Haggerty

    resolve_gitlink_ref(): improve docstring

    Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    mhagger authored gitster committed
  2. Michael Haggerty

    refs: rename parameters result -> sha1

    Try consistently to use the name "sha1" for parameters to which a SHA1
    will be stored.
    
    Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    mhagger authored gitster committed
  3. Michael Haggerty

    refs: rename "refname" variables

    Try to consistently use the variable name "refname" when referring to
    a string that names a reference.
    
    Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    mhagger authored gitster committed

Oct 21, 2011

  1. Junio C Hamano

    Merge branch 'jc/broken-ref-dwim-fix'

    * jc/broken-ref-dwim-fix:
      resolve_ref(): report breakage to the caller without warning
      resolve_ref(): expose REF_ISBROKEN flag
      refs.c: move dwim_ref()/dwim_log() from sha1_name.c
    gitster authored

Oct 19, 2011

  1. Junio C Hamano

    resolve_ref(): expose REF_ISBROKEN flag

    Instead of keeping this as an internal API, let the callers find
    out the reason why resolve_ref() returned NULL is not because there
    was no such file in $GIT_DIR but because a file was corrupt.
    
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    gitster authored

Oct 17, 2011

  1. Michael Haggerty

    invalidate_ref_cache(): expose this function in the refs API

    Make invalidate_ref_cache() an official part of the refs API.  It is
    currently a fact of life that code outside of refs.c mucks about with
    references.  This change gives such code a way of informing the refs
    module that it should no longer trust its cache.
    
    Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    mhagger authored gitster committed

Oct 10, 2011

  1. Junio C Hamano

    Merge branch 'jp/get-ref-dir-unsorted'

    * jp/get-ref-dir-unsorted:
      refs.c: free duplicate entries in the ref array instead of leaking them
      refs.c: abort ref search if ref array is empty
      refs.c: ensure struct whose member may be passed to realloc is initialized
      refs: Use binary search to lookup refs faster
      Don't sort ref_list too early
    
    Conflicts:
    	refs.c
    gitster authored

Oct 05, 2011

  1. Michael Haggerty

    add_ref(): verify that the refname is formatted correctly

    In add_ref(), verify that the refname is formatted correctly before
    adding it to the ref_list.  Here we have to allow refname components
    that start with ".", since (for example) the remote protocol uses
    synthetic reference name ".have".  So add a new REFNAME_DOT_COMPONENT
    flag that can be passed to check_refname_format() to allow leading
    dots.
    
    Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    mhagger authored gitster committed
Something went wrong with that request. Please try again.