1. 16 1月, 2019 1 次提交
  2. 06 11月, 2018 1 次提交
    • J
      assert NOARG/NONEG behavior of parse-options callbacks · 517fe807
      Jeff King 提交于
      When we define a parse-options callback, the flags we put in the option
      struct must match what the callback expects. For example, a callback
      which does not handle the "unset" parameter should only be used with
      PARSE_OPT_NONEG. But since the callback and the option struct are not
      defined next to each other, it's easy to get this wrong (as earlier
      patches in this series show).
      
      Fortunately, the compiler can help us here: compiling with
      -Wunused-parameters can show us which callbacks ignore their "unset"
      parameters (and likewise, ones that ignore "arg" expect to be triggered
      with PARSE_OPT_NOARG).
      
      But after we've inspected a callback and determined that all of its
      callers use the right flags, what do we do next? We'd like to silence
      the compiler warning, but do so in a way that will catch any wrong calls
      in the future.
      
      We can do that by actually checking those variables and asserting that
      they match our expectations. Because this is such a common pattern,
      we'll introduce some helper macros. The resulting messages aren't
      as descriptive as we could make them, but the file/line information from
      BUG() is enough to identify the problem (and anyway, the point is that
      these should never be seen).
      
      Each of the annotated callbacks in this patch triggers
      -Wunused-parameters, and was manually inspected to make sure all callers
      use the correct options (so none of these BUGs should be triggerable).
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      517fe807
  3. 01 11月, 2018 1 次提交
    • J
      fetch: replace string-list used as a look-up table with a hashmap · e198b3a7
      Junio C Hamano 提交于
      In find_non_local_tags() helper function (used to implement the
      "follow tags"), we use string_list_has_string() on two string lists
      as a way to see if a refname has already been processed, etc.
      
      All this code predates more modern in-core lookup API like hashmap;
      replace them with two hashmaps and one string list---the hashmaps
      are used for look-ups and the string list is to keep the order of
      items in the returned result stable (which is the only single thing
      hashmap does worse than lookups on string-list).
      
      Similarly, get_ref_map() uses another string-list as a look-up table
      for existing refs.  Replace it with a hashmap.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      e198b3a7
  4. 07 10月, 2018 1 次提交
  5. 22 9月, 2018 1 次提交
    • J
      fetch: in partial clone, check presence of targets · 35f9e3e5
      Jonathan Tan 提交于
      When fetching an object that is known as a promisor object to the local
      repository, the connectivity check in quickfetch() in builtin/fetch.c
      succeeds, causing object transfer to be bypassed. However, this should
      not happen if that object is merely promised and not actually present.
      
      Because this happens, when a user invokes "git fetch origin <sha-1>" on
      the command-line, the <sha-1> object may not actually be fetched even
      though the command returns an exit code of 0. This is a similar issue
      (but with a different cause) to the one fixed by a0c9016a
      ("upload-pack: send refs' objects despite "filter"", 2018-07-09).
      
      Therefore, update quickfetch() to also directly check for the presence
      of all objects to be fetched. Its documentation and name are also
      updated to better reflect what it does.
      Signed-off-by: NJonathan Tan <jonathantanmy@google.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      35f9e3e5
  6. 01 9月, 2018 2 次提交
    • Æ
      fetch: stop clobbering existing tags without --force · 0bc8d71b
      Ævar Arnfjörð Bjarmason 提交于
      Change "fetch" to treat "+" in refspecs (aka --force) to mean we
      should clobber a local tag of the same name.
      
      This changes the long-standing behavior of "fetch" added in
      853a3697 ("[PATCH] Multi-head fetch.", 2005-08-20). Before this
      change, all tag fetches effectively had --force enabled. See the
      git-fetch-script code in fast_forward_local() with the comment:
      
          > Tags need not be pointing at commits so there is no way to
          > guarantee "fast-forward" anyway.
      
      That commit and the rest of the history of "fetch" shows that the
      "+" (--force) part of refpecs was only conceived for branch updates,
      while tags have accepted any changes from upstream unconditionally and
      clobbered the local tag object. Changing this behavior has been
      discussed as early as 2011[1].
      
      The current behavior doesn't make sense to me, it easily results in
      local tags accidentally being clobbered. We could namespace our tags
      per-remote and not locally populate refs/tags/*, but as with my
      97716d21 ("fetch: add a --prune-tags option and fetch.pruneTags
      config", 2018-02-09) it's easier to work around the current
      implementation than to fix the root cause.
      
      So this change implements suggestion #1 from Jeff's 2011 E-Mail[1],
      "fetch" now only clobbers the tag if either "+" is provided as part of
      the refspec, or if "--force" is provided on the command-line.
      
      This also makes it nicely symmetrical with how "tag" itself works when
      creating tags. I.e. we refuse to clobber any existing tags unless
      "--force" is supplied. Now we can refuse all such clobbering, whether
      it would happen by clobbering a local tag with "tag", or by fetching
      it from the remote with "fetch".
      
      Ref updates outside refs/{tags,heads/* are still still not symmetrical
      with how "git push" works, as discussed in the recently changed
      pull-fetch-param.txt documentation. This change brings the two
      divergent behaviors more into line with one another. I don't think
      there's any reason "fetch" couldn't fully converge with the behavior
      used by "push", but that's a topic for another change.
      
      One of the tests added in 31b808a0 ("clone --single: limit the fetch
      refspec to fetched branch", 2012-09-20) is being changed to use
      --force where a clone would clobber a tag. This changes nothing about
      the existing behavior of the test.
      
      1. https://public-inbox.org/git/20111123221658.GA22313@sigill.intra.peff.net/Signed-off-by: NÆvar Arnfjörð Bjarmason <avarab@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      0bc8d71b
    • Æ
      fetch: change "branch" to "reference" in --force -h output · 8cd4b7c1
      Ævar Arnfjörð Bjarmason 提交于
      The -h output has been referring to the --force command as forcing the
      overwriting of local branches, but since "fetch" more generally
      fetches all sorts of references in all refs/ namespaces, let's talk
      about forcing the update of a a "reference" instead.
      
      This wording was initially introduced in 83201998 ("Rewrite
      builtin-fetch option parsing to use parse_options().", 2007-12-04).
      Signed-off-by: NÆvar Arnfjörð Bjarmason <avarab@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      8cd4b7c1
  7. 30 8月, 2018 2 次提交
    • J
      convert "hashcmp() == 0" to hasheq() · e3ff0683
      Jeff King 提交于
      This is the partner patch to the previous one, but covering
      the "hash" variants instead of "oid".  Note that our
      coccinelle rule is slightly more complex to avoid triggering
      the call in hasheq().
      
      I didn't bother to add a new rule to convert:
      
        - hasheq(E1->hash, E2->hash)
        + oideq(E1, E2)
      
      Since these are new functions, there won't be any such
      existing callers. And since most of the code is already
      using oideq, we're not likely to introduce new ones.
      
      We might still see "!hashcmp(E1->hash, E2->hash)" from topics
      in flight. But because our new rule comes after the existing
      ones, that should first get converted to "!oidcmp(E1, E2)"
      and then to "oideq(E1, E2)".
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      e3ff0683
    • 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
  8. 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
  9. 24 7月, 2018 1 次提交
    • J
      fetch: send "refs/tags/" prefix upon CLI refspecs · 2b554353
      Jonathan Tan 提交于
      When performing tag following, in addition to using the server's
      "include-tag" capability to send tag objects (and emulating it if the
      server does not support that capability), "git fetch" relies upon the
      presence of refs/tags/* entries in the initial ref advertisement to
      locally create refs pointing to the aforementioned tag objects. When
      using protocol v2, refs/tags/* entries in the initial ref advertisement
      may be suppressed by a ref-prefix argument, leading to the tag object
      being downloaded, but the ref not being created.
      
      Commit dcc73cf7 ("fetch: generate ref-prefixes when using a configured
      refspec", 2018-05-18) ensured that "refs/tags/" is always sent as a ref
      prefix when "git fetch" is invoked with no refspecs, but not when "git
      fetch" is invoked with refspecs. Extend that functionality to make it
      work in both situations.
      
      This also necessitates a change another test which tested ref
      advertisement filtering using tag refs - since tag refs are sent by
      default now, the test has been switched to using branch refs instead.
      Signed-off-by: NJonathan Tan <jonathantanmy@google.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      2b554353
  10. 21 7月, 2018 1 次提交
  11. 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
  12. 30 6月, 2018 1 次提交
  13. 29 6月, 2018 4 次提交
  14. 27 6月, 2018 1 次提交
  15. 24 5月, 2018 1 次提交
  16. 18 5月, 2018 14 次提交
  17. 16 5月, 2018 1 次提交
    • S
      object-store: move object access functions to object-store.h · cbd53a21
      Stefan Beller 提交于
      This should make these functions easier to find and cache.h less
      overwhelming to read.
      
      In particular, this moves:
      - read_object_file
      - oid_object_info
      - write_object_file
      
      As a result, most of the codebase needs to #include object-store.h.
      In this patch the #include is only added to files that would fail to
      compile otherwise.  It would be better to #include wherever
      identifiers from the header are used.  That can happen later
      when we have better tooling for it.
      Signed-off-by: NStefan Beller <sbeller@google.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      cbd53a21
  18. 26 4月, 2018 1 次提交
  19. 24 4月, 2018 1 次提交
  20. 27 3月, 2018 1 次提交
  21. 16 3月, 2018 1 次提交