1. 15 10月, 2018 1 次提交
  2. 09 10月, 2018 4 次提交
    • T
      transport.c: introduce core.alternateRefsPrefixes · 40f327fa
      Taylor Blau 提交于
      The recently-introduced "core.alternateRefsCommand" allows callers to
      specify with high flexibility the tips that they wish to advertise from
      alternates. This flexibility comes at the cost of some inconvenience
      when the caller only wishes to limit the advertisement to one or more
      prefixes.
      
      For example, to advertise only tags, a caller using
      'core.alternateRefsCommand' would have to do:
      
        $ git config core.alternateRefsCommand ' \
            f() { git -C "$1" for-each-ref \
                    refs/tags --format="%(objectname)" }; f "$@"'
      
      The above is cumbersome to write, so let's introduce a
      "core.alternateRefsPrefixes" to address this common case. Instead, the
      caller can run:
      
        $ git config core.alternateRefsPrefixes 'refs/tags'
      
      Which will behave identically to the longer example using
      "core.alternateRefsCommand".
      
      Since the value of "core.alternateRefsPrefixes" is appended to 'git
      for-each-ref' and then executed, include a "--" before taking the
      configured value to avoid misinterpreting arguments as flags to 'git
      for-each-ref'.
      
      In the case that the caller wishes to specify multiple prefixes, they
      may separate them by whitespace. If "core.alternateRefsCommand" is set,
      it will take precedence over "core.alternateRefsPrefixes".
      Signed-off-by: NTaylor Blau <me@ttaylorr.com>
      Acked-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      40f327fa
    • T
      transport.c: introduce core.alternateRefsCommand · 89284c1d
      Taylor Blau 提交于
      When in a repository containing one or more alternates, Git would
      sometimes like to list references from those alternates. For example,
      'git receive-pack' lists the "tips" pointed to by references in those
      alternates as special ".have" references.
      
      Listing ".have" references is designed to make pushing changes from
      upstream to a fork a lightweight operation, by advertising to the pusher
      that the fork already has the objects (via its alternate). Thus, the
      client can avoid sending them.
      
      However, when the alternate (upstream, in the previous example) has a
      pathologically large number of references, the initial advertisement is
      too expensive. In fact, it can dominate any such optimization where the
      pusher avoids sending certain objects.
      
      Introduce "core.alternateRefsCommand" in order to provide a facility to
      limit or filter alternate references. This can be used, for example, to
      filter out references the alternate does not wish to send (for space
      concerns, or otherwise) during the initial advertisement.
      
      Let the repository that has alternates configure this command to avoid
      trusting the alternate to provide us a safe command to run in the shell.
      To find the alternate, pass its absolute path as the first argument.
      Signed-off-by: NTaylor Blau <me@ttaylorr.com>
      Acked-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      89284c1d
    • T
      transport.c: extract 'fill_alternate_refs_command' · 1e5f31d4
      Taylor Blau 提交于
      To list alternate references, 'read_alternate_refs' creates a child
      process running 'git for-each-ref' in the alternate's Git directory.
      
      Prepare to run other commands besides 'git for-each-ref' by introducing
      and moving the relevant code from 'read_alternate_refs' to
      'fill_alternate_refs_command'.
      Signed-off-by: NTaylor Blau <me@ttaylorr.com>
      Acked-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      1e5f31d4
    • J
      transport: drop refnames from for_each_alternate_ref · bdf4276c
      Jeff King 提交于
      None of the current callers use the refname parameter we pass to their
      callbacks. In theory somebody _could_ do so, but it's actually quite
      weird if you think about it: it's a ref in somebody else's repository.
      So the name has no meaning locally, and in fact there may be duplicates
      if there are multiple alternates.
      
      The users of this interface really only care about seeing some ref tips,
      since that promises that the alternate has the full commit graph
      reachable from there. So let's keep the information we pass back to the
      bare minimum.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NTaylor Blau <me@ttaylorr.com>
      Acked-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      bdf4276c
  3. 07 10月, 2018 3 次提交
    • J
      transport: list refs before fetch if necessary · 6ab40557
      Jonathan Tan 提交于
      The built-in bundle transport and the transport helper interface do not
      work when transport_fetch_refs() is called immediately after transport
      creation. This will be needed in a subsequent patch, so fix this.
      
      Evidence: fetch_refs_from_bundle() relies on data->header being
      initialized in get_refs_from_bundle(), and fetch() in transport-helper.c
      relies on either data->fetch or data->import being set by get_helper(),
      but neither transport_helper_init() nor fetch() calls get_helper().
      
      Up until the introduction of the partial clone feature, this has not
      been a problem, because transport_fetch_refs() is always called after
      transport_get_remote_refs(). With the introduction of the partial clone
      feature, which involves calling transport_fetch_refs() (to fetch objects
      by their OIDs) without transport_get_remote_refs(), this is still not a
      problem, but only coincidentally - we do not support partially cloning a
      bundle, and as for cloning using a transport-helper-using protocol, it
      so happens that before transport_fetch_refs() is called, fetch_refs() in
      fetch-object.c calls transport_set_option(), which means that the
      aforementioned get_helper() is invoked through set_helper_option() in
      transport-helper.c.
      
      This could be fixed by fixing the transports themselves, but it doesn't
      seem like a good idea to me to open up previously untested code paths;
      also, there may be transport helpers in the wild that assume that "list"
      is always called before "fetch". Instead, fix this by having
      transport_fetch_refs() call transport_get_remote_refs() to ensure that
      the latter is always called at least once, unless the transport
      explicitly states that it supports fetching without listing refs.
      Signed-off-by: NJonathan Tan <jonathantanmy@google.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      6ab40557
    • J
      transport: do not list refs if possible · 01775651
      Jonathan Tan 提交于
      When all refs to be fetched are exact OIDs, it is possible to perform a
      fetch without requiring the remote to list refs if protocol v2 is used.
      Teach Git to do this.
      
      This currently has an effect only for lazy fetches done from partial
      clones. The change necessary to likewise optimize "git fetch <remote>
      <sha-1>" will be done in a subsequent patch.
      Signed-off-by: NJonathan Tan <jonathantanmy@google.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      01775651
    • J
      transport: allow skipping of ref listing · 99bcb883
      Jonathan Tan 提交于
      The get_refs_via_connect() function both performs the handshake
      (including determining the protocol version) and obtaining the list of
      remote refs. However, the fetch protocol v2 supports fetching objects
      without the listing of refs, so make it possible for the user to skip
      the listing by creating a new handshake() function. This will be used in
      a subsequent commit.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      99bcb883
  4. 22 9月, 2018 1 次提交
  5. 30 8月, 2018 1 次提交
    • J
      convert "oidcmp() == 0" to oideq() · 4a7e27e9
      Jeff King 提交于
      Using the more restrictive oideq() should, in the long run,
      give the compiler more opportunities to optimize these
      callsites. For now, this conversion should be a complete
      noop with respect to the generated code.
      
      The result is also perhaps a little more readable, as it
      avoids the "zero is equal" idiom. Since it's so prevalent in
      C, I think seasoned programmers tend not to even notice it
      anymore, but it can sometimes make for awkward double
      negations (e.g., we can drop a few !!oidcmp() instances
      here).
      
      This patch was generated almost entirely by the included
      coccinelle patch. This mechanical conversion should be
      completely safe, because we check explicitly for cases where
      oidcmp() is compared to 0, which is what oideq() is doing
      under the hood. Note that we don't have to catch "!oidcmp()"
      separately; coccinelle's standard isomorphisms make sure the
      two are treated equivalently.
      
      I say "almost" because I did hand-edit the coccinelle output
      to fix up a few style violations (it mostly keeps the
      original formatting, but sometimes unwraps long lines).
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      4a7e27e9
  6. 02 8月, 2018 1 次提交
    • J
      fetch-pack: unify ref in and out param · e2842b39
      Jonathan Tan 提交于
      When a user fetches:
       - at least one up-to-date ref and at least one non-up-to-date ref,
       - using HTTP with protocol v0 (or something else that uses the fetch
         command of a remote helper)
      some refs might not be updated after the fetch.
      
      This bug was introduced in commit 989b8c44 ("fetch-pack: put shallow
      info in output parameter", 2018-06-28) which allowed transports to
      report the refs that they have fetched in a new out-parameter
      "fetched_refs". If they do so, transport_fetch_refs() makes this
      information available to its caller.
      
      Users of "fetched_refs" rely on the following 3 properties:
       (1) it is the complete list of refs that was passed to
           transport_fetch_refs(),
       (2) it has shallow information (REF_STATUS_REJECT_SHALLOW set if
           relevant), and
       (3) it has updated OIDs if ref-in-want was used (introduced after
           989b8c44).
      
      In an effort to satisfy (1), whenever transport_fetch_refs()
      filters the refs sent to the transport, it re-adds the filtered refs to
      whatever the transport supplies before returning it to the user.
      However, the implementation in 989b8c44 unconditionally re-adds the
      filtered refs without checking if the transport refrained from reporting
      anything in "fetched_refs" (which it is allowed to do), resulting in an
      incomplete list, no longer satisfying (1).
      
      An earlier effort to resolve this [1] solved the issue by readding the
      filtered refs only if the transport did not refrain from reporting in
      "fetched_refs", but after further discussion, it seems that the better
      solution is to revert the API change that introduced "fetched_refs".
      This API change was first suggested as part of a ref-in-want
      implementation that allowed for ref patterns and, thus, there could be
      drastic differences between the input refs and the refs actually fetched
      [2]; we eventually decided to only allow exact ref names, but this API
      change remained even though its necessity was decreased.
      
      Therefore, revert this API change by reverting commit 989b8c44, and
      make receive_wanted_refs() update the OIDs in the sought array (like how
      update_shallow() updates shallow information in the sought array)
      instead. A test is also included to show that the user-visible bug
      discussed at the beginning of this commit message no longer exists.
      
      [1] https://public-inbox.org/git/20180801171806.GA122458@google.com/
      [2] https://public-inbox.org/git/86a128c5fb710a41791e7183207c4d64889f9307.1485381677.git.jonathantanmy@google.com/Signed-off-by: NJonathan Tan <jonathantanmy@google.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      e2842b39
  7. 24 7月, 2018 2 次提交
  8. 04 7月, 2018 2 次提交
    • J
      fetch-pack: support negotiation tip whitelist · 3390e42a
      Jonathan Tan 提交于
      During negotiation, fetch-pack eventually reports as "have" lines all
      commits reachable from all refs. Allow the user to restrict the commits
      sent in this way by providing a whitelist of tips; only the tips
      themselves and their ancestors will be sent.
      
      Both globs and single objects are supported.
      
      This feature is only supported for protocols that support connect or
      stateless-connect (such as HTTP with protocol v2).
      
      This will speed up negotiation when the repository has multiple
      relatively independent branches (for example, when a repository
      interacts with multiple repositories, such as with linux-next [1] and
      torvalds/linux [2]), and the user knows which local branch is likely to
      have commits in common with the upstream branch they are fetching.
      
      [1] https://kernel.googlesource.com/pub/scm/linux/kernel/git/next/linux-next/
      [2] https://kernel.googlesource.com/pub/scm/linux/kernel/git/torvalds/linux/Signed-off-by: NJonathan Tan <jonathantanmy@google.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      3390e42a
    • J
      fetch-pack: write shallow, then check connectivity · cf1e7c07
      Jonathan Tan 提交于
      When fetching, connectivity is checked after the shallow file is
      updated. There are 2 issues with this: (1) the connectivity check is
      only performed up to ancestors of existing refs (which is not thorough
      enough if we were deepening an existing ref in the first place), and (2)
      there is no rollback of the shallow file if the connectivity check
      fails.
      
      To solve (1), update the connectivity check to check the ancestry chain
      completely in the case of a deepening fetch by refraining from passing
      "--not --all" when invoking rev-list in connected.c.
      
      To solve (2), have fetch_pack() perform its own connectivity check
      before updating the shallow file. To support existing use cases in which
      "git fetch-pack" is used to download objects without much regard as to
      the connectivity of the resulting objects with respect to the existing
      repository, the connectivity check is only done if necessary (that is,
      the fetch is not a clone, and the fetch involves shallow/deepen
      functionality). "git fetch" still performs its own connectivity check,
      preserving correctness but sometimes performing redundant work. This
      redundancy is mitigated by the fact that fetch_pack() reports if it has
      performed a connectivity check itself, and if the transport supports
      connect or stateless-connect, it will bubble up that report so that "git
      fetch" knows not to perform the connectivity check in such a case.
      
      This was noticed when a user tried to deepen an existing repository by
      fetching with --no-shallow from a server that did not send all necessary
      objects - the connectivity check as run by "git fetch" succeeded, but a
      subsequent "git fsck" failed.
      Signed-off-by: NJonathan Tan <jonathantanmy@google.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      cf1e7c07
  9. 29 6月, 2018 1 次提交
    • B
      fetch-pack: put shallow info in output parameter · 989b8c44
      Brandon Williams 提交于
      Expand the transport fetch method signature, by adding an output
      parameter, to allow transports to return information about the refs they
      have fetched.  Then communicate shallow status information through this
      mechanism instead of by modifying the input list of refs.
      
      This does require clients to sometimes generate the ref map twice: once
      from the list of refs provided by the remote (as is currently done) and
      potentially once from the new list of refs that the fetch mechanism
      provides.
      Signed-off-by: NBrandon Williams <bmwill@google.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      989b8c44
  10. 18 5月, 2018 9 次提交
  11. 06 5月, 2018 1 次提交
    • J
      Replace all die("BUG: ...") calls by BUG() ones · 033abf97
      Johannes Schindelin 提交于
      In d8193743 (usage.c: add BUG() function, 2017-05-12), a new macro
      was introduced to use for reporting bugs instead of die(). It was then
      subsequently used to convert one single caller in 588a538a
      (setup_git_env: convert die("BUG") to BUG(), 2017-05-12).
      
      The cover letter of the patch series containing this patch
      (cf 20170513032414.mfrwabt4hovujde2@sigill.intra.peff.net) is not
      terribly clear why only one call site was converted, or what the plan
      is for other, similar calls to die() to report bugs.
      
      Let's just convert all remaining ones in one fell swoop.
      
      This trick was performed by this invocation:
      
      	sed -i 's/die("BUG: /BUG("/g' $(git grep -l 'die("BUG' \*.c)
      Signed-off-by: NJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      033abf97
  12. 24 4月, 2018 3 次提交
    • B
      fetch: send server options when using protocol v2 · 5e3548ef
      Brandon Williams 提交于
      Teach fetch to optionally accept server options by specifying them on
      the cmdline via '-o' or '--server-option'.  These server options are
      sent to the remote end when performing a fetch communicating using
      protocol version 2.
      
      If communicating using a protocol other than v2 the provided options are
      ignored and not sent to the remote end.
      Signed-off-by: NBrandon Williams <bmwill@google.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      5e3548ef
    • B
      ls-remote: send server options when using protocol v2 · ff473221
      Brandon Williams 提交于
      Teach ls-remote to optionally accept server options by specifying them
      on the cmdline via '-o' or '--server-option'.  These server options are
      sent to the remote end when querying for the remote end's refs using
      protocol version 2.
      
      If communicating using a protocol other than v2 the provided options are
      ignored and not sent to the remote end.
      Signed-off-by: NBrandon Williams <bmwill@google.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ff473221
    • R
      push: colorize errors · 960786e7
      Ryan Dammrose 提交于
      This is an attempt to resolve an issue I experience with people that are
      new to Git -- especially colleagues in a team setting -- where they miss
      that their push to a remote location failed because the failure and
      success both return a block of white text.
      
      An example is if I push something to a remote repository and then a
      colleague attempts to push to the same remote repository and the push
      fails because it requires them to pull first, but they don't notice
      because a success and failure both return a block of white text. They
      then continue about their business, thinking it has been successfully
      pushed.
      
      This patch colorizes the errors and hints (in red and yellow,
      respectively) so whenever there is a failure when pushing to a remote
      repository that fails, it is more noticeable.
      
      [jes: fixed a couple bugs, added the color.{advice,push,transport}
      settings, refactored to use want_color_stderr().]
      
      Signed-off-by: Ryan Dammrose ryandammrose@gmail.com
      Signed-off-by: NJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      960786e7
  13. 24 3月, 2018 1 次提交
  14. 16 3月, 2018 6 次提交
  15. 15 3月, 2018 4 次提交