1. 14 6月, 2016 1 次提交
  2. 30 12月, 2015 1 次提交
    • J
      create_symref: modernize variable names · b9badadd
      Jeff King 提交于
      Once upon a time, create_symref() was used only to point
      HEAD at a branch name, and the variable names reflect that
      (e.g., calling the path git_HEAD). However, it is much more
      generic these days (and has been for some time). Let's
      update the variable names to make it easier to follow:
      
        - `ref_target` is now just `refname`. This is closer to
          the `ref` that is already in `cache.h`, but with the
          extra twist that "name" makes it clear this is the name
          and not a ref struct. Dropping "target" hopefully makes
          it clear that we are talking about the symref itself,
          not what it points to.
      
        - `git_HEAD` is now `ref_path`; the on-disk path
          corresponding to `ref`.
      
        - `refs_heads_master` is now just `target`; i.e., what the
          symref points at. This term also matches what is in
          the symlink(2) manpage (at least on Linux).
      
        - the buffer to hold the symref file's contents was simply
          called `ref`. It's now `buf` (admittedly also generic,
          but at least not actively introducing confusion with the
          other variable holding the refname).
      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>
      b9badadd
  3. 06 11月, 2015 1 次提交
    • L
      hideRefs: add support for matching full refs · 78a766ab
      Lukas Fleischer 提交于
      In addition to matching stripped refs, one can now add hideRefs
      patterns that the full (unstripped) ref is matched against. To
      distinguish between stripped and full matches, those new patterns
      must be prefixed with a circumflex (^).
      
      This commit also removes support for the undocumented and unintended
      hideRefs settings ".have" (suppressing all "have" lines) and
      "capabilities^{}" (suppressing the capabilities line).
      Signed-off-by: NLukas Fleischer <lfleischer@lfos.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      78a766ab
  4. 18 9月, 2015 1 次提交
  5. 01 8月, 2015 1 次提交
  6. 28 7月, 2015 1 次提交
    • J
      refs: loosen restriction on wildcard "*" refspecs · cd377f45
      Jacob Keller 提交于
      Loosen restrictions on refspecs by allowing patterns that have a "*"
      within a component instead of only as the whole component.
      
      Remove the logic to accept a single "*" as a whole component from
      check_refname_format(), and implement an extended form of that logic
      in check_refname_component().  Pass the pointer to the flags argument
      to the latter, as it has to clear REFNAME_REFSPEC_PATTERN bit when
      it sees "*".
      
      Teach check_refname_component() function to allow an asterisk "*"
      only when REFNAME_REFSPEC_PATTERN is set in the flags, and drop the
      bit after seeing a "*", to ensure that one side of a refspec
      contains at most one asterisk.
      
      This will allow us to accept refspecs such as `for/bar*:foo/baz*`.
      Any refspec which functioned before shall continue functioning with
      the new logic.
      Signed-off-by: NJacob Keller <jacob.keller@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      cd377f45
  7. 22 7月, 2015 3 次提交
  8. 23 6月, 2015 8 次提交
  9. 26 5月, 2015 2 次提交
  10. 18 2月, 2015 6 次提交
  11. 13 2月, 2015 1 次提交
  12. 23 12月, 2014 4 次提交
  13. 05 12月, 2014 1 次提交
  14. 02 12月, 2014 1 次提交
  15. 26 11月, 2014 1 次提交
  16. 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
  17. 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