1. 22 9月, 2018 1 次提交
  2. 30 8月, 2018 2 次提交
    • J
      convert "oidcmp() != 0" to "!oideq()" · 9001dc2a
      Jeff King 提交于
      This is the flip side of the previous two patches: checking
      for a non-zero oidcmp() can be more strictly expressed as
      inequality. Like those patches, we write "!= 0" in the
      coccinelle transformation, which covers by isomorphism the
      more common:
      
        if (oidcmp(E1, E2))
      
      As with the previous two patches, this patch can be achieved
      almost entirely by running "make coccicheck"; the only
      differences are manual line-wrap fixes to match the original
      code.
      
      There is one thing to note for anybody replicating this,
      though: coccinelle 1.0.4 seems to miss the case in
      builtin/tag.c, even though it's basically the same as all
      the others. Running with 1.0.7 does catch this, so
      presumably it's just a coccinelle bug that was fixed in the
      interim.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      9001dc2a
    • 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
  3. 03 8月, 2018 1 次提交
    • J
      remote: make refspec follow the same disambiguation rule as local refs · 60650a48
      Junio C Hamano 提交于
      When matching a non-wildcard LHS of a refspec against a list of
      refs, find_ref_by_name_abbrev() returns the first ref that matches
      using any DWIM rules used by refname_match() in refs.c, even if a
      better match occurs later in the list of refs.
      
      This causes unexpected behavior when (for example) fetching using
      the refspec "refs/heads/s:<something>" from a remote with both
      "refs/heads/refs/heads/s" and "refs/heads/s"; even if the former was
      inadvertently created, one would still expect the latter to be
      fetched.  Similarly, when both a tag T and a branch T exist,
      fetching T should favor the tag, just like how local refname
      disambiguation rule works.  But because the code walks over
      ls-remote output from the remote, which happens to be sorted in
      alphabetical order and has refs/heads/T before refs/tags/T, a
      request to fetch T is (mis)interpreted as fetching refs/heads/T.
      
      Update refname_match(), all of whose current callers care only if it
      returns non-zero (i.e. matches) to see if an abbreviated name can
      mean the full name being tested, so that it returns a positive
      integer whose magnitude can be used to tell the precedence, and fix
      the find_ref_by_name_abbrev() function not to stop at the first
      match but find the match with the highest precedence.
      
      This is based on an earlier work, which special cased only the exact
      matches, by Jonathan Tan.
      Helped-by: NJonathan Tan <jonathantanmy@google.com>
      Helped-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      60650a48
  4. 21 7月, 2018 2 次提交
  5. 30 6月, 2018 4 次提交
  6. 29 6月, 2018 1 次提交
    • B
      fetch-pack: implement ref-in-want · 73302051
      Brandon Williams 提交于
      Implement ref-in-want on the client side so that when a server supports
      the "ref-in-want" feature, a client will send "want-ref" lines for each
      reference the client wants to fetch.  This feature allows clients to
      tolerate inconsistencies that exist when a remote repository's refs
      change during the course of negotiation.
      
      This allows a client to request to request a particular ref without
      specifying the OID of the ref.  This means that instead of hitting an
      error when a ref no longer points at the OID it did at the beginning of
      negotiation, negotiation can continue and the value of that ref will be
      sent at the termination of negotiation, just before a packfile is sent.
      
      More information on the ref-in-want feature can be found in
      Documentation/technical/protocol-v2.txt.
      Signed-off-by: NBrandon Williams <bmwill@google.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      73302051
  7. 18 5月, 2018 14 次提交
  8. 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
  9. 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
  10. 26 4月, 2018 1 次提交
  11. 15 3月, 2018 1 次提交
    • B
      sha1_file: convert sha1_object_info* to object_id · abef9020
      brian m. carlson 提交于
      Convert sha1_object_info and sha1_object_info_extended to take pointers
      to struct object_id and rename them to use "oid" instead of "sha1" in
      their names.  Update the declaration and definition and apply the
      following semantic patch, plus the standard object_id transforms:
      
      @@
      expression E1, E2;
      @@
      - sha1_object_info(E1.hash, E2)
      + oid_object_info(&E1, E2)
      
      @@
      expression E1, E2;
      @@
      - sha1_object_info(E1->hash, E2)
      + oid_object_info(E1, E2)
      
      @@
      expression E1, E2, E3;
      @@
      - sha1_object_info_extended(E1.hash, E2, E3)
      + oid_object_info_extended(&E1, E2, E3)
      
      @@
      expression E1, E2, E3;
      @@
      - sha1_object_info_extended(E1->hash, E2, E3)
      + oid_object_info_extended(E1, E2, E3)
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      abef9020
  12. 23 2月, 2018 1 次提交
  13. 10 2月, 2018 2 次提交
    • Æ
      fetch: add a --prune-tags option and fetch.pruneTags config · 97716d21
      Ævar Arnfjörð Bjarmason 提交于
      Add a --prune-tags option to git-fetch, along with fetch.pruneTags
      config option and a -P shorthand (-p is --prune). This allows for
      doing any of:
      
          git fetch -p -P
          git fetch --prune --prune-tags
          git fetch -p -P origin
          git fetch --prune --prune-tags origin
      
      Or simply:
      
          git config fetch.prune true &&
          git config fetch.pruneTags true &&
          git fetch
      
      Instead of the much more verbose:
      
          git fetch --prune origin 'refs/tags/*:refs/tags/*' '+refs/heads/*:refs/remotes/origin/*'
      
      Before this feature it was painful to support the use-case of pulling
      from a repo which is having both its branches *and* tags deleted
      regularly, and have our local references to reflect upstream.
      
      At work we create deployment tags in the repo for each rollout, and
      there's *lots* of those, so they're archived within weeks for
      performance reasons.
      
      Without this change it's hard to centrally configure such repos in
      /etc/gitconfig (on servers that are only used for working with
      them). You need to set fetch.prune=true globally, and then for each
      repo:
      
          git -C {} config --replace-all remote.origin.fetch "refs/tags/*:refs/tags/*" "^\+*refs/tags/\*:refs/tags/\*$"
      
      Now I can simply set fetch.pruneTags=true in /etc/gitconfig as well,
      and users running "git pull" will automatically get the pruning
      semantics I want.
      
      Even though "git remote" has corresponding "prune" and "update
      --prune" subcommands I'm intentionally not adding a corresponding
      prune-tags or "update --prune --prune-tags" mode to that command.
      
      It's advertised (as noted in my recent "git remote doc: correct
      dangerous lies about what prune does") as only modifying remote
      tracking references, whereas any --prune-tags option is always going
      to modify what from the user's perspective is a local copy of the tag,
      since there's no such thing as a remote tracking tag.
      
      Ideally add_prune_tags_to_fetch_refspec() would be something that
      would use ALLOC_GROW() to grow the 'fetch` member of the 'remote'
      struct. Instead I'm realloc-ing remote->fetch and adding the
      tag_refspec to the end.
      
      The reason is that parse_{fetch,push}_refspec which allocate the
      refspec (ultimately remote->fetch) struct are called many places that
      don't have access to a 'remote' struct. It would be hard to change all
      their callsites to be amenable to carry around the bookkeeping
      variables required for dynamic allocation.
      
      All the other callers of the API first incrementally construct the
      string version of the refspec in remote->fetch_refspec via
      add_fetch_refspec(), before finally calling parse_fetch_refspec() via
      some variation of remote_get().
      
      It's less of a pain to deal with the one special case that needs to
      modify already constructed refspecs than to chase down and change all
      the other callsites. The API I'm adding is intentionally not
      generalized because if we add more of these we'd probably want to
      re-visit how this is done.
      
      See my "Re: [BUG] git remote prune removes local tags, depending on
      fetch config" (87po6ahx87.fsf@evledraar.gmail.com;
      https://public-inbox.org/git/87po6ahx87.fsf@evledraar.gmail.com/) for
      more background info.
      Signed-off-by: NÆvar Arnfjörð Bjarmason <avarab@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      97716d21
    • Æ
      remote: add a macro for "refs/tags/*:refs/tags/*" · 750d0da9
      Ævar Arnfjörð Bjarmason 提交于
      Add a macro with the refspec string "refs/tags/*:refs/tags/*". There's
      been a pre-defined struct version of this since e0aaa29f ("Have a
      constant extern refspec for "--tags"", 2008-04-17), but nothing that
      could be passed to e.g. add_fetch_refspec().
      
      This will be used in subsequent commits to avoid hardcoding this
      string in multiple places.
      Signed-off-by: NÆvar Arnfjörð Bjarmason <avarab@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      750d0da9
  14. 25 1月, 2018 3 次提交
  15. 08 11月, 2017 1 次提交
    • J
      for-each-ref: let upstream/push report the remote ref name · 9700fae5
      J Wyman 提交于
      There are times when scripts want to know not only the name of the
      push branch on the remote, but also the name of the branch as known
      by the remote repository.
      
      An example of this is when a tool wants to push to the very same branch
      from which it would pull automatically, i.e. the `<remote>` and the `<to>`
      in `git push <remote> <from>:<to>` would be provided by
      `%(upstream:remotename)` and `%(upstream:remoteref)`, respectively.
      
      This patch offers the new suffix :remoteref for the `upstream` and `push`
      atoms, allowing to show exactly that. Example:
      
      	$ cat .git/config
      	...
      	[remote "origin"]
      		url = https://where.do.we.come/from
      		fetch = refs/heads/*:refs/remote/origin/*
      	[branch "master"]
      		remote = origin
      		merge = refs/heads/master
      	[branch "develop/with/topics"]
      		remote = origin
      		merge = refs/heads/develop/with/topics
      	...
      
      	$ git for-each-ref \
      		--format='%(push) %(push:remoteref)' \
      		refs/heads
      	refs/remotes/origin/master refs/heads/master
      	refs/remotes/origin/develop/with/topics refs/heads/develop/with/topics
      Signed-off-by: NJ Wyman <jwyman@microsoft.com>
      Signed-off-by: NJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      9700fae5
  16. 16 10月, 2017 2 次提交
  17. 24 9月, 2017 1 次提交
  18. 24 8月, 2017 1 次提交