1. 18 4月, 2009 2 次提交
  2. 08 4月, 2009 1 次提交
  3. 02 4月, 2009 1 次提交
    • M
      Make local branches behave like remote branches when --tracked · 5e6e2b48
      Michael J Gruber 提交于
      This makes sure that local branches, when followed using --track, behave
      the same as remote ones (e.g. differences being reported by git status
      and git checkout). This fixes 1 known failure.
      
      The fix is done within branch_get(): The first natural candidate,
      namely remote_find_tracking(), does not have all the necessary info
      because in general there is no remote struct for '.', and we don't want
      one because it would show up in other places as well.
      
      branch_get(), on the other hand, has access to merge_names[] (in
      addition to merge[]) and therefore can set up the followed branch
      easily.
      Signed-off-by: NMichael J Gruber <git@drmicha.warpmail.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      5e6e2b48
  4. 16 3月, 2009 1 次提交
    • J
      Remove total confusion from git-fetch and git-push · 9326d494
      Junio C Hamano 提交于
      The config file is not the only place remotes are defined, and without
      consulting .git/remotes and .git/branches, you won't know if "origin" is
      configured by the user.  Don't give up too early and insult the user with
      a wisecrack "Where do you want to fetch from today?"
      
      The only thing the previous patch seems to want to prevent from happening
      is a lazy "git fetch/push" that does not say where-from/to to produce an
      error message 'origin not found', and we can do that by not letting
      add_url_alias() to turn a nickname "origin" literally into a pathname
      "origin" without changing the rest of the logic.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      9326d494
  5. 15 3月, 2009 1 次提交
    • B
      Remove unused assignments · 8e76bf3f
      Benjamin Kramer 提交于
      These variables were always overwritten or the assigned
      value was unused:
      
        builtin-diff-tree.c::cmd_diff_tree(): nr_sha1
        builtin-for-each-ref.c::opt_parse_sort(): sort_tail
        builtin-mailinfo.c::decode_header_bq(): in
        builtin-shortlog.c::insert_one_record(): len
        connect.c::git_connect(): path
        imap-send.c::v_issue_imap_cmd(): n
        pretty.c::pp_user_info(): filler
        remote::parse_refspec_internal(): llen
      Signed-off-by: NBenjamin Kramer <benny.kra@googlemail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      8e76bf3f
  6. 11 3月, 2009 1 次提交
    • D
      Give error when no remote is configured · fa685bdf
      Daniel Barkalow 提交于
      When there's no explicitly-named remote, we use the remote specified
      for the current branch, which in turn defaults to "origin". But it
      this case should require the remote to actually be configured, and not
      fall back to the path "origin".
      
      Possibly, the config file's "remote = something" should require the
      something to be a configured remote instead of a bare repository URL,
      but we actually test with a bare repository URL.
      
      In fetch, we were giving the sensible error message when coming up
      with a URL failed, but this wasn't actually reachable, so move that
      error up and use it when appropriate.
      
      In push, we need a new error message, because the old one (formerly
      unreachable without a lot of help) used the repo name, which was NULL.
      Signed-off-by: NDaniel Barkalow <barkalow@iabervon.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      fa685bdf
  7. 08 3月, 2009 4 次提交
  8. 05 3月, 2009 1 次提交
  9. 28 2月, 2009 5 次提交
    • J
      remote: make guess_remote_head() use exact HEAD lookup if it is available · fbb074c2
      Jeff King 提交于
      Our usual method for determining the ref pointed to by HEAD
      is to compare HEAD's sha1 to the sha1 of all refs, trying to
      find a unique match.
      
      However, some transports actually get to look at HEAD
      directly; we should make use of that information when it is
      available.  Currently, only http remotes support this
      feature.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJay Soffian <jaysoffian@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      fbb074c2
    • J
      remote: make match_refs() not short-circuit · 5f48cb95
      Jay Soffian 提交于
      match_refs() returns non-zero if there is an error in
      match_explicit_refs(), without handling any remaining pattern ref specs.
      
      Its existing callers exit upon receiving non-zero, so a partial result
      is of no consequence to them; however a new caller, builtin-remote, is
      interested in the complete result even if there are errors in
      match_explicit_refs().
      Signed-off-by: NJay Soffian <jaysoffian@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      5f48cb95
    • J
      remote: make match_refs() copy src ref before assigning to peer_ref · cdf690e5
      Jay Soffian 提交于
      In some instances, match_refs() sets the peer_ref field of refs in the
      dst list such that it points to a ref in the src list. This prevents
      callers from freeing both the src and dst lists, as doing so would cause
      a double-free since free_refs() frees the peer_ref.
      
      As well, the following configuration causes two refs in the dst list to
      have the same peer_ref, which can also lead to a double-free:
      
        push = refs/heads/master:refs/heads/backup
        push = refs/heads/master:refs/heads/master
      
      Existing callers of match_heads() call it only once and then terminate,
      w/o ever bothering to free the src or dst lists, so this is not
      currently a problem.
      
      This patch modifies match_refs() to first copy any refs it plucks from
      the src list before assigning them as a peer_ref. This allows
      builtin-remote, a future caller, to free the src and dst lists.
      Signed-off-by: NJay Soffian <jaysoffian@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      cdf690e5
    • J
      remote: let guess_remote_head() optionally return all matches · 4229f1fa
      Jay Soffian 提交于
      Determining HEAD is ambiguous since it is done by comparing SHA1s.
      
      In the case of multiple matches we return refs/heads/master if it
      matches, else we return the first match we encounter. builtin-remote
      needs all matches returned to it, so add a flag for it to request such.
      
      To be simple and consistent, the return value is now a copy (including
      peer_ref) of the matching refs.
      
      Originally contributed by Jeff King along with the prior commit as a
      single patch.
      Signed-off-by: NJay Soffian <jaysoffian@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      4229f1fa
    • J
      remote: make copy_ref() perform a deep copy · 7b3db095
      Jay Soffian 提交于
      To ensure that copied refs can always be freed w/o causing a
      double-free, make copy_ref() perform a deep copy.
      
      Also have copy_ref() return NULL if asked to copy NULL to simplify
      things for the caller.
      
      Background: currently copy_ref() performs a shallow copy. This is fine
      for current callers who never free the result and/or only copy refs
      which contain NULL pointers. But copy_ref() is about to gain a new
      caller (guess_remote_head()) which copies refs where peer_ref is not
      NULL and the caller of guess_remote_head() will want to free the result.
      Signed-off-by: NJay Soffian <jaysoffian@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      7b3db095
  10. 26 2月, 2009 4 次提交
    • J
      remote: simplify guess_remote_head() · 6cb4e6cc
      Jay Soffian 提交于
      This function had complications which made it hard to extend.
      
      - It used to do two things: find the HEAD ref, and then find a
        matching ref, optionally returning the former via assignment to a
        passed-in pointer. Since finding HEAD is a one-liner, just have a
        caller do it themselves and pass it as an argument.
      
      - It used to manually search through the ref list for
        refs/heads/master; this can be a one-line call to
        find_ref_by_name.
      
      Originally contributed by Jeff King along with the next commit as a
      single patch.
      Signed-off-by: NJay Soffian <jaysoffian@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      6cb4e6cc
    • J
      move locate_head() to remote.c · 8ef51733
      Jay Soffian 提交于
      Move locate_head() to remote.c and rename it to guess_remote_head() to
      more accurately reflect what it does. This is in preparation for being
      able to call it from builtin-remote.c
      Signed-off-by: NJay Soffian <jaysoffian@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      8ef51733
    • J
      move duplicated ref_newer() to remote.c · ec8452d5
      Jay Soffian 提交于
      ref_newer() appears to have been copied from builtin-send-pack.c to
      http-push.c via cut and paste. This patch moves the function and its
      helper unmark_and_free() to remote.c. There was a slight difference
      between the two implementations, one used TMP_MARK for the mark, the
      other used 1. Per Jeff King, I went with TMP_MARK as more correct.
      
      This is in preparation for being able to call it from builtin-remote.c
      Signed-off-by: NJay Soffian <jaysoffian@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ec8452d5
    • J
      move duplicated get_local_heads() to remote.c · 454e2025
      Jay Soffian 提交于
      get_local_heads() appears to have been copied from builtin-send-pack.c
      to http-push.c via cut and paste. This patch moves the function and its
      helper one_local_ref() to remote.c.
      
      The two copies of one_local_ref() were not identical. I used the more
      recent version from builtin-send-pack.c after confirming with Jeff King
      that it was an oversight that commit 30affa1e did not update both
      copies.
      
      This is in preparation for being able to call it from builtin-remote.c
      Signed-off-by: NJay Soffian <jaysoffian@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      454e2025
  11. 12 1月, 2009 1 次提交
  12. 12 11月, 2008 2 次提交
  13. 18 10月, 2008 3 次提交
  14. 15 10月, 2008 1 次提交
  15. 13 10月, 2008 1 次提交
  16. 08 10月, 2008 1 次提交
  17. 25 9月, 2008 1 次提交
  18. 10 9月, 2008 1 次提交
  19. 22 8月, 2008 1 次提交
  20. 20 8月, 2008 1 次提交
  21. 02 8月, 2008 1 次提交
    • J
      make sure parsed wildcard refspec ends with slash · b2a56276
      Junio C Hamano 提交于
      A wildcard refspec is internally parsed into a refspec structure with src
      and dst strings.  Many parts of the code assumed that these do not include
      the trailing "/*" when matching the wildcard pattern with an actual ref we
      see at the remote.  What this meant was that we needed to make sure not
      just that the prefix matched, and also that a slash followed the part that
      matched.
      
      But a codepath that scans the result from ls-remote and finds matching
      refs forgot to check the "matching part must be followed by a slash" rule.
      This resulted in "refs/heads/b1" from the remote side to mistakenly match
      the source side of "refs/heads/b/*:refs/remotes/b/*" refspec.
      
      Worse, the refspec crafted internally by "git-clone", and a hardcoded
      preparsed refspec that is used to implement "git-fetch --tags", violated
      this "parsed widcard refspec does not end with slash" rule; simply adding
      the "matching part must be followed by a slash" rule then would have
      broken codepaths that use these refspecs.
      
      This commit changes the rule to require a trailing slash to parsed
      wildcard refspecs.  IOW, "refs/heads/b/*:refs/remotes/b/*" is parsed as
      src = "refs/heads/b/" and dst = "refs/remotes/b/".  This allows us to
      simplify the matching logic because we only need to do a prefixcmp() to
      notice "refs/heads/b/one" matches and "refs/heads/b1" does not.
      Acked-by: NDaniel Barkalow <barkalow@iabervon.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b2a56276
  22. 28 7月, 2008 1 次提交
    • J
      make sure parsed wildcard refspec ends with slash · 47c6ef1c
      Junio C Hamano 提交于
      A wildcard refspec is internally parsed into a refspec structure with src
      and dst strings.  Many parts of the code assumed that these do not include
      the trailing "/*" when matching the wildcard pattern with an actual ref we
      see at the remote.  What this meant was that we needed to make sure not
      just that the prefix matched, and also that a slash followed the part that
      matched.
      
      But a codepath that scans the result from ls-remote and finds matching
      refs forgot to check the "matching part must be followed by a slash" rule.
      This resulted in "refs/heads/b1" from the remote side to mistakenly match
      the source side of "refs/heads/b/*:refs/remotes/b/*" refspec.
      
      Worse, the refspec crafted internally by "git-clone", and a hardcoded
      preparsed refspec that is used to implement "git-fetch --tags", violated
      this "parsed widcard refspec does not end with slash" rule; simply adding
      the "matching part must be followed by a slash" rule then would have
      broken codepaths that use these refspecs.
      
      This commit changes the rule to require a trailing slash to parsed
      wildcard refspecs.  IOW, "refs/heads/b/*:refs/remotes/b/*" is parsed as
      src = "refs/heads/b/" and dst = "refs/remotes/b/".  This allows us to
      simplify the matching logic because we only need to do a prefixcmp() to
      notice "refs/heads/b/one" matches and "refs/heads/b1" does not.
      Acked-by: NDaniel Barkalow <barkalow@iabervon.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      47c6ef1c
  23. 17 7月, 2008 1 次提交
  24. 04 7月, 2008 1 次提交
  25. 03 7月, 2008 1 次提交
    • J
      Refactor "tracking statistics" code used by "git checkout" · 6d21bf96
      Junio C Hamano 提交于
      People seem to like "Your branch is ahead by N commit" report made by
      "git checkout", but the interface into the statistics function was a bit
      clunky.  This splits the function into three parts:
      
       * The core "commit counting" function that takes "struct branch" and
         returns number of commits to show if we are ahead, behind or forked;
      
       * Convenience "stat formating" function that takes "struct branch" and
         formats the report into a given strbuf, using the above function;
      
       * "checkout" specific function that takes "branch_info" (type that is
         internal to checkout implementation), calls the above function and
         print the formatted result.
      
      in the hope that the former two can be more easily reusable.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      6d21bf96
  26. 19 6月, 2008 1 次提交
    • J
      clean up error conventions of remote.c:match_explicit · 9a7bbd1d
      Jeff King 提交于
      match_explicit is called for each push refspec to try to
      fully resolve the source and destination sides of the
      refspec.  Currently, we look at each refspec and report
      errors on both the source and the dest side before aborting.
      
      It makes sense to report errors for each refspec, since an
      error in one is independent of an error in the other.
      However, reporting errors on the 'dst' side of a refspec if
      there has been an error on the 'src' side does not
      necessarily make sense, since the interpretation of the
      'dst' side depends on the 'src' side (for example, when
      creating a new unqualified remote ref, we use the same type
      as the src ref).
      
      This patch lets match_explicit return early when the src
      side of the refspec is bogus. We still look at all of the
      refspecs before aborting the push, though.
      
      At the same time, we clean up the call signature, which
      previously took an extra "errs" flag. This was pointless, as
      we didn't act on that flag, but rather just passed it back
      to the caller. Instead, we now use the more traditional
      "return -1" to signal an error, and the caller aggregates
      the error count.
      
      This change fixes two bugs, as well:
      
        - the early return avoids a segfault when passing a NULL
          matched_src to guess_ref()
      
        - the check for multiple sources pointing to a single dest
          aborted if the "err" flag was set. Presumably the intent
          was not to bother with the check if we had no
          matched_src. However, since the err flag was passed in
          from the caller, we might abort the check just because a
          previous refspec had a problem, which doesn't make
          sense.
      
          In practice, this didn't matter, since due to the error
          flag we end up aborting the push anyway.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      9a7bbd1d