]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
3 years agosubmodule: pass repo to check_has_commit()
Jonathan Tan [Fri, 8 Oct 2021 21:08:19 +0000 (14:08 -0700)] 
submodule: pass repo to check_has_commit()

Pass the repo explicitly when calling check_has_commit() to avoid
relying on add_submodule_odb(). With this commit and the parent commit,
the last remaining tests no longer rely on add_submodule_odb(), so mark
these tests accordingly.

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoobject-file: only register submodule ODB if needed
Jonathan Tan [Fri, 8 Oct 2021 21:08:18 +0000 (14:08 -0700)] 
object-file: only register submodule ODB if needed

In a35e03dee0 ("submodule: lazily add submodule ODBs as alternates",
2021-09-08), Git was taught to add all known submodule ODBs as
alternates when attempting to read an object that doesn't exist, as a
fallback for when a submodule object is read as if it were in
the_repository. However, this behavior wasn't restricted to happen only
when reading from the_repository. Fix this.

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agomerge-{ort,recursive}: remove add_submodule_odb()
Jonathan Tan [Fri, 8 Oct 2021 21:08:17 +0000 (14:08 -0700)] 
merge-{ort,recursive}: remove add_submodule_odb()

After the parent commit and some of its ancestors, the only place
commits are being accessed through alternates is in the user-facing
message formatting code. Fix those, and remove the add_submodule_odb()
calls.

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agorefs: peeling non-the_repository iterators is BUG
Jonathan Tan [Fri, 8 Oct 2021 21:08:16 +0000 (14:08 -0700)] 
refs: peeling non-the_repository iterators is BUG

There is currently no support for peeling the current ref of an iterator
iterating over a non-the_repository ref store, and none is needed. Thus,
for now, BUG() if that happens.

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agorefs: teach arbitrary repo support to iterators
Jonathan Tan [Fri, 8 Oct 2021 21:08:15 +0000 (14:08 -0700)] 
refs: teach arbitrary repo support to iterators

Note that should_pack_ref() is called when writing refs, which is only
supported for the_repository, hence the_repository is hardcoded there.

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agorefs: plumb repo into ref stores
Jonathan Tan [Fri, 8 Oct 2021 21:08:14 +0000 (14:08 -0700)] 
refs: plumb repo into ref stores

In preparation for the next 2 patches that adds (partial) support for
arbitrary repositories to ref iterators, plumb a repository into all ref
stores. There are no changes to program logic.

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'jk/ref-paranoia' into jt/no-abuse-alternate-odb-for-submodules
Junio C Hamano [Tue, 28 Sep 2021 22:15:42 +0000 (15:15 -0700)] 
Merge branch 'jk/ref-paranoia' into jt/no-abuse-alternate-odb-for-submodules

* jk/ref-paranoia: (71 commits)
  refs: drop "broken" flag from for_each_fullref_in()
  ref-filter: drop broken-ref code entirely
  ref-filter: stop setting FILTER_REFS_INCLUDE_BROKEN
  repack, prune: drop GIT_REF_PARANOIA settings
  refs: turn on GIT_REF_PARANOIA by default
  refs: omit dangling symrefs when using GIT_REF_PARANOIA
  refs: add DO_FOR_EACH_OMIT_DANGLING_SYMREFS flag
  refs-internal.h: reorganize DO_FOR_EACH_* flag documentation
  refs-internal.h: move DO_FOR_EACH_* flags next to each other
  t5312: be more assertive about command failure
  t5312: test non-destructive repack
  t5312: create bogus ref as necessary
  t5312: drop "verbose" helper
  t5600: provide detached HEAD for corruption failures
  t5516: don't use HEAD ref for invalid ref-deletion tests
  t7900: clean up some more broken refs
  The eighth batch
  t0000: avoid masking git exit value through pipes
  tree-diff: fix leak when not HAVE_ALLOCA_H
  pack-revindex.h: correct the time complexity descriptions
  ...

3 years agorefs: drop "broken" flag from for_each_fullref_in()
Jeff King [Fri, 24 Sep 2021 18:48:48 +0000 (14:48 -0400)] 
refs: drop "broken" flag from for_each_fullref_in()

No callers pass in anything but "0" here. Likewise to our sibling
functions. Note that some of them ferry along the flag, but none of
their callers pass anything but "0" either.

Nor is anybody likely to change that. Callers which really want to see
all of the raw refs use for_each_rawref(). And anybody interested in
iterating a subset of the refs will likely be happy to use the
now-default behavior of showing broken refs, but omitting dangling
symlinks.

So we can get rid of this whole feature.

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoref-filter: drop broken-ref code entirely
Jeff King [Fri, 24 Sep 2021 18:48:20 +0000 (14:48 -0400)] 
ref-filter: drop broken-ref code entirely

Now that none of our callers passes the INCLUDE_BROKEN flag, we can drop
it entirely, along with the code to plumb it through to the
for_each_fullref_in() functions.

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoref-filter: stop setting FILTER_REFS_INCLUDE_BROKEN
Jeff King [Fri, 24 Sep 2021 18:48:05 +0000 (14:48 -0400)] 
ref-filter: stop setting FILTER_REFS_INCLUDE_BROKEN

Of the ref-filter callers, for-each-ref and git-branch both set the
INCLUDE_BROKEN flag (but git-tag does not, which is a weird
inconsistency).  But now that GIT_REF_PARANOIA is on by default, that
produces almost the same outcome for all three.

The one exception is that GIT_REF_PARANOIA will omit dangling symrefs.
That's a better behavior for these tools, as they would never include
such a symref in the main output anyway (they can't, as it doesn't point
to an object). Instead they issue a warning to stderr. But that warning
is somewhat useless; a dangling symref is a perfectly reasonable thing
to have in your repository, and is not a sign of corruption. It's much
friendlier to just quietly ignore it.

And in terms of robustness, the warning gains us little. It does not
impact the exit code of either tool. So while the warning _might_ clue
in a user that they have an unexpected broken symref, it would not help
any kind of scripted use.

This patch converts for-each-ref and git-branch to stop using the
INCLUDE_BROKEN flag. That gives them more reasonable behavior, and
harmonizes them with git-tag.

We have to change one test to adapt to the situation. t1430 tries to
trigger all of the REF_ISBROKEN behaviors from the underlying ref code.
It uses for-each-ref to do so (because there isn't any other mechanism).
That will no longer issue a warning about the symref which points to an
invalid name, as it's considered dangling (and we can instead be sure
that it's _not_ mentioned on stderr). Note that we do still complain
about the illegally named "broken..symref"; its problem is not that it's
dangling, but the name of the symref itself is illegal.

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agorepack, prune: drop GIT_REF_PARANOIA settings
Jeff King [Fri, 24 Sep 2021 18:46:37 +0000 (14:46 -0400)] 
repack, prune: drop GIT_REF_PARANOIA settings

Now that GIT_REF_PARANOIA is the default, we don't need to selectively
enable it for destructive operations. In fact, it's harmful to do so,
because it overrides any GIT_REF_PARANOIA=0 setting that the user may
have provided (because they're trying to work around some corruption).

With these uses gone, we can further clean up the ref_paranoia global,
and make it a static variable inside the refs code.

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agorefs: turn on GIT_REF_PARANOIA by default
Jeff King [Fri, 24 Sep 2021 18:46:13 +0000 (14:46 -0400)] 
refs: turn on GIT_REF_PARANOIA by default

The original point of the GIT_REF_PARANOIA flag was to include broken
refs in iterations, so that possibly-destructive operations would not
silently ignore them (and would generally instead try to operate on the
oids and fail when the objects could not be accessed).

We already turned this on by default for some dangerous operations, like
"repack -ad" (where missing a reachability tip would mean dropping the
associated history). But it was not on for general use, even though it
could easily result in the spreading of corruption (e.g., imagine
cloning a repository which simply omits some of its refs because
their objects are missing; the result quietly succeeds even though you
did not clone everything!).

This patch turns on GIT_REF_PARANOIA by default. So a clone as mentioned
above would actually fail (upload-pack tells us about the broken ref,
and when we ask for the objects, pack-objects fails to deliver them).
This may be inconvenient when working with a corrupted repository, but:

  - we are better off to err on the side of complaining about
    corruption, and then provide mechanisms for explicitly loosening
    safety.

  - this is only one type of corruption anyway. If we are missing any
    other objects in the history that _aren't_ ref tips, then we'd
    behave similarly (happily show the ref, but then barf when we
    started traversing).

We retain the GIT_REF_PARANOIA variable, but simply default it to "1"
instead of "0". That gives the user an escape hatch for loosening this
when working with a corrupt repository. It won't work across a remote
connection to upload-pack (because we can't necessarily set environment
variables on the remote), but there the client has other options (e.g.,
choosing which refs to fetch).

As a bonus, this also makes ref iteration faster in general (because we
don't have to call has_object_file() for each ref), though probably not
noticeably so in the general case. In a repo with a million refs, it
shaved a few hundred milliseconds off of upload-pack's advertisement;
that's noticeable, but most repos are not nearly that large.

The possible downside here is that any operation which iterates refs but
doesn't ever open their objects may now quietly claim to have X when the
object is corrupted (e.g., "git rev-list new-branch --not --all" will
treat a broken ref as uninteresting). But again, that's not really any
different than corruption below the ref level. We might have
refs/heads/old-branch as non-corrupt, but we are not actively checking
that we have the entire reachable history. Or the pointed-to object
could even be corrupted on-disk (but our "do we have it" check would
still succeed). In that sense, this is merely bringing ref-corruption in
line with general object corruption.

One alternative implementation would be to actually check for broken
refs, and then _immediately die_ if we see any. That would cause the
"rev-list --not --all" case above to abort immediately. But in many ways
that's the worst of all worlds:

  - it still spends time looking up the objects an extra time

  - it still doesn't catch corruption below the ref level

  - it's even more inconvenient; with the current implementation of
    GIT_REF_PARANOIA for something like upload-pack, we can make
    the advertisement and let the client choose a non-broken piece of
    history. If we bail as soon as we see a broken ref, they cannot even
    see the advertisement.

The test changes here show some of the fallout. A non-destructive "git
repack -adk" now fails by default (but we can override it). Deleting a
broken ref now actually tells the hooks the correct "before" state,
rather than a confusing null oid.

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agorefs: omit dangling symrefs when using GIT_REF_PARANOIA
Jeff King [Fri, 24 Sep 2021 18:42:38 +0000 (14:42 -0400)] 
refs: omit dangling symrefs when using GIT_REF_PARANOIA

Dangling symrefs aren't actually a corruption problem. It's perfectly
fine for refs/remotes/origin/HEAD to point to an unborn branch. And in
particular, if you are trying to establish reachability, a symref that
points nowhere doesn't matter either way. Any ref it could point to will
be examined during the rest of the traversal.

It's possible that a symref pointing nowhere _could_ be a sign that the
ref it was meant to point to was deleted accidentally (e.g., via
corruption). But there is no particular reason to think that is true for
any given case, and in the meantime, GIT_REF_PARANOIA kicking in
automatically for some operations means they'll fail unnecessarily.

So let's loosen it just a bit. The new test in t5312 shows off an
example that is safe, but currently fails (and no longer does after this
patch).

Note that we don't do anything if the caller explicitly asked for
DO_FOR_EACH_INCLUDE_BROKEN. In that case they may be looking for
dangling symrefs themselves, and setting GIT_REF_PARANOIA should not
_loosen_ things from what the caller asked for.

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agorefs: add DO_FOR_EACH_OMIT_DANGLING_SYMREFS flag
Jeff King [Fri, 24 Sep 2021 18:41:32 +0000 (14:41 -0400)] 
refs: add DO_FOR_EACH_OMIT_DANGLING_SYMREFS flag

When the DO_FOR_EACH_INCLUDE_BROKEN flag is used, we include both actual
corrupt refs (illegal names, missing objects), but also symrefs that
point to nothing. This latter is not really a corruption, but just
something that may happen normally. For example, the symref at
refs/remotes/origin/HEAD may point to a tracking branch which is later
deleted. (The local HEAD may also be unborn, of course, but we do not
access it through ref iteration).

Most callers of for_each_ref() etc, do not care. They don't pass
INCLUDE_BROKEN, so don't see it at all. But for those which do pass it,
this somewhat-normal state causes extra warnings (e.g., from
for-each-ref) or even aborts operations (destructive repacks with
GIT_REF_PARANOIA set).

This patch just introduces the flag and the mechanism; there are no
callers yet (and hence no tests). Two things to note on the
implementation:

  - we actually skip any symref that does not resolve to a ref. This
    includes ones which point to an invalidly-named ref. You could argue
    this is a more serious breakage than simple dangling. But the
    overall effect is the same (we could not follow the symref), as well
    as the impact on things like REF_PARANOIA (either way, a symref we
    can't follow won't impact reachability, because we'll see the ref
    itself during iteration). The underlying resolution function doesn't
    distinguish these two cases (they both get REF_ISBROKEN).

  - we change the iterator in refs/files-backend.c where we check
    INCLUDE_BROKEN. There's a matching spot in refs/packed-backend.c,
    but we don't know need to do anything there. The packed backend does
    not support symrefs at all.

The resulting set of flags might be a bit easier to follow if we broke
this down into "INCLUDE_CORRUPT_REFS" and "INCLUDE_DANGLING_SYMREFS".
But there are a few reasons not do so:

  - adding a new OMIT_DANGLING_SYMREFS flag lets us leave existing
    callers intact, without changing their behavior (and some of them
    really do want to see the dangling symrefs; e.g., t5505 has a test
    which expects us to report when a symref becomes dangling)

  - they're not actually independent. You cannot say "include dangling
    symrefs" without also including refs whose objects are not
    reachable, because dangling symrefs by definition do not have an
    object. We could tweak the implementation to distinguish this, but
    in practice nobody wants to ask for that. Adding the OMIT flag keeps
    the implementation simple and makes sure we don't regress the
    current behavior.

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agorefs-internal.h: reorganize DO_FOR_EACH_* flag documentation
Jeff King [Fri, 24 Sep 2021 18:39:44 +0000 (14:39 -0400)] 
refs-internal.h: reorganize DO_FOR_EACH_* flag documentation

The documentation for the DO_FOR_EACH_* flags is sprinkled over the
refs-internal.h file. We define the two flags in one spot, and then
describe them in more detail far away from there, in the definitions of
refs_ref_iterator_begin() and ref_iterator_advance_fn().

Let's try to organize this a bit better:

  - convert the #defines to an enum. This makes it clear that they are
    related, and that the enum shows the complete set of flags.

  - combine all descriptions for each flag in a single spot, next to the
    flag's definition

  - use the enum rather than a bare int for functions which take the
    flags. This helps readers realize which flags can be used.

  - clarify the mention of flags for ref_iterator_advance_fn(). It does
    not take flags itself, but is meant to depend on ones set up
    earlier.

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agorefs-internal.h: move DO_FOR_EACH_* flags next to each other
Jeff King [Fri, 24 Sep 2021 18:37:58 +0000 (14:37 -0400)] 
refs-internal.h: move DO_FOR_EACH_* flags next to each other

There are currently two DO_FOR_EACH_* flags, which must not have their
bits overlap. Yet they're defined hundreds of lines apart. Let's move
them next to each other to make it clear that they are related and are a
complete set (which matters if you are adding a new flag and would like
to know what the next available bit is).

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agot5312: be more assertive about command failure
Jeff King [Fri, 24 Sep 2021 18:37:11 +0000 (14:37 -0400)] 
t5312: be more assertive about command failure

When repacking or pruning in a corrupted repository, our tests in t5312
argue that it is OK to complete the operation or bail, as long as we
don't actually delete the objects pointed to by the corruption.

This isn't a wrong line of reasoning, but the tests are a bit permissive
by using test_might_fail. The fact is that we _do_ bail currently, and
if we ever stopped doing so, that would be worthy of a human
investigating. So let's switch these to test_must_fail.

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agot5312: test non-destructive repack
Jeff King [Fri, 24 Sep 2021 18:36:42 +0000 (14:36 -0400)] 
t5312: test non-destructive repack

In t5312, we create a state with a broken ref, and then make sure that
destructive repacks don't silently ignore the breakage (where a
destructive repack is one that might drop objects). But we don't check
the behavior of non-destructive repacks at all (i.e., ones where we'd
keep unreachable objects).

So let's add a test to confirm the current behavior, which is that
they are allowed (i.e., ignoring the breakage and considering any
objects it points to as unreachable). This may change in the future, but
we'd like for the test suite to alert us to that fact.

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agot5312: create bogus ref as necessary
Jeff King [Fri, 24 Sep 2021 18:36:18 +0000 (14:36 -0400)] 
t5312: create bogus ref as necessary

Some tests in t5312 create an illegally-named ref, and then see how
various operations handle it. But between those operations, we also do
some more setup (e.g., repacking), and we are subtly depending on how
those setup steps react to the illegal ref.

To future-proof us against those behaviors changing, let's instead
create and clean up our bogus ref on demand in the tests that need it.

This has two small extra advantages:

 - the tests are more stand-alone; we do not need an extra test to clean
   up the ref before moving on to other parts of the script

 - the creation and cleanup is together in one helper function. Because
   these depend on touching the refs in the filesystem directly, they
   may need to be tweaked for a world with alternate backends (they have
   not been noticed so far in the reftable work because with a non-file
   backend the tests don't fail; they simply become uninteresting noops
   because the broken ref isn't read at all).

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agot5312: drop "verbose" helper
Jeff King [Fri, 24 Sep 2021 18:35:29 +0000 (14:35 -0400)] 
t5312: drop "verbose" helper

t5312 has several uses of the "verbose" helper, as described in
8ad1652418 (t5304: use helper to report failure of "test foo = bar",
2014-10-10). Back then the "-x" trace option for tests was new, and was
not as pleasant to use (e.g., some tests failed under "-x", we did not
support BASH_XTRACEFD, etc).

These days it is clear that "-x" is the preferred way to get extra
output, and we don't need to mark up individual tests. Let's get rid of
the uses of "verbose" here, as one step toward eradicating it totally.

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agot5600: provide detached HEAD for corruption failures
Jeff King [Fri, 24 Sep 2021 18:34:04 +0000 (14:34 -0400)] 
t5600: provide detached HEAD for corruption failures

When checking how git-clone behaves when it fails, we stimulate some
failures by trying to do a clone from a local repository whose objects
have been removed. Because these clones use local optimizations, there's
a subtle dependency in how the corruption is handled on the sending
side.

If upload-pack does not show us the broken refs (which it does not
currently), then we see only HEAD (which is itself broken), and clone
that as a detached HEAD. When we try to write the ref, we notice that we
never got the object and bail.

But if upload-pack _does_ show us the broken refs (which it may in a
future patch), then we'll realize that HEAD is a symref and just write
that. You'd think we'd fail when writing out the refs themselves, but we
don't; we do a bulk write and skip the connectivity check because of our
--local optimizations. For the non-bare case, we do notice the problem
when we try to checkout. But for a bare repository, we unexpectedly
complete the clone successfully!

At first glance this may seem like a bug. But the whole point of those
local optimizations is to give up some safety for speed. If you want to
be careful, you should be using "--no-local", which would notice that
the pack did not transfer sufficient objects. We could do that in these
tests, but part of the point is for them to fail at specific moments
(and indeed, we have a later test that checks for transport failure).

However, we can make this less subtle and future-proof it against
changes on the upload-pack side by just having an explicit detached
HEAD in the corrupted repo. Now we'll fail as expected during the ref
write if any ref _or_ HEAD is corrupt, whether we're --bare or not.

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agot5516: don't use HEAD ref for invalid ref-deletion tests
Jeff King [Fri, 24 Sep 2021 18:33:00 +0000 (14:33 -0400)] 
t5516: don't use HEAD ref for invalid ref-deletion tests

A few tests in t5516 want to assert that we can delete a corrupted ref
whose pointed-to object is missing. They do so by using the "main"
branch, which is also pointed to by HEAD.

This does work, but only because of a subtle assumption about the
implementation. We do not block the deletion because of the invalid ref,
but we _also_ do not notice that the deleted branch is pointed to by
HEAD. And so the safety rule of "do not allow HEAD to be deleted in a
non-bare repository" does not kick in, and the test passes.

Let's instead use a non-HEAD branch. That still tests what we care about
here (deleting a corrupt ref), but without implicitly depending on our
failure to notice that we're deleting HEAD. That will future proof the
test against that behavior changing.

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agot7900: clean up some more broken refs
Jeff King [Fri, 24 Sep 2021 18:32:17 +0000 (14:32 -0400)] 
t7900: clean up some more broken refs

The "incremental-repack task" test replaces the object directory with a
known state. As a result, some of our refs point to objects that are not
included in that state.

Commit 3cf5f221be (t7900: clean up some broken refs, 2021-01-19) cleaned
up some of those (that were causing warnings to stderr from the
maintenance process). But there are a few more that were missed. These
aren't hurting anything for now, but it's certainly an unexpected state
to leave the test repository in, and it will become a problem if repack
ever gets more picky about broken refs.

Let's clean up those additional refs (which are all in refs/remotes,
with nothing there that isn't broken), and add an extra "for-each-ref"
call to assert that we've got everything.

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoThe eighth batch
Junio C Hamano [Thu, 23 Sep 2021 20:45:03 +0000 (13:45 -0700)] 
The eighth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'rs/use-xopen-in-index-pack'
Junio C Hamano [Thu, 23 Sep 2021 20:44:50 +0000 (13:44 -0700)] 
Merge branch 'rs/use-xopen-in-index-pack'

Code clean-up.

* rs/use-xopen-in-index-pack:
  index-pack: use xopen in init_thread

3 years agoMerge branch 'kz/revindex-comment-fix'
Junio C Hamano [Thu, 23 Sep 2021 20:44:49 +0000 (13:44 -0700)] 
Merge branch 'kz/revindex-comment-fix'

Header comment fix.

* kz/revindex-comment-fix:
  pack-revindex.h: correct the time complexity descriptions

3 years agoMerge branch 'cb/plug-leaks-in-alloca-emu-users'
Junio C Hamano [Thu, 23 Sep 2021 20:44:49 +0000 (13:44 -0700)] 
Merge branch 'cb/plug-leaks-in-alloca-emu-users'

Leakfix.

* cb/plug-leaks-in-alloca-emu-users:
  t0000: avoid masking git exit value through pipes
  tree-diff: fix leak when not HAVE_ALLOCA_H

3 years agoMerge branch 'jt/submodule-name-to-gitdir'
Junio C Hamano [Thu, 23 Sep 2021 20:44:49 +0000 (13:44 -0700)] 
Merge branch 'jt/submodule-name-to-gitdir'

Code refactoring.

* jt/submodule-name-to-gitdir:
  submodule: extract path to submodule gitdir func

3 years agoMerge branch 'ma/doc-git-version'
Junio C Hamano [Thu, 23 Sep 2021 20:44:49 +0000 (13:44 -0700)] 
Merge branch 'ma/doc-git-version'

Doc update.

* ma/doc-git-version:
  documentation: add documentation for 'git version'

3 years agoMerge branch 'ma/help-w-check-for-requested-page'
Junio C Hamano [Thu, 23 Sep 2021 20:44:48 +0000 (13:44 -0700)] 
Merge branch 'ma/help-w-check-for-requested-page'

The error in "git help no-such-git-command" is handled better.

* ma/help-w-check-for-requested-page:
  help: make sure local html page exists before calling external processes

3 years agoMerge branch 'cb/unix-sockets-with-windows'
Junio C Hamano [Thu, 23 Sep 2021 20:44:48 +0000 (13:44 -0700)] 
Merge branch 'cb/unix-sockets-with-windows'

Adjust credential-cache helper to Windows.

* cb/unix-sockets-with-windows:
  git-compat-util: include declaration for unix sockets in windows
  credential-cache: check for windows specific errors
  t0301: fixes for windows compatibility

3 years agoMerge branch 'ab/retire-option-argument'
Junio C Hamano [Thu, 23 Sep 2021 20:44:48 +0000 (13:44 -0700)] 
Merge branch 'ab/retire-option-argument'

An oddball OPTION_ARGUMENT feature has been removed from the
parse-options API.

* ab/retire-option-argument:
  parse-options API: remove OPTION_ARGUMENT feature
  difftool: use run_command() API in run_file_diff()
  difftool: prepare "diff" cmdline in cmd_difftool()
  difftool: prepare "struct child_process" in cmd_difftool()

3 years agoMerge branch 'mr/bisect-in-c-4'
Junio C Hamano [Thu, 23 Sep 2021 20:44:48 +0000 (13:44 -0700)] 
Merge branch 'mr/bisect-in-c-4'

Rewrite of "git bisect" in C continues.

* mr/bisect-in-c-4:
  bisect--helper: retire `--bisect-next-check` subcommand
  bisect--helper: reimplement `bisect_run` shell function in C
  bisect--helper: reimplement `bisect_visualize()` shell function in C
  run-command: make `exists_in_PATH()` non-static
  t6030-bisect-porcelain: add test for bisect visualize
  t6030-bisect-porcelain: add tests to control bisect run exit cases

3 years agoMerge branch 'ab/unused-script-helpers'
Junio C Hamano [Thu, 23 Sep 2021 20:44:47 +0000 (13:44 -0700)] 
Merge branch 'ab/unused-script-helpers'

Code clean-up.

* ab/unused-script-helpers:
  test-lib: remove unused $_x40 and $_z40 variables
  git-bisect: remove unused SHA-1 $x40 shell variable
  git-sh-setup: remove unused "pull with rebase" message
  git-submodule: remove unused is_zero_oid() function

3 years agoMerge branch 'ab/http-drop-old-curl-plus'
Junio C Hamano [Thu, 23 Sep 2021 20:44:47 +0000 (13:44 -0700)] 
Merge branch 'ab/http-drop-old-curl-plus'

Conditional compilation around versions of libcURL has been
straightened out.

* ab/http-drop-old-curl-plus:
  http: don't hardcode the value of CURL_SOCKOPT_OK
  http: centralize the accounting of libcurl dependencies
  http: correct curl version check for CURLOPT_PINNEDPUBLICKEY
  http: correct version check for CURL_HTTP_VERSION_2
  http: drop support for curl < 7.18.0 (again)
  Makefile: drop support for curl < 7.9.8 (again)
  INSTALL: mention that we need libcurl 7.19.4 or newer to build
  INSTALL: reword and copy-edit the "libcurl" section
  INSTALL: don't mention the "curl" executable at all

3 years agoMerge branch 'po/git-config-doc-mentions-help-c'
Junio C Hamano [Thu, 23 Sep 2021 20:44:47 +0000 (13:44 -0700)] 
Merge branch 'po/git-config-doc-mentions-help-c'

Doc update.

* po/git-config-doc-mentions-help-c:
  doc: config, tell readers of `git help --config`

3 years agoMerge branch 'jk/http-server-protocol-versions'
Junio C Hamano [Thu, 23 Sep 2021 20:44:47 +0000 (13:44 -0700)] 
Merge branch 'jk/http-server-protocol-versions'

Taking advantage of the CGI interface, http-backend has been
updated to enable protocol v2 automatically when the other side
asks for it.

* jk/http-server-protocol-versions:
  docs/protocol-v2: point readers transport config discussion
  docs/git: discuss server-side config for GIT_PROTOCOL
  docs/http-backend: mention v2 protocol
  http-backend: handle HTTP_GIT_PROTOCOL CGI variable
  t5551: test v2-to-v0 http protocol fallback

3 years agoMerge branch 'ab/gc-remove-unused-call'
Junio C Hamano [Thu, 23 Sep 2021 20:44:46 +0000 (13:44 -0700)] 
Merge branch 'ab/gc-remove-unused-call'

Code clean-up.

* ab/gc-remove-unused-call:
  gc: remove unused launchctl_get_uid() call

3 years agoMerge branch 'ab/test-tool-run-command-cleanup'
Junio C Hamano [Thu, 23 Sep 2021 20:44:46 +0000 (13:44 -0700)] 
Merge branch 'ab/test-tool-run-command-cleanup'

Code clean-up.

* ab/test-tool-run-command-cleanup:
  test-tool run-command: fix flip-flop init pattern

3 years agoMerge branch 'en/tests-cleanup-leftover-untracked'
Junio C Hamano [Thu, 23 Sep 2021 20:44:46 +0000 (13:44 -0700)] 
Merge branch 'en/tests-cleanup-leftover-untracked'

Test clean-up.

* en/tests-cleanup-leftover-untracked:
  tests: remove leftover untracked files

3 years agoMerge branch 'jk/strvec-typefix'
Junio C Hamano [Thu, 23 Sep 2021 20:44:46 +0000 (13:44 -0700)] 
Merge branch 'jk/strvec-typefix'

Correct nr and alloc members of strvec struct to be of type size_t.

* jk/strvec-typefix:
  strvec: use size_t to store nr and alloc

3 years agoMerge branch 'rs/drop-core-compression-vars'
Junio C Hamano [Thu, 23 Sep 2021 20:44:46 +0000 (13:44 -0700)] 
Merge branch 'rs/drop-core-compression-vars'

Code clean-up.

* rs/drop-core-compression-vars:
  compression: drop write-only core_compression_* variables

3 years agoMerge branch 'rs/packfile-bad-object-list-in-oidset'
Junio C Hamano [Thu, 23 Sep 2021 20:44:45 +0000 (13:44 -0700)] 
Merge branch 'rs/packfile-bad-object-list-in-oidset'

Replace a handcrafted data structure used to keep track of bad
objects in the packfile API by an oidset.

* rs/packfile-bad-object-list-in-oidset:
  packfile: use oidset for bad objects
  packfile: convert has_packed_and_bad() to object_id
  packfile: convert mark_bad_packed_object() to object_id
  midx: inline nth_midxed_pack_entry()
  oidset: make oidset_size() an inline function

3 years agoMerge branch 'en/am-abort-fix'
Junio C Hamano [Thu, 23 Sep 2021 20:44:45 +0000 (13:44 -0700)] 
Merge branch 'en/am-abort-fix'

When "git am --abort" fails to abort correctly, it still exited
with exit status of 0, which has been corrected.

* en/am-abort-fix:
  am: fix incorrect exit status on am fail to abort
  t4151: add a few am --abort tests
  git-am.txt: clarify --abort behavior

3 years agoMerge branch 'ps/update-ref-batch-flush'
Junio C Hamano [Thu, 23 Sep 2021 20:44:45 +0000 (13:44 -0700)] 
Merge branch 'ps/update-ref-batch-flush'

"git update-ref --stdin" failed to flush its output as needed,
which potentially led the conversation to a deadlock.

* ps/update-ref-batch-flush:
  t1400: avoid SIGPIPE race condition on fifo
  update-ref: fix streaming of status updates

3 years agoMerge branch 'jt/add-submodule-odb-clean-up' into jt/no-abuse-alternate-odb-for-submo...
Junio C Hamano [Thu, 23 Sep 2021 00:11:09 +0000 (17:11 -0700)] 
Merge branch 'jt/add-submodule-odb-clean-up' into jt/no-abuse-alternate-odb-for-submodules

* jt/add-submodule-odb-clean-up:
  revision: remove "submodule" from opt struct
  repository: support unabsorbed in repo_submodule_init
  submodule: remove unnecessary unabsorbed fallback

3 years agoThe seventh batch
Junio C Hamano [Mon, 20 Sep 2021 22:09:44 +0000 (15:09 -0700)] 
The seventh batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'jk/t5562-racefix'
Junio C Hamano [Mon, 20 Sep 2021 22:20:46 +0000 (15:20 -0700)] 
Merge branch 'jk/t5562-racefix'

Test update.

* jk/t5562-racefix:
  t5562: use alarm() to interrupt timed child-wait

3 years agoMerge branch 'rs/no-mode-to-open-when-appending'
Junio C Hamano [Mon, 20 Sep 2021 22:20:45 +0000 (15:20 -0700)] 
Merge branch 'rs/no-mode-to-open-when-appending'

The "mode" word is useless in a call to open(2) that does not
create a new file.  Such a call in the files backend of the ref
subsystem has been cleaned up.

* rs/no-mode-to-open-when-appending:
  refs/files-backend: remove unused open mode parameter

3 years agoMerge branch 'rs/setup-use-xopen-and-xdup'
Junio C Hamano [Mon, 20 Sep 2021 22:20:45 +0000 (15:20 -0700)] 
Merge branch 'rs/setup-use-xopen-and-xdup'

Code clean-up.

* rs/setup-use-xopen-and-xdup:
  setup: use xopen and xdup in sanitize_stdfds

3 years agoMerge branch 'js/run-command-close-packs'
Junio C Hamano [Mon, 20 Sep 2021 22:20:45 +0000 (15:20 -0700)] 
Merge branch 'js/run-command-close-packs'

The run-command API has been updated so that the callers can easily
ask the file descriptors open for packfiles to be closed immediately
before spawning commands that may trigger auto-gc.

* js/run-command-close-packs:
  Close object store closer to spawning child processes
  run_auto_maintenance(): implicitly close the object store
  run-command: offer to close the object store before running
  run-command: prettify the `RUN_COMMAND_*` flags
  pull: release packs before fetching
  commit-graph: when closing the graph, also release the slab

3 years agoMerge branch 'ds/mergies-with-sparse-index'
Junio C Hamano [Mon, 20 Sep 2021 22:20:44 +0000 (15:20 -0700)] 
Merge branch 'ds/mergies-with-sparse-index'

Various mergy operations have been prepared to work efficiently
with the sparse index.

* ds/mergies-with-sparse-index:
  sparse-index: integrate with cherry-pick and rebase
  sequencer: ensure full index if not ORT strategy
  t1092: add cherry-pick, rebase tests
  merge-ort: expand only for out-of-cone conflicts
  merge: make sparse-aware with ORT
  diff: ignore sparse paths in diffstat

3 years agoMerge branch 'ds/sparse-index-ignored-files'
Junio C Hamano [Mon, 20 Sep 2021 22:20:44 +0000 (15:20 -0700)] 
Merge branch 'ds/sparse-index-ignored-files'

In cone mode, the sparse-index code path learned to remove ignored
files (like build artifacts) outside the sparse cone, allowing the
entire directory outside the sparse cone to be removed, which is
especially useful when the sparse patterns change.

* ds/sparse-index-ignored-files:
  sparse-checkout: clear tracked sparse dirs
  sparse-index: add SPARSE_INDEX_MEMORY_ONLY flag
  attr: be careful about sparse directories
  sparse-checkout: create helper methods
  sparse-index: use WRITE_TREE_MISSING_OK
  sparse-index: silently return when cache tree fails
  unpack-trees: fix nested sparse-dir search
  sparse-index: silently return when not using cone-mode patterns
  t7519: rewrite sparse index test

3 years agoMerge branch 'ar/submodule-run-update-procedure'
Junio C Hamano [Mon, 20 Sep 2021 22:20:44 +0000 (15:20 -0700)] 
Merge branch 'ar/submodule-run-update-procedure'

Reimplementation of parts of "git submodule" in C continues.

* ar/submodule-run-update-procedure:
  submodule--helper: run update procedures from C

3 years agoMerge branch 'ab/make-tags-cleanup'
Junio C Hamano [Mon, 20 Sep 2021 22:20:43 +0000 (15:20 -0700)] 
Merge branch 'ab/make-tags-cleanup'

Build clean-up for "make tags" and friends.

* ab/make-tags-cleanup:
  Makefile: normalize clobbering & xargs for tags targets
  Makefile: remove "cscope.out", not "cscope*" in cscope.out target
  Makefile: don't use "FORCE" for tags targets
  Makefile: add QUIET_GEN to "cscope" target
  Makefile: move ".PHONY: cscope" near its target

3 years agoMerge branch 'ab/serve-cleanup'
Junio C Hamano [Mon, 20 Sep 2021 22:20:43 +0000 (15:20 -0700)] 
Merge branch 'ab/serve-cleanup'

Code clean-up around "git serve".

* ab/serve-cleanup:
  upload-pack: document and rename --advertise-refs
  serve.[ch]: remove "serve_options", split up --advertise-refs code
  {upload,receive}-pack tests: add --advertise-refs tests
  serve.c: move version line to advertise_capabilities()
  serve: move transfer.advertiseSID check into session_id_advertise()
  serve.[ch]: don't pass "struct strvec *keys" to commands
  serve: use designated initializers
  transport: use designated initializers
  transport: rename "fetch" in transport_vtable to "fetch_refs"
  serve: mark has_capability() as static

3 years agoMerge branch 'ar/submodule-add-more'
Junio C Hamano [Mon, 20 Sep 2021 22:20:43 +0000 (15:20 -0700)] 
Merge branch 'ar/submodule-add-more'

More parts of "git submodule add" has been rewritten in C.

* ar/submodule-add-more:
  submodule--helper: rename compute_submodule_clone_url()
  submodule--helper: remove resolve-relative-url subcommand
  submodule--helper: remove add-config subcommand
  submodule--helper: remove add-clone subcommand
  submodule--helper: convert the bulk of cmd_add() to C
  dir: libify and export helper functions from clone.c
  submodule--helper: remove repeated code in sync_submodule()
  submodule--helper: refactor resolve_relative_url() helper
  submodule--helper: add options for compute_submodule_clone_url()

3 years agoMerge branch 'ar/submodule-add-config'
Junio C Hamano [Mon, 20 Sep 2021 22:20:42 +0000 (15:20 -0700)] 
Merge branch 'ar/submodule-add-config'

Large part of "git submodule add" gets rewritten in C.

* ar/submodule-add-config:
  submodule--helper: introduce add-config subcommand

3 years agoMerge branch 'ab/unbundle-progress'
Junio C Hamano [Mon, 20 Sep 2021 22:20:42 +0000 (15:20 -0700)] 
Merge branch 'ab/unbundle-progress'

Add progress display to "git bundle unbundle".

* ab/unbundle-progress:
  bundle: show progress on "unbundle"
  index-pack: add --progress-title option
  bundle API: change "flags" to be "extra_index_pack_args"
  bundle API: start writing API documentation

3 years agoMerge branch 'tb/pack-finalize-ordering'
Junio C Hamano [Mon, 20 Sep 2021 22:20:42 +0000 (15:20 -0700)] 
Merge branch 'tb/pack-finalize-ordering'

The order in which various files that make up a single (conceptual)
packfile has been reevaluated and straightened up.  This matters in
correctness, as an incomplete set of files must not be shown to a
running Git.

* tb/pack-finalize-ordering:
  pack-objects: rename .idx files into place after .bitmap files
  pack-write: split up finish_tmp_packfile() function
  builtin/index-pack.c: move `.idx` files into place last
  index-pack: refactor renaming in final()
  builtin/repack.c: move `.idx` files into place last
  pack-write.c: rename `.idx` files after `*.rev`
  pack-write: refactor renaming in finish_tmp_packfile()
  bulk-checkin.c: store checksum directly
  pack.h: line-wrap the definition of finish_tmp_packfile()

3 years agoMerge branch 'cb/pedantic-build-for-developers'
Junio C Hamano [Mon, 20 Sep 2021 22:20:41 +0000 (15:20 -0700)] 
Merge branch 'cb/pedantic-build-for-developers'

Update the build procedure to use the "-pedantic" build when
DEVELOPER makefile macro is in effect.

* cb/pedantic-build-for-developers:
  developer: enable pedantic by default
  win32: allow building with pedantic mode enabled
  gettext: remove optional non-standard parens in N_() definition

3 years agoMerge branch 'ab/progress-users-adjust-counters'
Junio C Hamano [Mon, 20 Sep 2021 22:20:41 +0000 (15:20 -0700)] 
Merge branch 'ab/progress-users-adjust-counters'

The code to show progress indicator in a few code paths did not
cover between 0-100%, which has been corrected.

* ab/progress-users-adjust-counters:
  entry: show finer-grained counter in "Filtering content" progress line
  commit-graph: fix bogus counter in "Scanning merged commits" progress line

3 years agoMerge branch 'dt/submodule-diff-fixes'
Junio C Hamano [Mon, 20 Sep 2021 22:20:41 +0000 (15:20 -0700)] 
Merge branch 'dt/submodule-diff-fixes'

"git diff --submodule=diff" showed failure from run_command() when
trying to run diff inside a submodule, when the user manually
removes the submodule directory.

* dt/submodule-diff-fixes:
  diff --submodule=diff: don't print failure message twice
  diff --submodule=diff: do not fail on ever-initialied deleted submodules
  t4060: remove unused variable

3 years agoMerge branch 'jv/pkt-line-batch'
Junio C Hamano [Mon, 20 Sep 2021 22:20:40 +0000 (15:20 -0700)] 
Merge branch 'jv/pkt-line-batch'

Reduce number of write(2) system calls while sending the
ref advertisement.

* jv/pkt-line-batch:
  upload-pack: use stdio in send_ref callbacks
  pkt-line: add stdio packet write functions

3 years agoMerge branch 'lh/systemd-timers'
Junio C Hamano [Mon, 20 Sep 2021 22:20:40 +0000 (15:20 -0700)] 
Merge branch 'lh/systemd-timers'

"git maintenance" scheduler learned to use systemd timers as a
possible backend.

* lh/systemd-timers:
  maintenance: add support for systemd timers on Linux
  maintenance: `git maintenance run` learned `--scheduler=<scheduler>`
  cache.h: Introduce a generic "xdg_config_home_for(…)" function

3 years agoMerge branch 'ab/tr2-leaks-and-fixes'
Junio C Hamano [Mon, 20 Sep 2021 22:20:40 +0000 (15:20 -0700)] 
Merge branch 'ab/tr2-leaks-and-fixes'

The tracing of process ancestry information has been enhanced.

* ab/tr2-leaks-and-fixes:
  tr2: log N parent process names on Linux
  tr2: do compiler enum check in trace2_collect_process_info()
  tr2: leave the parent list empty upon failure & don't leak memory
  tr2: stop leaking "thread_name" memory
  tr2: clarify TRACE2_PROCESS_INFO_EXIT comment under Linux
  tr2: remove NEEDSWORK comment for "non-procfs" implementations

3 years agoMerge branch 'jt/grep-wo-submodule-odb-as-alternate'
Junio C Hamano [Mon, 20 Sep 2021 22:20:39 +0000 (15:20 -0700)] 
Merge branch 'jt/grep-wo-submodule-odb-as-alternate'

The code to make "git grep" recurse into submodules has been
updated to migrate away from the "add submodule's object store as
an alternate object store" mechanism (which is suboptimal).

* jt/grep-wo-submodule-odb-as-alternate:
  t7814: show lack of alternate ODB-adding
  submodule-config: pass repo upon blob config read
  grep: add repository to OID grep sources
  grep: allocate subrepos on heap
  grep: read submodule entry with explicit repo
  grep: typesafe versions of grep_source_init
  grep: use submodule-ODB-as-alternate lazy-addition
  submodule: lazily add submodule ODBs as alternates

3 years agoMerge branch 'tb/multi-pack-bitmaps'
Junio C Hamano [Mon, 20 Sep 2021 22:20:39 +0000 (15:20 -0700)] 
Merge branch 'tb/multi-pack-bitmaps'

The reachability bitmap file used to be generated only for a single
pack, but now we've learned to generate bitmaps for history that
span across multiple packfiles.

* tb/multi-pack-bitmaps: (29 commits)
  pack-bitmap: drop bitmap_index argument from try_partial_reuse()
  pack-bitmap: drop repository argument from prepare_midx_bitmap_git()
  p5326: perf tests for MIDX bitmaps
  p5310: extract full and partial bitmap tests
  midx: respect 'GIT_TEST_MULTI_PACK_INDEX_WRITE_BITMAP'
  t7700: update to work with MIDX bitmap test knob
  t5319: don't write MIDX bitmaps in t5319
  t5310: disable GIT_TEST_MULTI_PACK_INDEX_WRITE_BITMAP
  t0410: disable GIT_TEST_MULTI_PACK_INDEX_WRITE_BITMAP
  t5326: test multi-pack bitmap behavior
  t/helper/test-read-midx.c: add --checksum mode
  t5310: move some tests to lib-bitmap.sh
  pack-bitmap: write multi-pack bitmaps
  pack-bitmap: read multi-pack bitmaps
  pack-bitmap.c: avoid redundant calls to try_partial_reuse
  pack-bitmap.c: introduce 'bitmap_is_preferred_refname()'
  pack-bitmap.c: introduce 'nth_bitmap_object_oid()'
  pack-bitmap.c: introduce 'bitmap_num_objects()'
  midx: avoid opening multiple MIDXs when writing
  midx: close linked MIDXs, avoid leaking memory
  ...

3 years agoMerge branch 'ps/fetch-optim'
Junio C Hamano [Mon, 20 Sep 2021 22:20:39 +0000 (15:20 -0700)] 
Merge branch 'ps/fetch-optim'

Optimize code that handles large number of refs in the "git fetch"
code path.

* ps/fetch-optim:
  fetch: avoid second connectivity check if we already have all objects
  fetch: merge fetching and consuming refs
  fetch: refactor fetch refs to be more extendable
  fetch-pack: optimize loading of refs via commit graph
  connected: refactor iterator to return next object ID directly
  fetch: avoid unpacking headers in object existence check
  fetch: speed up lookup of want refs via commit-graph

3 years agot0000: avoid masking git exit value through pipes
Carlo Marcelo Arenas Belón [Thu, 16 Sep 2021 08:55:23 +0000 (01:55 -0700)] 
t0000: avoid masking git exit value through pipes

9af0b8dbe2 (t0000-basic: more commit-tree tests., 2006-04-26) adds
tests for commit-tree that mask the return exit from git as described
in a378fee5b07 (Documentation: add shell guidelines, 2018-10-05).

Fix the tests, to avoid pipes by using a temporary file instead.

Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agotree-diff: fix leak when not HAVE_ALLOCA_H
Carlo Marcelo Arenas Belón [Thu, 16 Sep 2021 08:55:22 +0000 (01:55 -0700)] 
tree-diff: fix leak when not HAVE_ALLOCA_H

b8ba412bf7 (tree-diff: avoid alloca for large allocations, 2016-06-07)
adds a way to route some bigger allocations out of the stack and free
them through the addition of two conveniently named macros, but leaves
the calls to free the xalloca part, which could be also in the heap,
if the system doesn't HAVE_ALLOCA_H (ex: macOS and other BSD).

Add the missing free call, xalloca_free(), which is a noop if we
allocated memory in the stack frame, but a real free() if we
allocated in the heap instead, and while at it, change the expression
to match in both macros for ease of readability.

This avoids a leak reported by LSAN while running t0000 but that
wouldn't fail the test (which is fixed in the next patch):

  SUMMARY: LeakSanitizer: 1034 byte(s) leaked in 15 allocation(s).

Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agopack-revindex.h: correct the time complexity descriptions
Kyle Zhao [Wed, 15 Sep 2021 09:09:23 +0000 (09:09 +0000)] 
pack-revindex.h: correct the time complexity descriptions

Time complexities for pack_pos_to_midx and midx_to_pack_pos are swapped,
correct it.

Signed-off-by: Kyle Zhao <kylezhao@tencent.com>
Reviewed-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoThe sixth batch
Junio C Hamano [Wed, 15 Sep 2021 20:15:09 +0000 (13:15 -0700)] 
The sixth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'jc/prefix-filename-allocates'
Junio C Hamano [Wed, 15 Sep 2021 20:15:28 +0000 (13:15 -0700)] 
Merge branch 'jc/prefix-filename-allocates'

Leakfix.

* jc/prefix-filename-allocates:
  hash-object: prefix_filename() returns allocated memory these days

3 years agoMerge branch 'rs/range-diff-avoid-segfault-with-I'
Junio C Hamano [Wed, 15 Sep 2021 20:15:27 +0000 (13:15 -0700)] 
Merge branch 'rs/range-diff-avoid-segfault-with-I'

"git range-diff -I... <range> <range>" segfaulted, which has been
corrected.

* rs/range-diff-avoid-segfault-with-I:
  range-diff: avoid segfault with -I

3 years agoMerge branch 'ab/reverse-midx-optim'
Junio C Hamano [Wed, 15 Sep 2021 20:15:27 +0000 (13:15 -0700)] 
Merge branch 'ab/reverse-midx-optim'

The code that optionally creates the *.rev reverse index file has
been optimized to avoid needless computation when it is not writing
the file out.

* ab/reverse-midx-optim:
  pack-write: skip *.rev work when not writing *.rev

3 years agoMerge branch 'bs/install-strip'
Junio C Hamano [Wed, 15 Sep 2021 20:15:26 +0000 (13:15 -0700)] 
Merge branch 'bs/install-strip'

"make INSTALL_STRIP=-s install" allows the installation step to use
"install -s" to strip the binaries as they get installed.

* bs/install-strip:
  make: add INSTALL_STRIP option variable

3 years agoMerge branch 'pb/test-use-user-env'
Junio C Hamano [Wed, 15 Sep 2021 20:15:26 +0000 (13:15 -0700)] 
Merge branch 'pb/test-use-user-env'

Teach "test_pause" and "debug" helpers to allow using the HOME and
TERM environment variables the user usually uses.

* pb/test-use-user-env:
  test-lib-functions: keep user's debugger config files and TERM in 'debug'
  test-lib-functions: optionally keep HOME, TERM and SHELL in 'test_pause'
  test-lib-functions: use 'TEST_SHELL_PATH' in 'test_pause'

3 years agoMerge branch 'jc/trivial-threeway-binary-merge'
Junio C Hamano [Wed, 15 Sep 2021 20:15:26 +0000 (13:15 -0700)] 
Merge branch 'jc/trivial-threeway-binary-merge'

The "git apply -3" code path learned not to bother the lower level
merge machinery when the three-way merge can be trivially resolved
without the content level merge.

* jc/trivial-threeway-binary-merge:
  apply: resolve trivial merge without hitting ll-merge with "--3way"

3 years agoMerge branch 'bs/doc-bugreport-outdir'
Junio C Hamano [Wed, 15 Sep 2021 20:15:25 +0000 (13:15 -0700)] 
Merge branch 'bs/doc-bugreport-outdir'

Docfix.

* bs/doc-bugreport-outdir:
  Documentation: fix default directory of git bugreport -o

3 years agoMerge branch 'ab/no-more-check-bindir'
Junio C Hamano [Wed, 15 Sep 2021 20:15:25 +0000 (13:15 -0700)] 
Merge branch 'ab/no-more-check-bindir'

Build simplification.

* ab/no-more-check-bindir:
  Makefile: remove the check_bindir script

3 years agoMerge branch 'ab/send-email-config-fix'
Junio C Hamano [Wed, 15 Sep 2021 20:15:24 +0000 (13:15 -0700)] 
Merge branch 'ab/send-email-config-fix'

Regression fix.

* ab/send-email-config-fix:
  send-email: fix a "first config key wins" regression in v2.33.0

3 years agoMerge branch 'so/diff-index-regression-fix'
Junio C Hamano [Wed, 15 Sep 2021 20:15:24 +0000 (13:15 -0700)] 
Merge branch 'so/diff-index-regression-fix'

Recent "diff -m" changes broke "gitk", which has been corrected.

* so/diff-index-regression-fix:
  diff-index: restore -c/--cc options handling

3 years agot1400: avoid SIGPIPE race condition on fifo
Jeff King [Wed, 15 Sep 2021 17:24:52 +0000 (13:24 -0400)] 
t1400: avoid SIGPIPE race condition on fifo

t1400.190 sometimes fails or even hangs because of the way it uses
fifos. Our goal is to interactively read and write lines from
update-ref, so we have two fifos, in and out. We open a descriptor
connected to "in" and redirect output to that, so that update-ref does
not see EOF as it would if we opened and closed it for each "echo" call.

But we don't do the same for the output. This leads to a race where our
"read response <out" has not yet opened the fifo, but update-ref tries
to write to it and gets SIGPIPE. This can result in the test failing, or
worse, hanging as we wait forever for somebody to write to the pipe.

This is the same proble we fixed in 4783e7ea83 (t0008: avoid SIGPIPE
race condition on fifo, 2013-07-12), and we can fix it the same way, by
opening a second long-running descriptor.

Before this patch, running:

  ./t1400-update-ref.sh --run=1,190 --stress

failed or hung within a few dozen iterations. After it, I ran it for
several hundred without problems.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agosubmodule: extract path to submodule gitdir func
Jonathan Tan [Wed, 15 Sep 2021 18:59:19 +0000 (11:59 -0700)] 
submodule: extract path to submodule gitdir func

We currently store each submodule gitdir in ".git/modules/<name>", but
this has problems with some submodule naming schemes, as described in a
comment in submodule_name_to_gitdir() in this patch.

Extract the determination of the location of a submodule's gitdir into
its own function submodule_name_to_gitdir(). For now, the problem
remains unsolved, but this puts us in a better position for finding a
solution.

This was motivated, at $DAYJOB, by a part of Android's repo hierarchy
[1]. In particular, there is a repo "build", and several repos of the
form "build/<name>".

This is based on earlier work by Brandon Williams [2].

[1] https://android.googlesource.com/platform/
[2] https://lore.kernel.org/git/20180808223323.79989-2-bmwill@google.com/

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agodocumentation: add documentation for 'git version'
Matthias Aßhauer [Tue, 14 Sep 2021 13:27:18 +0000 (13:27 +0000)] 
documentation: add documentation for 'git version'

While 'git version' is probably the least complex git command,
it is a non-experimental user-facing builtin command. As such
it should have a help page.

Both `git help` and `git version` can be called as options
(`--help`/`--version`) that internally get converted to the
corresponding command. Add a small paragraph to
Documentation/git.txt describing how these two options
interact with each other and link to this help page for the
sub-options that `--version` can take. Well, currently there
is only one sub-option, but that could potentially increase
in future versions of Git.

Signed-off-by: Matthias Aßhauer <mha1993@live.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agohelp: make sure local html page exists before calling external processes
Matthias Aßhauer [Tue, 14 Sep 2021 13:27:17 +0000 (13:27 +0000)] 
help: make sure local html page exists before calling external processes

We check that git.html exists, regardless of the page the user wants to open.
Checking whether the requested page exists instead gives us a smoother user
experience in two use cases:

1) The requested page doesn't exist

When calling a git command and there is an error, most users reasonably expect
git to produce an error message on the standard error stream, but in this case
we pass the filepath to git web--browse which passes it on to a browser (or a
helper program like xdg-open or start that should in turn open a browser)
without any error and many GUI based browsers or helpers won't output such a
message onto the standard error stream.

Especially the helper programs tend to show the corresponding error message in
a message box and wait for user input before exiting. This leaves users in
interactive console sessions without an error message in their console,
without a console prompt and without the help page they expected.

2) git.html is missing for some reason, but the user asked for some other page

We currently refuse to show any local html help page when we can't find
git.html. Even if the requested help page exists. If we check for the requested
page instead, we can show the user all available pages and only error out on
those that don't exist.

Signed-off-by: Matthias Aßhauer <mha1993@live.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agogit-compat-util: include declaration for unix sockets in windows
Carlo Marcelo Arenas Belón [Tue, 14 Sep 2021 07:26:00 +0000 (00:26 -0700)] 
git-compat-util: include declaration for unix sockets in windows

Available since Windows 10 release 1803 and Windows Server 2019.

NO_UNIX_SOCKETS is still the default for Windows builds, as they need
to keep backward compatibility with releases up to Windows 7, but allow
including the header otherwise.

Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agocredential-cache: check for windows specific errors
Carlo Marcelo Arenas Belón [Tue, 14 Sep 2021 07:25:59 +0000 (00:25 -0700)] 
credential-cache: check for windows specific errors

Connect and reset errors aren't what will be expected by POSIX but
are instead compatible with the ones used by WinSock.

To avoid any possibility of confusion with other systems, checks
for disconnection and availability had been abstracted into helper
functions that are platform specific.

Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agot0301: fixes for windows compatibility
Carlo Marcelo Arenas Belón [Tue, 14 Sep 2021 07:25:58 +0000 (00:25 -0700)] 
t0301: fixes for windows compatibility

In preparation for a future patch that will allow building with
Unix Sockets in Windows, workaround a couple of issues from the
Mingw-W64 compatibility layer.

test -S is not able to detect that a file is a socket, so use
test -e instead (through a library function).

`mkdir -m` can't represent a valid ACL directly and fails with
permission problems, so instead call mkdir followed by chmod, which
has been enhanced to do so.

The last invocation of mkdir would likely need the same treatment
but SYMLINK is unlikely to be enabled on Windows so it has been
punted for now.

Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agodoc: config, tell readers of `git help --config`
Philip Oakley [Mon, 13 Sep 2021 21:23:05 +0000 (22:23 +0100)] 
doc: config, tell readers of `git help --config`

The `git help` command gained the ability to list config variables in
3ac68a93fd (help: add --config to list all available config, 2018-05-26)
but failed to tell readers of the config documenation itself.

Provide that cross reference.

Signed-off-by: Philip Oakley <philipoakley@iee.email>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agobisect--helper: retire `--bisect-next-check` subcommand
Miriam Rubio [Mon, 13 Sep 2021 17:39:04 +0000 (19:39 +0200)] 
bisect--helper: retire `--bisect-next-check` subcommand

After reimplementation of `git bisect run` in C,
`--bisect-next-check` subcommand is not needed anymore.

Let's remove it from options list and code.

Mentored by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Miriam Rubio <mirucam@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agobisect--helper: reimplement `bisect_run` shell function in C
Tanushree Tumane [Mon, 13 Sep 2021 17:39:03 +0000 (19:39 +0200)] 
bisect--helper: reimplement `bisect_run` shell function in C

Reimplement the `bisect_run()` shell function
in C and also add `--bisect-run` subcommand to
`git bisect--helper` to call it from git-bisect.sh.

Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Tanushree Tumane <tanushreetumane@gmail.com>
Signed-off-by: Miriam Rubio <mirucam@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agobisect--helper: reimplement `bisect_visualize()` shell function in C
Pranit Bauva [Mon, 13 Sep 2021 17:39:02 +0000 (19:39 +0200)] 
bisect--helper: reimplement `bisect_visualize()` shell function in C

Reimplement the `bisect_visualize()` shell function
in C and also add `--bisect-visualize` subcommand to
`git bisect--helper` to call it from git-bisect.sh.

Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Mentored-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Tanushree Tumane <tanushreetumane@gmail.com>
Signed-off-by: Miriam Rubio <mirucam@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agorun-command: make `exists_in_PATH()` non-static
Pranit Bauva [Mon, 13 Sep 2021 17:39:01 +0000 (19:39 +0200)] 
run-command: make `exists_in_PATH()` non-static

Remove the `static` keyword from `exists_in_PATH()` function
and declare the function in `run-command.h` file.
The function will be used in bisect_visualize() in a later
commit.

Mentored by: Christian Couder <chriscool@tuxfamily.org>
Mentored by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Tanushree Tumane <tanushreetumane@gmail.com>
Signed-off-by: Miriam Rubio <mirucam@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agot6030-bisect-porcelain: add test for bisect visualize
Miriam Rubio [Mon, 13 Sep 2021 17:39:00 +0000 (19:39 +0200)] 
t6030-bisect-porcelain: add test for bisect visualize

Add a test to control breakages in bisect visualize command.

Signed-off-by: Miriam Rubio <mirucam@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agot6030-bisect-porcelain: add tests to control bisect run exit cases
Miriam Rubio [Mon, 13 Sep 2021 17:38:59 +0000 (19:38 +0200)] 
t6030-bisect-porcelain: add tests to control bisect run exit cases

There is a gap on bisect run test coverage related with error exits.
Add two tests to control these error cases.

Signed-off-by: Miriam Rubio <mirucam@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agohttp: don't hardcode the value of CURL_SOCKOPT_OK
Ævar Arnfjörð Bjarmason [Mon, 13 Sep 2021 14:51:29 +0000 (16:51 +0200)] 
http: don't hardcode the value of CURL_SOCKOPT_OK

Use the new git-curl-compat.h header to define CURL_SOCKOPT_OK to its
known value if we're on an older curl version that doesn't have it. It
was hardcoded in http.c in a15d069a198 (http: enable keepalive on TCP
sockets, 2013-10-12).

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agohttp: centralize the accounting of libcurl dependencies
Ævar Arnfjörð Bjarmason [Mon, 13 Sep 2021 14:51:28 +0000 (16:51 +0200)] 
http: centralize the accounting of libcurl dependencies

As discussed in 644de29e220 (http: drop support for curl < 7.19.4,
2021-07-30) checking against LIBCURL_VERSION_NUM isn't as reliable as
checking specific symbols present in curl, as some distros have been
known to backport features.

However, while some of the curl_easy_setopt() arguments we rely on are
macros, others are enum, and we can't assume that those that are
macros won't change into enums in the future.

So we're still going to have to check LIBCURL_VERSION_NUM, but by
doing that in one central place and using a macro definition of our
own, anyone who's backporting features can define it themselves, and
thus have access to more modern curl features that they backported,
even if they didn't bump the LIBCURL_VERSION_NUM.

More importantly, as shown in a preceding commit doing these version
checks makes for hard to read and possibly buggy code, as shown by the
bug fixed there where we were conflating base 10 for base 16 when
comparing the version.

By doing them all in one place we'll hopefully reduce the chances of
such future mistakes, furthermore it now becomes easier to see at a
glance what the oldest supported version is, which makes it easier to
reason about any future deprecation similar to the recent
e48a623dea0 (Merge branch 'ab/http-drop-old-curl', 2021-08-24).

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agohttp: correct curl version check for CURLOPT_PINNEDPUBLICKEY
Ævar Arnfjörð Bjarmason [Mon, 13 Sep 2021 14:51:27 +0000 (16:51 +0200)] 
http: correct curl version check for CURLOPT_PINNEDPUBLICKEY

In aeff8a61216 (http: implement public key pinning, 2016-02-15) a
dependency and warning() was added if curl older than 7.44.0 was used,
but the relevant code depended on CURLOPT_PINNEDPUBLICKEY, introduced
in 7.39.0.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>