1. 06 10月, 2011 2 次提交
    • M
      Change check_ref_format() to take a flags argument · 8d9c5010
      Michael Haggerty 提交于
      Change check_ref_format() to take a flags argument that indicates what
      is acceptable in the reference name (analogous to "git
      check-ref-format"'s "--allow-onelevel" and "--refspec-pattern").  This
      is more convenient for callers and also fixes a failure in the test
      suite (and likely elsewhere in the code) by enabling "onelevel" and
      "refspec-pattern" to be allowed independently of each other.
      
      Also rename check_ref_format() to check_refname_format() to make it
      obvious that it deals with refnames rather than references themselves.
      Signed-off-by: NMichael Haggerty <mhagger@alum.mit.edu>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      8d9c5010
    • M
      Change bad_ref_char() to return a boolean value · 9224b73b
      Michael Haggerty 提交于
      Previously most bad characters were indicated by returning 1, but "*"
      was special-cased to return 2 instead of 1.  One caller examined the
      return value to see whether the special case occurred.
      
      But it is easier (to document and understand) for bad_ref_char()
      simply to return a boolean value, treating "*" like any other bad
      character.  Special-case the handling of "*" (which only occurs in
      very specific circumstances) at the caller.  The resulting calling
      code thereby also becomes more transparent.
      Signed-off-by: NMichael Haggerty <mhagger@alum.mit.edu>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      9224b73b
  2. 28 8月, 2011 1 次提交
  3. 23 8月, 2011 1 次提交
  4. 07 7月, 2011 2 次提交
    • 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
    • J
      Fix prefix handling in ref iteration functions · b3cfc406
      Josh Triplett 提交于
      The do_for_each_ref iteration function accepts a prefix and a trim, and
      checks for the prefix on each ref before passing in that ref; it also
      supports trimming off part of the ref before passing it.  However,
      do_for_each_ref used trim as the length of the prefix to check, ignoring
      the actual length of the prefix.  Switch to using prefixcmp, checking
      the entire length of the prefix string, to properly support a trim value
      different than the length of the prefix.
      
      Several callers passed a prefix of "refs/" to filter out everything
      outside of refs/, but a trim of 0 to avoid trimming off the "refs/"; the
      trim of 0 meant that the filter of "refs/" no longer applied.  Change
      these callers to pass an empty prefix instead, to avoid changing the
      existing behavior.  Various callers count on this lack of filtering,
      such as receive-pack which uses add_extra_ref to add alternates as refs
      named ".have"; adding filtering would break that, causing
      t5501-fetch-push-alternates.sh to fail.  That lack of filtering doesn't
      currently have any other effect, since the loose ref functions can never
      supply refs outside of "refs/", and packed-refs will not normally
      include such refs unless manually edited.
      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>
      b3cfc406
  5. 17 6月, 2011 1 次提交
  6. 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
  7. 08 7月, 2010 3 次提交
  8. 13 6月, 2010 1 次提交
  9. 03 6月, 2010 1 次提交
  10. 01 6月, 2010 1 次提交
    • G
      Rewrite dynamic structure initializations to runtime assignment · 66dbfd55
      Gary V. Vaughan 提交于
      Unfortunately, there are still plenty of production systems with
      vendor compilers that choke unless all compound declarations can be
      determined statically at compile time, for example hpux10.20 (I can
      provide a comprehensive list of our supported platforms that exhibit
      this problem if necessary).
      
      This patch simply breaks apart any compound declarations with dynamic
      initialisation expressions, and moves the initialisation until after
      the last declaration in the same block, in all the places necessary to
      have the offending compilers accept the code.
      Signed-off-by: NGary V. Vaughan <gary@thewrittenword.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      66dbfd55
  11. 30 3月, 2010 1 次提交
  12. 16 3月, 2010 1 次提交
    • J
      refs: ref entry with NULL sha1 is can be a dangling symref · e01de1c9
      Junio C Hamano 提交于
      Brandon Casey noticed that t5505 had accidentally broken its && chain,
      hiding inconsistency between the code that writes the warning to the
      standard output and the test that expects to see the warning on the
      standard error, which was introduced by f8948e2f (remote prune: warn
      dangling symrefs, 2009-02-08).
      
      It turns out that the issue is deeper than that.  After f8948e2f, a symref
      that is dangling is marked with a NULL sha1, and the idea of using NULL
      sha1 to mean a deleted ref was scrapped, but somehow a follow-up eafb4526
      (do_one_ref(): null_sha1 check is not about broken ref, 2009-07-22)
      incorrectly reorganized do_one_ref(), still thinking NULL sha1 is never
      used in the code.
      
      Fix this by:
      
       - adopt Brandon's fix to t5505 test;
      
       - introduce REF_BROKEN flag to mark a ref that fails to resolve (dangling
         symref);
      
       - move the check for broken ref back inside the "if we are skipping
         dangling refs" code block.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      e01de1c9
  13. 14 3月, 2010 1 次提交
  14. 13 3月, 2010 1 次提交
  15. 04 2月, 2010 1 次提交
    • J
      Typofixes outside documentation area · 9517e6b8
      Junio C Hamano 提交于
          begining -> beginning
          canonicalizations -> canonicalization
          comand -> command
          dewrapping -> unwrapping
          dirtyness -> dirtiness
          DISCLAMER -> DISCLAIMER
          explicitely -> explicitly
          feeded -> fed
          impiled -> implied
          madatory -> mandatory
          mimick -> mimic
          preceeding -> preceding
          reqeuest -> request
          substition -> substitution
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      9517e6b8
  16. 21 1月, 2010 2 次提交
  17. 10 11月, 2009 1 次提交
  18. 29 9月, 2009 1 次提交
  19. 30 7月, 2009 1 次提交
  20. 23 7月, 2009 1 次提交
    • J
      do_one_ref(): null_sha1 check is not about broken ref · eafb4526
      Junio C Hamano 提交于
      f8948e2f (remote prune: warn dangling symrefs, 2009-02-08) introduced a
      more dangerous variant of for_each_ref() family that skips the check for
      dangling refs, but it also made another unrelated check optional by
      mistake.
      
      The check to see if a ref points at 0{40} is not about brokenness, but is
      about a possible future plan to represent a deleted ref by writing 40 "0"
      in a loose ref when there is a stale version of the same ref already in
      .git/packed-refs, so that we can implement deletion of a ref without
      having to rewrite the packed refs file excluding the ref being deleted.
      
      This check has to live outside of the conditional.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      eafb4526
  21. 17 7月, 2009 1 次提交
  22. 28 6月, 2009 1 次提交
  23. 01 6月, 2009 1 次提交
  24. 26 5月, 2009 1 次提交
    • J
      lock_ref: inform callers of unavailable ref · f475e08e
      Jeff King 提交于
      One of the ways that locking might fail is that there is a
      DF conflict between two refs (e.g., you want to lock
      "foo/bar" but "foo" already exists). In this case, we return
      an error, but there is no way for the caller to know the
      specific problem.
      
      This patch sets errno to ENOTDIR, which is the most sensible
      code. It's what we would see if the refs were stored purely
      in the filesystem (but these days we must check the
      namespace manually due to packed refs).
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      f475e08e
  25. 14 5月, 2009 1 次提交
  26. 09 5月, 2009 1 次提交
  27. 30 4月, 2009 1 次提交
    • A
      replace direct calls to unlink(2) with unlink_or_warn · 691f1a28
      Alex Riesen 提交于
      This helps to notice when something's going wrong, especially on
      systems which lock open files.
      
      I used the following criteria when selecting the code for replacement:
      - it was already printing a warning for the unlink failures
      - it is in a function which already printing something or is
        called from such a function
      - it is in a static function, returning void and the function is only
        called from a builtin main function (cmd_)
      - it is in a function which handles emergency exit (signal handlers)
      - it is in a function which is obvously cleaning up the lockfiles
      Signed-off-by: NAlex Riesen <raa.lkml@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      691f1a28
  28. 14 4月, 2009 1 次提交
  29. 08 4月, 2009 1 次提交
    • J
      make get_short_ref a public function · 7c2b3029
      Jeff King 提交于
      Often we want to shorten a full ref name to something "prettier"
      to show a user. For example, "refs/heads/master" is often shown
      simply as "master", or "refs/remotes/origin/master" is shown as
      "origin/master".
      
      Many places in the code use a very simple formula: skip common
      prefixes like refs/heads, refs/remotes, etc. This is codified in
      the prettify_ref function.
      
      for-each-ref has a more correct (but more expensive) approach:
      consider the ref lookup rules, and try shortening as much as
      possible while remaining unambiguous.
      
      This patch makes the latter strategy globally available as
      shorten_unambiguous_ref.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      7c2b3029
  30. 30 3月, 2009 1 次提交
  31. 25 3月, 2009 1 次提交
    • S
      Don't permit ref/branch names to end with ".lock" · 3e262b95
      Shawn O. Pearce 提交于
      We already skip over loose refs under $GIT_DIR/refs if the name
      ends with ".lock", so creating a branch named "foo.lock" will not
      appear in the output of "git branch", "git for-each-ref", nor will
      its commit be considered reachable by "git rev-list --all".
      
      In the latter case this is especially evil, as it may cause
      repository corruption when objects reachable only through such a
      ref are deleted by "git prune".
      
      It should be reasonably safe to deny use of ".lock" as a ref suffix.
      In prior versions of Git such branches would be "phantom branches";
      you can create it, but you can't see it in "git branch" output.
      Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      3e262b95
  32. 24 3月, 2009 2 次提交
    • J
      check_ref_format(): tighten refname rules · cbdffe40
      Junio C Hamano 提交于
      This changes the rules for refnames to forbid:
      
       (1) a refname that contains "@{" in it.
      
           Some people and foreign SCM converter may have named their branches
           as frotz@24 and we still want to keep supporting it.
      
           However, "git branch frotz@{24}" is a disaster.  It cannot even
           checked out because "git checkout frotz@{24}" will interpret it as
           "detach the HEAD at twenty-fourth reflog entry of the frotz branch".
      
       (2) a refname that ends with a dot.
      
           We already reject a path component that begins with a dot, primarily
           to avoid ambiguous range interpretation.  If we allowed ".B" as a
           valid ref, it is unclear if "A...B" means "in dot-B but not in A" or
           "either in A or B but not in both".
      
           But for this to be complete, we need also to forbid "A." to avoid "in
           B but not in A-dot".  This was not a problem in the original range
           notation, but we should have added this restriction when three-dot
           notation was introduced.
      
           Unlike "no dot at the beginning of any path component" rule, this
           rule does not have to be "no dot at the end of any path component",
           because you cannot abbreviate the tail end away, similar to you can
           say "dot-B" to mean "refs/heads/dot-B".
      
      For these reasons, it is not likely people created branches with these
      names on purpose, but we have allowed such names to be used for quite some
      time, and it is possible that people created such branches by mistake or
      by accident.
      
      To help people with branches with such unfortunate names to recover,
      we still allow "branch -d 'bad.'" to delete such branches, and also allow
      "branch -m bad. good" to rename them.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      cbdffe40
    • M
  33. 10 3月, 2009 1 次提交
  34. 08 3月, 2009 1 次提交