1. 23 12月, 2014 3 次提交
  2. 05 12月, 2014 1 次提交
  3. 16 10月, 2014 6 次提交
    • R
      refs.c: allow listing and deleting badly named refs · d0f810f0
      Ronnie Sahlberg 提交于
      We currently do not handle badly named refs well:
      
        $ cp .git/refs/heads/master .git/refs/heads/master.....@\*@\\.
        $ git branch
          fatal: Reference has invalid format: 'refs/heads/master.....@*@\.'
        $ git branch -D master.....@\*@\\.
          error: branch 'master.....@*@\.' not found.
      
      Users cannot recover from a badly named ref without manually finding
      and deleting the loose ref file or appropriate line in packed-refs.
      Making that easier will make it easier to tweak the ref naming rules
      in the future, for example to forbid shell metacharacters like '`'
      and '"', without putting people in a state that is hard to get out of.
      
      So allow "branch --list" to show these refs and allow "branch -d/-D"
      and "update-ref -d" to delete them.  Other commands (for example to
      rename refs) will continue to not handle these refs but can be changed
      in later patches.
      
      Details:
      
      In resolving functions, refuse to resolve refs that don't pass the
      git-check-ref-format(1) check unless the new RESOLVE_REF_ALLOW_BAD_NAME
      flag is passed.  Even with RESOLVE_REF_ALLOW_BAD_NAME, refuse to
      resolve refs that escape the refs/ directory and do not match the
      pattern [A-Z_]* (think "HEAD" and "MERGE_HEAD").
      
      In locking functions, refuse to act on badly named refs unless they
      are being deleted and either are in the refs/ directory or match [A-Z_]*.
      
      Just like other invalid refs, flag resolved, badly named refs with the
      REF_ISBROKEN flag, treat them as resolving to null_sha1, and skip them
      in all iteration functions except for for_each_rawref.
      
      Flag badly named refs (but not symrefs pointing to badly named refs)
      with a REF_BAD_NAME flag to make it easier for future callers to
      notice and handle them specially.  For example, in a later patch
      for-each-ref will use this flag to detect refs whose names can confuse
      callers parsing for-each-ref output.
      
      In the transaction API, refuse to create or update badly named refs,
      but allow deleting them (unless they try to escape refs/ and don't match
      [A-Z_]*).
      Signed-off-by: NRonnie Sahlberg <sahlberg@google.com>
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      d0f810f0
    • J
      packed-ref cache: forbid dot-components in refnames · f3cc52d8
      Jonathan Nieder 提交于
      Since v1.7.9-rc1~10^2 (write_head_info(): handle "extra refs" locally,
      2012-01-06), this trick to keep track of ".have" refs that are only
      valid on the wire and not on the filesystem is not needed any more.
      
      Simplify by removing support for the REFNAME_DOT_COMPONENT flag.
      
      This means we'll be slightly stricter with invalid refs found in a
      packed-refs file or during clone.  read_loose_refs() already checks
      for and skips refnames with .components so it is not affected.
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      Reviewed-by: NRonnie Sahlberg <sahlberg@google.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      f3cc52d8
    • J
      branch -d: avoid repeated symref resolution · 62a2d525
      Jonathan Nieder 提交于
      If a repository gets in a broken state with too much symref nesting,
      it cannot be repaired with "git branch -d":
      
       $ git symbolic-ref refs/heads/nonsense refs/heads/nonsense
       $ git branch -d nonsense
       error: branch 'nonsense' not found.
      
      Worse, "git update-ref --no-deref -d" doesn't work for such repairs
      either:
      
       $ git update-ref -d refs/heads/nonsense
       error: unable to resolve reference refs/heads/nonsense: Too many levels of symbolic links
      
      Fix both by teaching resolve_ref_unsafe a new RESOLVE_REF_NO_RECURSE
      flag and passing it when appropriate.
      
      Callers can still read the value of a symref (for example to print a
      message about it) with that flag set --- resolve_ref_unsafe will
      resolve one level of symrefs and stop there.
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      Reviewed-by: NRonnie Sahlberg <sahlberg@google.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      62a2d525
    • R
      refs.c: make write_ref_sha1 static · aae383db
      Ronnie Sahlberg 提交于
      No external users call write_ref_sha1 any more so let's declare it static.
      Signed-off-by: NRonnie Sahlberg <sahlberg@google.com>
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      aae383db
    • R
      refs.c: ref_transaction_commit: distinguish name conflicts from other errors · 28e6a97e
      Ronnie Sahlberg 提交于
      In _commit, ENOTDIR can happen in the call to lock_ref_sha1_basic, either
      when we lstat the new refname or if the name checking function reports that
      the same type of conflict happened.  In both cases, it means that we can not
      create the new ref due to a name conflict.
      
      Start defining specific return codes for _commit.  TRANSACTION_NAME_CONFLICT
      refers to a failure to create a ref due to a name conflict with another ref.
      TRANSACTION_GENERIC_ERROR is for all other errors.
      
      When "git fetch" is creating refs, name conflicts differ from other errors in
      that they are likely to be resolved by running "git remote prune <remote>".
      "git fetch" currently inspects errno to decide whether to give that advice.
      Once it switches to the transaction API, it can check for
      TRANSACTION_NAME_CONFLICT instead.
      Signed-off-by: NRonnie Sahlberg <sahlberg@google.com>
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      28e6a97e
    • R
      refs.c: pass the ref log message to _create/delete/update instead of _commit · db7516ab
      Ronnie Sahlberg 提交于
      Change the ref transaction API so that we pass the reflog message to the
      create/delete/update functions instead of to ref_transaction_commit.
      This allows different reflog messages for each ref update in a multi-ref
      transaction.
      Signed-off-by: NRonnie Sahlberg <sahlberg@google.com>
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      db7516ab
  4. 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
  5. 04 9月, 2014 5 次提交
  6. 03 9月, 2014 1 次提交
  7. 17 7月, 2014 1 次提交
  8. 15 7月, 2014 11 次提交
  9. 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
  10. 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
  11. 08 4月, 2014 5 次提交
  12. 28 10月, 2013 1 次提交
  13. 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
  14. 31 8月, 2013 1 次提交