]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
2 years agomidx: preliminary support for `--refs-snapshot`
Taylor Blau [Wed, 29 Sep 2021 01:55:07 +0000 (21:55 -0400)] 
midx: preliminary support for `--refs-snapshot`

To figure out which commits we can write a bitmap for, the multi-pack
index/bitmap code does a reachability traversal, marking any commit
which can be found in the MIDX as eligible to receive a bitmap.

This approach will cause a problem when multi-pack bitmaps are able to
be generated from `git repack`, since the reference tips can change
during the repack. Even though we ignore commits that don't exist in
the MIDX (when doing a scan of the ref tips), it's possible that a
commit in the MIDX reaches something that isn't.

This can happen when a multi-pack index contains some pack which refers
to loose objects (e.g., if a pack was pushed after starting the repack
but before generating the MIDX which depends on an object which is
stored as loose in the repository, and by definition isn't included in
the multi-pack index).

By taking a snapshot of the references before we start repacking, we can
close that race window. In the above scenario (where we have a packed
object pointing at a loose one), we'll either (a) take a snapshot of the
references before seeing the packed one, or (b) take it after, at which
point we can guarantee that the loose object will be packed and included
in the MIDX.

This patch does just that. It writes a temporary "reference snapshot",
which is a list of OIDs that are at the ref tips before writing a
multi-pack bitmap. References that are "preferred" (i.e,. are a suffix
of at least one value of the 'pack.preferBitmapTips' configuration) are
marked with a special '+'.

The format is simple: one line per commit at each tip, with an optional
'+' at the beginning (for preferred references, as described above).

When provided, the reference snapshot is used to drive bitmap selection
instead of the MIDX code doing its own traversal. When it isn't
provided, the usual traversal takes place instead.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agobuiltin/multi-pack-index.c: support `--stdin-packs` mode
Taylor Blau [Wed, 29 Sep 2021 01:55:04 +0000 (21:55 -0400)] 
builtin/multi-pack-index.c: support `--stdin-packs` mode

To power a new `--write-midx` mode, `git repack` will want to write a
multi-pack index containing a certain set of packs in the repository.

This new option will be used by `git repack` to write a MIDX which
contains only the packs which will survive after the repack (that is, it
will exclude any packs which are about to be deleted).

This patch effectively exposes the function implemented in the previous
commit via the `git multi-pack-index` builtin. An alternative approach
would have been to call that function from the `git repack` builtin
directly, but this introduces awkward problems around closing and
reopening the object store, so the MIDX will be written out-of-process.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agomidx: expose `write_midx_file_only()` publicly
Taylor Blau [Wed, 29 Sep 2021 01:55:01 +0000 (21:55 -0400)] 
midx: expose `write_midx_file_only()` publicly

Expose a variant of the write_midx_file() function which ignores packs
that aren't included in an explicit "allow" list.

This will be used in an upcoming patch to power a new `--stdin-packs`
mode of `git multi-pack-index write` for callers that only want to
include certain packs in a MIDX (and ignore any packs which may have
happened to enter the repository independently, e.g., from pushes).

Those patches will provide test coverage for this new function.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agopack-bitmap: drop bitmap_index argument from try_partial_reuse()
Jeff King [Thu, 9 Sep 2021 19:57:21 +0000 (15:57 -0400)] 
pack-bitmap: drop bitmap_index argument from try_partial_reuse()

Starting in commit 0f533c7284 (pack-bitmap: read multi-pack bitmaps,
2021-08-31), we no longer look at the "struct bitmap_index" passed to
try_partial_reuse(). This is because we only handle verbatim reuse from
a single pack: either the pack whose bitmap we're looking at, or the
"preferred" pack of a midx bitmap. And thus the primary item we look at
is the "pack" parameter added by that same commit, and not the
bitmap_git->pack parameter (which would be NULL for a midx bitmap). It's
our caller, reuse_partial_packfile_from_bitmap(), which decides which
pack to use and passes it in to us.

Drop the unused parameter to prevent confusion.

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agopack-bitmap: drop repository argument from prepare_midx_bitmap_git()
Jeff King [Thu, 9 Sep 2021 19:56:58 +0000 (15:56 -0400)] 
pack-bitmap: drop repository argument from prepare_midx_bitmap_git()

We never look at the repository argument which is passed. This makes
sense, since the multi_pack_index struct already tells us everything we
need to access the files in its associated object directory.

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agop5326: perf tests for MIDX bitmaps
Taylor Blau [Tue, 31 Aug 2021 20:52:48 +0000 (16:52 -0400)] 
p5326: perf tests for MIDX bitmaps

These new performance tests demonstrate effectively the same behavior as
p5310, but use a multi-pack bitmap instead of a single-pack one.

Notably, p5326 does not create a MIDX bitmap with multiple packs. This
is so we can measure a direct comparison between it and p5310. Any
difference between the two is measuring just the overhead of using MIDX
bitmaps.

Here are the results of p5310 and p5326 together, measured at the same
time and on the same machine (using a Xenon W-2255 CPU):

    Test                                                  HEAD
    ------------------------------------------------------------------------
    5310.2: repack to disk                                96.78(93.39+11.33)
    5310.3: simulated clone                               9.98(9.79+0.19)
    5310.4: simulated fetch                               1.75(4.26+0.19)
    5310.5: pack to file (bitmap)                         28.20(27.87+8.70)
    5310.6: rev-list (commits)                            0.41(0.36+0.05)
    5310.7: rev-list (objects)                            1.61(1.54+0.07)
    5310.8: rev-list count with blob:none                 0.25(0.21+0.04)
    5310.9: rev-list count with blob:limit=1k             2.65(2.54+0.10)
    5310.10: rev-list count with tree:0                   0.23(0.19+0.04)
    5310.11: simulated partial clone                      4.34(4.21+0.12)
    5310.13: clone (partial bitmap)                       11.05(12.21+0.48)
    5310.14: pack to file (partial bitmap)                31.25(34.22+3.70)
    5310.15: rev-list with tree filter (partial bitmap)   0.26(0.22+0.04)

versus the same tests (this time using a multi-pack index):

    Test                                                  HEAD
    ------------------------------------------------------------------------
    5326.2: setup multi-pack index                        78.99(75.29+11.58)
    5326.3: simulated clone                               11.78(11.56+0.22)
    5326.4: simulated fetch                               1.70(4.49+0.13)
    5326.5: pack to file (bitmap)                         28.02(27.72+8.76)
    5326.6: rev-list (commits)                            0.42(0.36+0.06)
    5326.7: rev-list (objects)                            1.65(1.58+0.06)
    5326.8: rev-list count with blob:none                 0.26(0.21+0.05)
    5326.9: rev-list count with blob:limit=1k             2.97(2.86+0.10)
    5326.10: rev-list count with tree:0                   0.25(0.20+0.04)
    5326.11: simulated partial clone                      5.65(5.49+0.16)
    5326.13: clone (partial bitmap)                       12.22(13.43+0.38)
    5326.14: pack to file (partial bitmap)                30.05(31.57+7.25)
    5326.15: rev-list with tree filter (partial bitmap)   0.24(0.20+0.04)

There is slight overhead in "simulated clone", "simulated partial
clone", and "clone (partial bitmap)". Unsurprisingly, that overhead is
due to using the MIDX's reverse index to map between bit positions and
MIDX positions.

This can be reproduced by running "git repack -adb" along with "git
multi-pack-index write --bitmap" in a large-ish repository. Then run:

    $ perf record -o pack.perf git -c core.multiPackIndex=false \
      pack-objects --all --stdout >/dev/null </dev/null
    $ perf record -o midx.perf git -c core.multiPackIndex=true \
      pack-objects --all --stdout >/dev/null </dev/null

and compare the two with "perf diff -c delta -o 1 pack.perf midx.perf".
The most notable results are below (the next largest positive delta is
+0.14%):

    # Event 'cycles'
    #
    # Baseline    Delta  Shared Object       Symbol
    # ........  .......  ..................  ..........................
    #
                 +5.86%  git                 [.] nth_midxed_offset
                 +5.24%  git                 [.] nth_midxed_pack_int_id
         3.45%   +0.97%  git                 [.] offset_to_pack_pos
         3.30%   +0.57%  git                 [.] pack_pos_to_offset
                 +0.30%  git                 [.] pack_pos_to_midx

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agop5310: extract full and partial bitmap tests
Taylor Blau [Tue, 31 Aug 2021 20:52:46 +0000 (16:52 -0400)] 
p5310: extract full and partial bitmap tests

A new p5326 introduced by the next patch will want these same tests,
interjecting its own setup in between. Move them out so that both perf
tests can reuse them.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agomidx: respect 'GIT_TEST_MULTI_PACK_INDEX_WRITE_BITMAP'
Taylor Blau [Tue, 31 Aug 2021 20:52:43 +0000 (16:52 -0400)] 
midx: respect 'GIT_TEST_MULTI_PACK_INDEX_WRITE_BITMAP'

Introduce a new 'GIT_TEST_MULTI_PACK_INDEX_WRITE_BITMAP' environment
variable to also write a multi-pack bitmap when
'GIT_TEST_MULTI_PACK_INDEX' is set.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agot7700: update to work with MIDX bitmap test knob
Taylor Blau [Tue, 31 Aug 2021 20:52:41 +0000 (16:52 -0400)] 
t7700: update to work with MIDX bitmap test knob

A number of these tests are focused only on pack-based bitmaps and need
to be updated to disable 'GIT_TEST_MULTI_PACK_INDEX_WRITE_BITMAP' where
necessary.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agot5319: don't write MIDX bitmaps in t5319
Taylor Blau [Tue, 31 Aug 2021 20:52:38 +0000 (16:52 -0400)] 
t5319: don't write MIDX bitmaps in t5319

This test is specifically about generating a midx still respecting a
pack-based bitmap file. Generating a MIDX bitmap would confuse the test.
Let's override the 'GIT_TEST_MULTI_PACK_INDEX_WRITE_BITMAP' variable to
make sure we don't do so.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agot5310: disable GIT_TEST_MULTI_PACK_INDEX_WRITE_BITMAP
Jeff King [Tue, 31 Aug 2021 20:52:36 +0000 (16:52 -0400)] 
t5310: disable GIT_TEST_MULTI_PACK_INDEX_WRITE_BITMAP

Generating a MIDX bitmap confuses many of the tests in t5310, which
expect to control whether and how bitmaps are written. Since the
relevant MIDX-bitmap tests here are covered already in t5326, let's just
disable the flag for the whole t5310 script.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agot0410: disable GIT_TEST_MULTI_PACK_INDEX_WRITE_BITMAP
Jeff King [Tue, 31 Aug 2021 20:52:33 +0000 (16:52 -0400)] 
t0410: disable GIT_TEST_MULTI_PACK_INDEX_WRITE_BITMAP

Generating a MIDX bitmap causes tests which repack in a partial clone to
fail because they are missing objects. Missing objects is an expected
component of tests in t0410, so disable this knob altogether. Graceful
degradation when writing a bitmap with missing objects is tested in
t5326.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agot5326: test multi-pack bitmap behavior
Taylor Blau [Tue, 31 Aug 2021 20:52:31 +0000 (16:52 -0400)] 
t5326: test multi-pack bitmap behavior

This patch introduces a new test, t5326, which tests the basic
functionality of multi-pack bitmaps.

Some trivial behavior is tested, such as:

  - Whether bitmaps can be generated with more than one pack.
  - Whether clones can be served with all objects in the bitmap.
  - Whether follow-up fetches can be served with some objects outside of
    the server's bitmap

These use lib-bitmap's tests (which in turn were pulled from t5310), and
we cover cases where the MIDX represents both a single pack and multiple
packs.

In addition, some non-trivial and MIDX-specific behavior is tested, too,
including:

  - Whether multi-pack bitmaps behave correctly with respect to the
    pack-reuse machinery when the base for some object is selected from
    a different pack than the delta.
  - Whether multi-pack bitmaps correctly respect the
    pack.preferBitmapTips configuration.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agot/helper/test-read-midx.c: add --checksum mode
Taylor Blau [Tue, 31 Aug 2021 20:52:28 +0000 (16:52 -0400)] 
t/helper/test-read-midx.c: add --checksum mode

Subsequent tests will want to check for the existence of a multi-pack
bitmap which matches the multi-pack-index stored in the pack directory.

The multi-pack bitmap includes the hex checksum of the MIDX it
corresponds to in its filename (for example,
'$packdir/multi-pack-index-<checksum>.bitmap'). As a result, some tests
want a way to learn what '<checksum>' is.

This helper addresses that need by printing the checksum of the
repository's multi-pack-index.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agot5310: move some tests to lib-bitmap.sh
Taylor Blau [Tue, 31 Aug 2021 20:52:26 +0000 (16:52 -0400)] 
t5310: move some tests to lib-bitmap.sh

We'll soon be adding a test script that will cover many of the same
bitmap concepts as t5310, but for MIDX bitmaps. Let's pull out as many
of the applicable tests as we can so we don't have to rewrite them.

There should be no functional change to t5310; we still run the same
operations in the same order.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agopack-bitmap: write multi-pack bitmaps
Taylor Blau [Tue, 31 Aug 2021 20:52:24 +0000 (16:52 -0400)] 
pack-bitmap: write multi-pack bitmaps

Write multi-pack bitmaps in the format described by
Documentation/technical/bitmap-format.txt, inferring their presence with
the absence of '--bitmap'.

To write a multi-pack bitmap, this patch attempts to reuse as much of
the existing machinery from pack-objects as possible. Specifically, the
MIDX code prepares a packing_data struct that pretends as if a single
packfile has been generated containing all of the objects contained
within the MIDX.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agopack-bitmap: read multi-pack bitmaps
Taylor Blau [Tue, 31 Aug 2021 20:52:21 +0000 (16:52 -0400)] 
pack-bitmap: read multi-pack bitmaps

This prepares the code in pack-bitmap to interpret the new multi-pack
bitmaps described in Documentation/technical/bitmap-format.txt, which
mostly involves converting bit positions to accommodate looking them up
in a MIDX.

Note that there are currently no writers who write multi-pack bitmaps,
and that this will be implemented in the subsequent commit. Note also
that get_midx_checksum() and get_midx_filename() are made non-static so
they can be called from pack-bitmap.c.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agopack-bitmap.c: avoid redundant calls to try_partial_reuse
Taylor Blau [Tue, 31 Aug 2021 20:52:19 +0000 (16:52 -0400)] 
pack-bitmap.c: avoid redundant calls to try_partial_reuse

try_partial_reuse() is used to mark any bits in the beginning of a
bitmap whose objects can be reused verbatim from the pack they came
from.

Currently this function returns void, and signals nothing to the caller
when bits could not be reused. But multi-pack bitmaps would benefit from
having such a signal, because they may try to pass objects which are in
bounds, but from a pack other than the preferred one.

Any extra calls are noops because of a conditional in
reuse_partial_packfile_from_bitmap(), but those loop iterations can be
avoided by letting try_partial_reuse() indicate when it can't accept any
more bits for reuse, and then listening to that signal.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agopack-bitmap.c: introduce 'bitmap_is_preferred_refname()'
Taylor Blau [Tue, 31 Aug 2021 20:52:16 +0000 (16:52 -0400)] 
pack-bitmap.c: introduce 'bitmap_is_preferred_refname()'

In a recent commit, pack-objects learned support for the
'pack.preferBitmapTips' configuration. This patch prepares the
multi-pack bitmap code to respect this configuration, too.

The yet-to-be implemented code will find that it is more efficient to
check whether each reference contains a prefix found in the configured
set of values rather than doing an additional traversal.

Implement a function 'bitmap_is_preferred_refname()' which will perform
that check. Its caller will be added in a subsequent patch.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agopack-bitmap.c: introduce 'nth_bitmap_object_oid()'
Taylor Blau [Tue, 31 Aug 2021 20:52:14 +0000 (16:52 -0400)] 
pack-bitmap.c: introduce 'nth_bitmap_object_oid()'

A subsequent patch to support reading MIDX bitmaps will be less noisy
after extracting a generic function to fetch the nth OID contained in
the bitmap.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agopack-bitmap.c: introduce 'bitmap_num_objects()'
Taylor Blau [Tue, 31 Aug 2021 20:52:12 +0000 (16:52 -0400)] 
pack-bitmap.c: introduce 'bitmap_num_objects()'

A subsequent patch to support reading MIDX bitmaps will be less noisy
after extracting a generic function to return how many objects are
contained in a bitmap.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agomidx: avoid opening multiple MIDXs when writing
Taylor Blau [Wed, 1 Sep 2021 20:34:01 +0000 (16:34 -0400)] 
midx: avoid opening multiple MIDXs when writing

Opening multiple instance of the same MIDX can lead to problems like two
separate packed_git structures which represent the same pack being added
to the repository's object store.

The above scenario can happen because prepare_midx_pack() checks if
`m->packs[pack_int_id]` is NULL in order to determine if a pack has been
opened and installed in the repository before. But a caller can
construct two copies of the same MIDX by calling get_multi_pack_index()
and load_multi_pack_index() since the former manipulates the
object store directly but the latter is a lower-level routine which
allocates a new MIDX for each call.

So if prepare_midx_pack() is called on multiple MIDXs with the same
pack_int_id, then that pack will be installed twice in the object
store's packed_git pointer.

This can lead to problems in, for e.g., the pack-bitmap code, which does
something like the following (in pack-bitmap.c:open_pack_bitmap()):

    struct bitmap_index *bitmap_git = ...;
    for (p = get_all_packs(r); p; p = p->next) {
      if (open_pack_bitmap_1(bitmap_git, p) == 0)
        ret = 0;
    }

which is a problem if two copies of the same pack exist in the
packed_git list because pack-bitmap.c:open_pack_bitmap_1() contains a
conditional like the following:

    if (bitmap_git->pack || bitmap_git->midx) {
      /* ignore extra bitmap file; we can only handle one */
      warning("ignoring extra bitmap file: %s", packfile->pack_name);
      close(fd);
      return -1;
    }

Avoid this scenario by not letting write_midx_internal() open a MIDX
that isn't also pointed at by the object store. So long as this is the
case, other routines should prefer to open MIDXs with
get_multi_pack_index() or reprepare_packed_git() instead of creating
instances on their own. Because get_multi_pack_index() returns
`r->object_store->multi_pack_index` if it is non-NULL, we'll only have
one instance of a MIDX open at one time, avoiding these problems.

To encourage this, drop the `struct multi_pack_index *` parameter from
`write_midx_internal()`, and rely instead on the `object_dir` to find
(or initialize) the correct MIDX instance.

Likewise, replace the call to `close_midx()` with
`close_object_store()`, since we're about to replace the MIDX with a new
one and should invalidate the object store's memory of any MIDX that
might have existed beforehand.

Note that this now forbids passing object directories that don't belong
to alternate repositories over `--object-dir`, since before we would
have happily opened a MIDX in any directory, but now restrict ourselves
to only those reachable by `r->objects->multi_pack_index` (and alternate
MIDXs that we can see by walking the `next` pointer).

As far as I can tell, supporting arbitrary directories with
`--object-dir` was a historical accident, since even the documentation
says `<alt>` when referring to the value passed to this option.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agomidx: close linked MIDXs, avoid leaking memory
Taylor Blau [Tue, 31 Aug 2021 20:52:07 +0000 (16:52 -0400)] 
midx: close linked MIDXs, avoid leaking memory

When a repository has at least one alternate, the MIDX belonging to each
alternate is accessed through the `next` pointer on the main object
store's copy of the MIDX. close_midx() didn't bother to close any
of the linked MIDXs. It likewise didn't free the memory pointed to by
`m`, leaving uninitialized bytes with live pointers to them left around
in the heap.

Clean this up by closing linked MIDXs, and freeing up the memory pointed
to by each of them. When callers call close_midx(), then they can
discard the entire linked list of MIDXs and set their pointer to the
head of that list to NULL.

This isn't strictly required for the upcoming patches, but it makes it
much more difficult (though still possible, for e.g., by calling
`close_midx(m->next)` which leaves `m->next` pointing at uninitialized
bytes) to have pointers to uninitialized memory.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agomidx: infer preferred pack when not given one
Taylor Blau [Tue, 31 Aug 2021 20:52:04 +0000 (16:52 -0400)] 
midx: infer preferred pack when not given one

In 9218c6a40c (midx: allow marking a pack as preferred, 2021-03-30), the
multi-pack index code learned how to select a pack which all duplicate
objects are selected from. That is, if an object appears in multiple
packs, select the copy in the preferred pack before breaking ties
according to the other rules like pack mtime and readdir() order.

Not specifying a preferred pack can cause serious problems with
multi-pack reachability bitmaps, because these bitmaps rely on having at
least one pack from which all duplicates are selected. Not having such a
pack causes problems with the code in pack-objects to reuse packs
verbatim (e.g., that code assumes that a delta object in a chunk of pack
sent verbatim will have its base object sent from the same pack).

So why does not marking a pack preferred cause problems here? The reason
is roughly as follows:

  - Ties are broken (when handling duplicate objects) by sorting
    according to midx_oid_compare(), which sorts objects by OID,
    preferred-ness, pack mtime, and finally pack ID (more on that
    later).

  - The psuedo pack-order (described in
    Documentation/technical/pack-format.txt under the section
    "multi-pack-index reverse indexes") is computed by
    midx_pack_order(), and sorts by pack ID and pack offset, with
    preferred packs sorting first.

  - But! Pack IDs come from incrementing the pack count in
    add_pack_to_midx(), which is a callback to
    for_each_file_in_pack_dir(), meaning that pack IDs are assigned in
    readdir() order.

When specifying a preferred pack, all of that works fine, because
duplicate objects are correctly resolved in favor of the copy in the
preferred pack, and the preferred pack sorts first in the object order.

"Sorting first" is critical, because the bitmap code relies on finding
out which pack holds the first object in the MIDX's pseudo pack-order to
determine which pack is preferred.

But if we didn't specify a preferred pack, and the pack which comes
first in readdir() order does not also have the lowest timestamp, then
it's possible that that pack (the one that sorts first in pseudo-pack
order, which the bitmap code will treat as the preferred one) did *not*
have all duplicate objects resolved in its favor, resulting in breakage.

The fix is simple: pick a (semi-arbitrary, non-empty) preferred pack
when none was specified. This forces that pack to have duplicates
resolved in its favor, and (critically) to sort first in pseudo-pack
order.  Unfortunately, testing this behavior portably isn't possible,
since it depends on readdir() order which isn't guaranteed by POSIX.

(Note that multi-pack reachability bitmaps have yet to be implemented;
so in that sense this patch is fixing a bug which does not yet exist.
But by having this patch beforehand, we can prevent the bug from ever
materializing.)

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agomidx: reject empty `--preferred-pack`'s
Taylor Blau [Tue, 31 Aug 2021 20:52:02 +0000 (16:52 -0400)] 
midx: reject empty `--preferred-pack`'s

The soon-to-be-implemented multi-pack bitmap treats object in the first
bit position specially by assuming that all objects in the pack it was
selected from are also represented from that pack in the MIDX. In other
words, the pack from which the first object was selected must also have
all of its other objects selected from that same pack in the MIDX in
case of any duplicates.

But this assumption relies on the fact that there is at least one object
in that pack to begin with; otherwise the object in the first bit
position isn't from a preferred pack, in which case we can no longer
assume that all objects in that pack were also selected from the same
pack.

Guard this assumption by checking the number of objects in the given
preferred pack, and failing if the given pack is empty.

To make sure we can safely perform this check, open any packs which are
contained in an existing MIDX via prepare_midx_pack(). The same is done
for new packs via the add_pack_to_midx() callback, but packs picked up
from a previous MIDX will not yet have these opened.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agomidx: clear auxiliary .rev after replacing the MIDX
Taylor Blau [Tue, 31 Aug 2021 20:51:59 +0000 (16:51 -0400)] 
midx: clear auxiliary .rev after replacing the MIDX

When writing a new multi-pack index, write_midx_internal() attempts to
clean up any auxiliary files (currently just the MIDX's `.rev` file, but
soon to include a `.bitmap`, too) corresponding to the MIDX it's
replacing.

This step should happen after the new MIDX is written into place, since
doing so beforehand means that the old MIDX could be read without its
corresponding .rev file.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agomidx: fix `*.rev` cleanups with `--object-dir`
Taylor Blau [Tue, 31 Aug 2021 20:51:55 +0000 (16:51 -0400)] 
midx: fix `*.rev` cleanups with `--object-dir`

If using --object-dir to point into an object directory which belongs to
a different repository than the one in the current working directory,
such as:

  git init repo
  git -C repo ... # add some objects
  cd alternate
  git multi-pack-index --object-dir ../repo/.git/objects write

the binary will segfault trying to access the object-dir via the repo it
found, but that's not fully initialized. Worse, if we later call
clear_midx_files_ext(), we will use `the_repository` and remove files
out of the wrong object directory.

Fix this by using the given object_dir (or the object directory of
`the_repository` if `--object-dir` wasn't given) to properly to clean up
the *.rev files, avoiding the crash.

Original-patch-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agomidx: disallow running outside of a repository
Taylor Blau [Tue, 31 Aug 2021 20:51:53 +0000 (16:51 -0400)] 
midx: disallow running outside of a repository

The multi-pack-index command supports working with arbitrary object
directories via the `--object-dir` flag. Though this has historically
worked in arbitrary repositories (including when the command itself was
run outside of a Git repository), this has been somewhat of an accident.

For example, running:

    git multi-pack-index write --object-dir=/path/to/repo/objects

outside of a Git repository causes a BUG(). This is because the
top-level `cmd_multi_pack_index()` function stops parsing when it sees
"write", and then fills in the default object directory (the result of
calling `get_object_directory()`) before handing off to
`cmd_multi_pack_index_write()`. But there is no repository to
initialize, and so calling `get_object_directory()` results in a BUG()
(indicating that the current repository is not initialized).

Another case where this doesn't quite work as expected is when operating
in a SHA-256 repository. To see the failure, try this in your shell:

    git init --object-format=sha256 repo
    git -C repo commit --allow-empty base
    git -C repo repack -d

    git multi-pack-index --object-dir=$(pwd)/repo/.git/objects write

and observe that we cannot open the `.idx` file in "repo", because the
outermost process assumes that any repository that it works in also uses
the default value of `the_hash_algo` (at the time of writing, SHA-1).

There may be compelling reasons for trying to work around these bugs,
but working in arbitrary `--object-dir`'s is non-standard enough (and
likewise, these bugs prevalent enough) that I don't think any workflows
would be broken by abandoning this behavior.

Accordingly, restrict the `multi-pack-index` builtin to only work when
inside of a Git repository (i.e., its main utility becomes selecting
which alternate to operate in), which avoids both of the bugs above.

(Note that you can still trigger a bug when writing a MIDX in an
alternate which does not use the same object format as the repository
which it is an alternate of, but that is an unrelated bug to this one).

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoDocumentation: describe MIDX-based bitmaps
Taylor Blau [Tue, 24 Aug 2021 16:15:59 +0000 (12:15 -0400)] 
Documentation: describe MIDX-based bitmaps

Update the technical documentation to describe the multi-pack bitmap
format. This patch merely introduces the new format, and describes its
high-level ideas. Git does not yet know how to read nor write these
multi-pack variants, and so the subsequent patches will:

  - Introduce code to interpret multi-pack bitmaps, according to this
    document.

  - Then, introduce code to write multi-pack bitmaps from the 'git
    multi-pack-index write' sub-command.

Finally, the implementation will gain tests in subsequent patches (as
opposed to inline with the patch teaching Git how to write multi-pack
bitmaps) to avoid a cyclic dependency.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agopack-bitmap-write.c: free existing bitmaps
Taylor Blau [Tue, 24 Aug 2021 16:15:56 +0000 (12:15 -0400)] 
pack-bitmap-write.c: free existing bitmaps

When writing a new bitmap, the bitmap writer code attempts to read the
existing bitmap (if one is present). This is done in order to quickly
permute the bits of any bitmaps for commits which appear in the existing
bitmap, and were also selected for the new bitmap.

But since this code was added in 341fa34887 (pack-bitmap-write: use
existing bitmaps, 2020-12-08), the resources associated with opening an
existing bitmap were never released.

It's fine to ignore this, but it's bad hygiene. It will also cause a
problem for the multi-pack-index builtin, which will be responsible not
only for writing bitmaps, but also for expiring any old multi-pack
bitmaps.

If an existing bitmap was reused here, it will also be expired. That
will cause a problem on platforms which require file resources to be
closed before unlinking them, like Windows. Avoid this by ensuring we
close reused bitmaps with free_bitmap_index() before removing them.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agopack-bitmap-write.c: gracefully fail to write non-closed bitmaps
Taylor Blau [Tue, 24 Aug 2021 16:15:54 +0000 (12:15 -0400)] 
pack-bitmap-write.c: gracefully fail to write non-closed bitmaps

The set of objects covered by a bitmap must be closed under
reachability, since it must be the case that there is a valid bit
position assigned for every possible reachable object (otherwise the
bitmaps would be incomplete).

Pack bitmaps are never written from 'git repack' unless repacking
all-into-one, and so we never write non-closed bitmaps (except in the
case of partial clones where we aren't guaranteed to have all objects).

But multi-pack bitmaps change this, since it isn't known whether the
set of objects in the MIDX is closed under reachability until walking
them. Plumb through a bit that is set when a reachable object isn't
found.

As soon as a reachable object isn't found in the set of objects to
include in the bitmap, bitmap_writer_build() knows that the set is not
closed, and so it now fails gracefully.

A test is added in t0410 to trigger a bitmap write without full
reachability closure by removing local copies of some reachable objects
from a promisor remote.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agopack-bitmap.c: harden 'test_bitmap_walk()' to check type bitmaps
Taylor Blau [Tue, 24 Aug 2021 16:15:51 +0000 (12:15 -0400)] 
pack-bitmap.c: harden 'test_bitmap_walk()' to check type bitmaps

The special `--test-bitmap` mode of `git rev-list` is used to compare
the result of an object traversal with a bitmap to check its integrity.
This mode does not, however, assert that the types of reachable objects
are stored correctly.

Harden this mode by teaching it to also check that each time an object's
bit is marked, the corresponding bit should be set in exactly one of the
type bitmaps (whose type matches the object's true type).

Co-authored-by: Jeff King <peff@peff.net>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoGit 2.33 v2.33.0
Junio C Hamano [Mon, 16 Aug 2021 19:15:44 +0000 (12:15 -0700)] 
Git 2.33

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoMerge branch 'rs/oidtree-alignment-fix'
Junio C Hamano [Mon, 16 Aug 2021 19:14:35 +0000 (12:14 -0700)] 
Merge branch 'rs/oidtree-alignment-fix'

Codepath to access recently added oidtree data structure had
to make unaligned accesses to oids, which has been corrected.

* rs/oidtree-alignment-fix:
  oidtree: avoid unaligned access to crit-bit tree

2 years agoMerge tag 'l10n-2.33.0-rnd2' of git://github.com/git-l10n/git-po
Junio C Hamano [Mon, 16 Aug 2021 16:38:57 +0000 (09:38 -0700)] 
Merge tag 'l10n-2.33.0-rnd2' of git://github.com/git-l10n/git-po

l10n-2.33.0-rnd2

* tag 'l10n-2.33.0-rnd2' of git://github.com/git-l10n/git-po: (46 commits)
  l10n: sv.po: Update Swedish translation (5230t0f0u)
  l10n: TEAMS: change Simplified Chinese team leader
  l10n: tr: v2.33 (round 2)
  l10n: es: 2.33.0 round 2
  l10n: zh_CN: for git v2.33.0 l10n round 2
  l10n: zh_CN: Revision for git v2.32.0 l10n round 1
  l10n: README: refactor to use GFM syntax
  l10n: update German translation for Git v2.33.0 (rnd2)
  l10n: pt_PT: v2.33.0 round 2
  l10n: pt_PT: git-po-helper update
  l10n: pt_PT: update translation table
  l10n: zh_TW.po: remove the obsolete glossary
  l10n: vi.po(5230t): Updated translation for v2.32.0 round 2
  l10n: fr.po v2.33 rnd 2
  l10n: id: po-id for 2.33.0 round 2
  l10n: zh_TW.po: update for v2.33.0 rnd 2
  l10n: git.pot: v2.33.0 round 2 (11 new, 8 removed)
  l10n: de.po: fix typos
  l10n: update German translation for Git v2.33.0
  l10n: fr.po fix typos in commands and variables
  ...

2 years agol10n: sv.po: Update Swedish translation (5230t0f0u)
Peter Krefting [Sat, 14 Aug 2021 20:15:58 +0000 (21:15 +0100)] 
l10n: sv.po: Update Swedish translation (5230t0f0u)

Also fixed some typos reported by "git-po-helper".

Signed-off-by: Peter Krefting <peter@softwolves.pp.se>
Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
2 years agol10n: TEAMS: change Simplified Chinese team leader
Jiang Xin [Sun, 15 Aug 2021 22:39:30 +0000 (06:39 +0800)] 
l10n: TEAMS: change Simplified Chinese team leader

Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
2 years agooidtree: avoid unaligned access to crit-bit tree
René Scharfe [Sat, 14 Aug 2021 20:00:38 +0000 (22:00 +0200)] 
oidtree: avoid unaligned access to crit-bit tree

The flexible array member "k" of struct cb_node is used to store the key
of the crit-bit tree node.  It offers no alignment guarantees -- in fact
the current struct layout puts it one byte after a 4-byte aligned
address, i.e. guaranteed to be misaligned.

oidtree uses a struct object_id as cb_node key.  Since cf0983213c (hash:
add an algo member to struct object_id, 2021-04-26) it requires 4-byte
alignment.  The mismatch is reported by UndefinedBehaviorSanitizer at
runtime like this:

hash.h:277:2: runtime error: member access within misaligned address 0x00015000802d for type 'struct object_id', which requires 4 byte alignment
0x00015000802d: note: pointer points here
 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00
             ^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior hash.h:277:2 in

We can fix that by:

1. eliminating the alignment requirement of struct object_id,
2. providing the alignment in struct cb_node, or
3. avoiding the issue by only using memcpy to access "k".

Currently we only store one of two values in "algo" in struct object_id.
We could use a uint8_t for that instead and widen it only once we add
support for our twohundredth algorithm or so.  That would not only avoid
alignment issues, but also reduce the memory requirements for each
instance of struct object_id by ca. 9%.

Supporting keys with alignment requirements might be useful to spread
the use of crit-bit trees.  It can be achieved by using a wider type for
"k" (e.g. uintmax_t), using different types for the members "byte" and
"otherbits" (e.g. uint16_t or uint32_t for each), or by avoiding the use
of flexible arrays like khash.h does.

This patch implements the third option, though, because it has the least
potential for causing side-effects and we're close to the next release.
If one of the other options is implemented later as well to get their
additional benefits we can get rid of the extra copies introduced here.

Reported-by: Andrzej Hunt <andrzej@ahunt.org>
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoMerge branch 'next' of github.com:ChrisADR/git-po
Jiang Xin [Sun, 15 Aug 2021 10:32:20 +0000 (18:32 +0800)] 
Merge branch 'next' of github.com:ChrisADR/git-po

* 'next' of github.com:ChrisADR/git-po:
  l10n: es: 2.33.0 round 2

2 years agol10n: tr: v2.33 (round 2)
Emir Sarı [Sun, 15 Aug 2021 07:17:15 +0000 (10:17 +0300)] 
l10n: tr: v2.33 (round 2)

Signed-off-by: Emir Sarı <bitigchi@me.com>
2 years agol10n: es: 2.33.0 round 2
Christopher Diaz Riveros [Sat, 14 Aug 2021 16:13:11 +0000 (11:13 -0500)] 
l10n: es: 2.33.0 round 2

Signed-off-by: Christopher Diaz Riveros <christopher.diaz.riv@gmail.com>
Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
Signed-off-by: Javier Spagnoletti phansys@gmail.com
Signed-off-by: Cleydyr Albuquerque <cleydyr@gmail.com>
Signed-off-by: Andrei Rybak <rybak.a.v@gmail.com>
Signed-off-by: Guillermo Ramos <gramosg>
2 years agol10n: zh_CN: for git v2.33.0 l10n round 2
Jiang Xin [Mon, 2 Aug 2021 00:25:39 +0000 (08:25 +0800)] 
l10n: zh_CN: for git v2.33.0 l10n round 2

Translate 48 new messages (5230t0f0u) for git 2.33.0, and also fixed
typos found by "git-po-helper".

Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
Signed-off-by: Fangyi Zhou <me@fangyi.io>
2 years agol10n: zh_CN: Revision for git v2.32.0 l10n round 1
Fangyi Zhou [Mon, 7 Jun 2021 04:59:56 +0000 (12:59 +0800)] 
l10n: zh_CN: Revision for git v2.32.0 l10n round 1

Signed-off-by: Fangyi Zhou <me@fangyi.io>
2 years agol10n: README: refactor to use GFM syntax
Jiang Xin [Fri, 6 Aug 2021 03:07:48 +0000 (11:07 +0800)] 
l10n: README: refactor to use GFM syntax

Format README.md using GFM (GitHub Flavored Markdown) syntax.

- In order to use more than 3 level headings, use ATX style headings
  instead of setext style headings.

- In order to add highlights for code blocks, use fenced code blocks
  instead of indented code blocks.

Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
2 years agoMerge branch 'l10n-2.33-rnd2' of github.com:ralfth/git
Jiang Xin [Sun, 15 Aug 2021 02:26:18 +0000 (10:26 +0800)] 
Merge branch 'l10n-2.33-rnd2' of github.com:ralfth/git

* 'l10n-2.33-rnd2' of github.com:ralfth/git:
  l10n: update German translation for Git v2.33.0 (rnd2)

2 years agoMerge branch 'pt-PT' of github.com:git-l10n-pt-PT/git-po
Jiang Xin [Sun, 15 Aug 2021 02:24:24 +0000 (10:24 +0800)] 
Merge branch 'pt-PT' of github.com:git-l10n-pt-PT/git-po

* 'pt-PT' of github.com:git-l10n-pt-PT/git-po:
  l10n: pt_PT: v2.33.0 round 2
  l10n: pt_PT: git-po-helper update
  l10n: pt_PT: update translation table

2 years agol10n: update German translation for Git v2.33.0 (rnd2)
Ralf Thielow [Sat, 14 Aug 2021 14:35:44 +0000 (16:35 +0200)] 
l10n: update German translation for Git v2.33.0 (rnd2)

Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com>
2 years agol10n: pt_PT: v2.33.0 round 2
Daniel Santos [Sat, 14 Aug 2021 12:02:31 +0000 (13:02 +0100)] 
l10n: pt_PT: v2.33.0 round 2

 * translation of new entries

Signed-off-by: Daniel Santos <hello@brighterdan.com>
2 years agol10n: pt_PT: git-po-helper update
Daniel Santos [Sat, 14 Aug 2021 11:08:39 +0000 (12:08 +0100)] 
l10n: pt_PT: git-po-helper update

 * run git-po-helper update pt_PT.po

Signed-off-by: Daniel Santos <hello@brighterdan.com>
2 years agol10n: pt_PT: update translation table
Daniel Santos [Thu, 12 Aug 2021 21:13:03 +0000 (22:13 +0100)] 
l10n: pt_PT: update translation table

 * updated translation table

Signed-off-by: Daniel Santos <hello@brighterdan.com>
2 years agoMerge branch 'loc/zh_TW/210814' of github.com:l10n-tw/git-po
Jiang Xin [Sat, 14 Aug 2021 11:30:54 +0000 (19:30 +0800)] 
Merge branch 'loc/zh_TW/210814' of github.com:l10n-tw/git-po

* 'loc/zh_TW/210814' of github.com:l10n-tw/git-po:
  l10n: zh_TW.po: remove the obsolete glossary
  l10n: zh_TW.po: update for v2.33.0 rnd 2

2 years agol10n: zh_TW.po: remove the obsolete glossary
Yi-Jyun Pan [Sat, 14 Aug 2021 06:11:42 +0000 (14:11 +0800)] 
l10n: zh_TW.po: remove the obsolete glossary

Signed-off-by: Yi-Jyun Pan <pan93412@gmail.com>
2 years agoMerge branch 'master' of github.com:vnwildman/git
Jiang Xin [Sat, 14 Aug 2021 09:02:54 +0000 (17:02 +0800)] 
Merge branch 'master' of github.com:vnwildman/git

* 'master' of github.com:vnwildman/git:
  l10n: vi.po(5230t): Updated translation for v2.32.0 round 2

2 years agoMerge branch 'po-id' of github.com:bagasme/git-po
Jiang Xin [Sat, 14 Aug 2021 09:01:27 +0000 (17:01 +0800)] 
Merge branch 'po-id' of github.com:bagasme/git-po

* 'po-id' of github.com:bagasme/git-po:
  l10n: id: po-id for 2.33.0 round 2

2 years agol10n: vi.po(5230t): Updated translation for v2.32.0 round 2
Tran Ngoc Quan [Sat, 14 Aug 2021 07:54:44 +0000 (14:54 +0700)] 
l10n: vi.po(5230t): Updated translation for v2.32.0 round 2

Signed-off-by: Tran Ngoc Quan <vnwildman@gmail.com>
2 years agol10n: fr.po v2.33 rnd 2
Jean-Noël Avila [Sat, 14 Aug 2021 06:28:48 +0000 (08:28 +0200)] 
l10n: fr.po v2.33 rnd 2

Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
2 years agol10n: id: po-id for 2.33.0 round 2
Bagas Sanjaya [Sat, 14 Aug 2021 02:35:18 +0000 (09:35 +0700)] 
l10n: id: po-id for 2.33.0 round 2

Update translation for following component:
  * builtin/submodule--helper.c

Translate following new component:
  * builtin/revert.c

Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>
2 years agol10n: zh_TW.po: update for v2.33.0 rnd 2
Yi-Jyun Pan [Sat, 14 Aug 2021 05:48:09 +0000 (13:48 +0800)] 
l10n: zh_TW.po: update for v2.33.0 rnd 2

Signed-off-by: Yi-Jyun Pan <pan93412@gmail.com>
2 years agoMerge branch 'master' of github.com:vnwildman/git
Jiang Xin [Sat, 14 Aug 2021 03:52:34 +0000 (11:52 +0800)] 
Merge branch 'master' of github.com:vnwildman/git

* 'master' of github.com:vnwildman/git:
  l10n: vi.po(5227t): Fixed typo after run git-po-helper

2 years agol10n: git.pot: v2.33.0 round 2 (11 new, 8 removed)
Jiang Xin [Fri, 13 Aug 2021 23:57:34 +0000 (07:57 +0800)] 
l10n: git.pot: v2.33.0 round 2 (11 new, 8 removed)

Generate po/git.pot from v2.33.0-rc2 for git v2.33.0 l10n round 2.

Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
2 years agoMerge branch 'master' of github.com:git/git
Jiang Xin [Fri, 13 Aug 2021 23:56:22 +0000 (07:56 +0800)] 
Merge branch 'master' of github.com:git/git

* 'master' of github.com:git/git: (51 commits)
  Git 2.33-rc2
  object-file: use unsigned arithmetic with bit mask
  Revert 'diff-merges: let "-m" imply "-p"'
  object-store: avoid extra ';' from KHASH_INIT
  oidtree: avoid nested struct oidtree_node
  Git 2.33-rc1
  test: fix for COLUMNS and bash 5
  The eighth batch
  diff: --pickaxe-all typofix
  mingw: align symlinks-related rmdir() behavior with Linux
  t7508: avoid non POSIX BRE
  use fspathhash() everywhere
  t0001: fix broken not-quite getcwd(3) test in bed67874e2
  Documentation: render special characters correctly
  reset: clear_unpack_trees_porcelain to plug leak
  builtin/rebase: fix options.strategy memory lifecycle
  builtin/merge: free found_ref when done
  builtin/mv: free or UNLEAK multiple pointers at end of cmd_mv
  convert: release strbuf to avoid leak
  read-cache: call diff_setup_done to avoid leak
  ...

2 years agoMerge branch 'master' of github.com:nafmo/git-l10n-sv
Jiang Xin [Fri, 13 Aug 2021 23:55:01 +0000 (07:55 +0800)] 
Merge branch 'master' of github.com:nafmo/git-l10n-sv

* 'master' of github.com:nafmo/git-l10n-sv:
  l10n: sv.po: Update Swedish translation (5227t0f0u)

2 years agoMerge branch 'master' of github.com:alshopov/git-po
Jiang Xin [Fri, 13 Aug 2021 23:54:38 +0000 (07:54 +0800)] 
Merge branch 'master' of github.com:alshopov/git-po

* 'master' of github.com:alshopov/git-po:
  l10n: bg.po: Updated Bulgarian translation (5227t)

2 years agoMerge branch 'l10n-2.33' of github.com:ralfth/git
Jiang Xin [Fri, 13 Aug 2021 23:50:33 +0000 (07:50 +0800)] 
Merge branch 'l10n-2.33' of github.com:ralfth/git

* 'l10n-2.33' of github.com:ralfth/git:
  l10n: de.po: fix typos
  l10n: update German translation for Git v2.33.0

2 years agoMerge branch 'fr_fix_typos' of github.com:jnavila/git
Jiang Xin [Fri, 13 Aug 2021 23:45:37 +0000 (07:45 +0800)] 
Merge branch 'fr_fix_typos' of github.com:jnavila/git

* 'fr_fix_typos' of github.com:jnavila/git:
  l10n: fr.po fix typos in commands and variables

2 years agoMerge branch 'master' of github.com:Softcatala/git-po
Jiang Xin [Fri, 13 Aug 2021 23:44:41 +0000 (07:44 +0800)] 
Merge branch 'master' of github.com:Softcatala/git-po

* 'master' of github.com:Softcatala/git-po:
  l10n: Update Catalan translation

2 years agol10n: de.po: fix typos
Ralf Thielow [Fri, 13 Aug 2021 15:07:04 +0000 (17:07 +0200)] 
l10n: de.po: fix typos

Fix some typos found by `./git-po-helper check-po po/de.po`.

Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com>
2 years agol10n: update German translation for Git v2.33.0
Ralf Thielow [Mon, 9 Aug 2021 14:50:31 +0000 (16:50 +0200)] 
l10n: update German translation for Git v2.33.0

Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com>
2 years agol10n: fr.po fix typos in commands and variables
Jean-Noël Avila [Thu, 12 Aug 2021 19:09:51 +0000 (21:09 +0200)] 
l10n: fr.po fix typos in commands and variables

Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
2 years agol10n: id: mismatch variable name fixes
Bagas Sanjaya [Thu, 12 Aug 2021 10:18:29 +0000 (17:18 +0700)] 
l10n: id: mismatch variable name fixes

Jiang Xin reported possible typos in po/id.po, all of them are mismatch
variable names. Fix them.

Reported-by: Jiang Xin <worldhello.net@gmail.com>
Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>
2 years agol10n: vi.po(5227t): Fixed typo after run git-po-helper
Tran Ngoc Quan [Thu, 12 Aug 2021 07:05:39 +0000 (14:05 +0700)] 
l10n: vi.po(5227t): Fixed typo after run git-po-helper

Signed-off-by: Tran Ngoc Quan <vnwildman@gmail.com>
2 years agol10n: Update Catalan translation
Jordi Mas [Thu, 12 Aug 2021 06:07:32 +0000 (08:07 +0200)] 
l10n: Update Catalan translation

Signed-off-by: Jordi Mas <jmas@softcatala.org>
2 years agoMerge branch 'daniel' of github.com:git-l10n-pt-PT/git-po
Jiang Xin [Thu, 12 Aug 2021 00:23:55 +0000 (08:23 +0800)] 
Merge branch 'daniel' of github.com:git-l10n-pt-PT/git-po

* 'daniel' of github.com:git-l10n-pt-PT/git-po:
  l10n: pt_PT: cleaning flags mismatch
  l10n: pt_PT: cleaning duplicate translations
  l10n: pt_PT: update translation tables
  l10n: pt_PT: translated git v2.33.0
  l10n: pt_PT: update git-po-helper
  l10n: pt_PT: remove trailing comments
  l10n: pt_PT: translation tables
  l10n: pt_PT: add Portuguese translations part 5
  l10n: pt_PT: add Portuguese translations part 4

2 years agoGit 2.33-rc2 v2.33.0-rc2
Junio C Hamano [Wed, 11 Aug 2021 18:54:03 +0000 (11:54 -0700)] 
Git 2.33-rc2

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoMerge branch 'jn/log-m-does-not-imply-p'
Junio C Hamano [Wed, 11 Aug 2021 19:36:18 +0000 (12:36 -0700)] 
Merge branch 'jn/log-m-does-not-imply-p'

Earlier "git log -m" was changed to always produce patch output,
which would break existing scripts, which has been reverted.

* jn/log-m-does-not-imply-p:
  Revert 'diff-merges: let "-m" imply "-p"'

2 years agoMerge branch 'cb/many-alternate-optim-fixup'
Junio C Hamano [Wed, 11 Aug 2021 19:36:17 +0000 (12:36 -0700)] 
Merge branch 'cb/many-alternate-optim-fixup'

Build fix.

* cb/many-alternate-optim-fixup:
  object-file: use unsigned arithmetic with bit mask
  object-store: avoid extra ';' from KHASH_INIT
  oidtree: avoid nested struct oidtree_node

2 years agoobject-file: use unsigned arithmetic with bit mask
René Scharfe [Fri, 6 Aug 2021 17:53:47 +0000 (19:53 +0200)] 
object-file: use unsigned arithmetic with bit mask

33f379eee6 (make object_directory.loose_objects_subdir_seen a bitmap,
2021-07-07) replaced a wasteful 256-byte array with a 32-byte array
and bit operations.  The mask calculation shifts a literal 1 of type
int left by anything between 0 and 31.  UndefinedBehaviorSanitizer
doesn't like that and reports:

object-file.c:2477:18: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'

Make sure to use an unsigned 1 instead to avoid the issue.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agol10n: pt_PT: cleaning flags mismatch
Daniel Santos [Wed, 11 Aug 2021 04:07:01 +0000 (05:07 +0100)] 
l10n: pt_PT: cleaning flags mismatch

 * corrected git flags mismatch

Signed-off-by: Daniel Santos <hello@brighterdan.com>
2 years agol10n: pt_PT: cleaning duplicate translations
Daniel Santos [Mon, 9 Aug 2021 07:33:41 +0000 (08:33 +0100)] 
l10n: pt_PT: cleaning duplicate translations

 * cleaning duplicate incorrect translations part 1

Signed-off-by: Daniel Santos <hello@brighterdan.com>
2 years agol10n: pt_PT: update translation tables
Daniel Santos [Fri, 6 Aug 2021 14:20:28 +0000 (15:20 +0100)] 
l10n: pt_PT: update translation tables

 * update translation tables

Signed-off-by: Daniel Santos <hello@brighterdan.com>
2 years agol10n: pt_PT: translated git v2.33.0
Daniel Santos [Tue, 3 Aug 2021 13:50:58 +0000 (14:50 +0100)] 
l10n: pt_PT: translated git v2.33.0

 * translated new entries of git v2.33.0

Signed-off-by: Daniel Santos <hello@brighterdan.com>
2 years agoRevert 'diff-merges: let "-m" imply "-p"'
Jonathan Nieder [Fri, 6 Aug 2021 01:45:23 +0000 (18:45 -0700)] 
Revert 'diff-merges: let "-m" imply "-p"'

This reverts commit f5bfcc823ba242a46e20fb6f71c9fbf7ebb222fe, which
made "git log -m" imply "--patch" by default.  The logic was that
"-m", which makes diff generation for merges perform a diff against
each parent, has no use unless I am viewing the diff, so we could save
the user some typing by turning on display of the resulting diff
automatically.  That wasn't expected to adversely affect scripts
because scripts would either be using a command like "git diff-tree"
that already emits diffs by default or would be combining -m with a
diff generation option such as --name-status.  By saving typing for
interactive use without adversely affecting scripts in the wild, it
would be a pure improvement.

The problem is that although diff generation options are only relevant
for the displayed diff, a script author can imagine them affecting
path limiting.  For example, I might run

git log -w --format=%H -- README

hoping to list commits that edited README, excluding whitespace-only
changes.  In fact, a whitespace-only change is not TREESAME so the use
of -w here has no effect (since we don't apply these diff generation
flags to the diff_options struct rev_info::pruning used for this
purpose), but the documentation suggests that it should work

Suppose you specified foo as the <paths>. We shall call
commits that modify foo !TREESAME, and the rest TREESAME. (In
a diff filtered for foo, they look different and equal,
respectively.)

and a script author who has not tested whitespace-only changes
wouldn't notice.

Similarly, a script author could include

git log -m --first-parent --format=%H -- README

to filter the first-parent history for commits that modified README.
The -m is a no-op but it reflects the script author's intent.  For
example, until 1e20a407fe2 (stash list: stop passing "-m" to "git
log", 2021-05-21), "git stash list" did this.

As a result, we can't safely change "-m" to imply "-p" without fear of
breaking such scripts.  Restore the previous behavior.

Noticed because Rust's src/bootstrap/bootstrap.py made use of this
same construct: https://github.com/rust-lang/rust/pull/87513.  That
script has been updated to omit the unnecessary "-m" option, but we
can expect other scripts in the wild to have similar expectations.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agol10n: sv.po: Update Swedish translation (5227t0f0u)
Peter Krefting [Mon, 9 Aug 2021 19:38:56 +0000 (20:38 +0100)] 
l10n: sv.po: Update Swedish translation (5227t0f0u)

Signed-off-by: Peter Krefting <peter@softwolves.pp.se>
2 years agoobject-store: avoid extra ';' from KHASH_INIT
Carlo Marcelo Arenas Belón [Mon, 9 Aug 2021 01:38:32 +0000 (18:38 -0700)] 
object-store: avoid extra ';' from KHASH_INIT

cf2dc1c238 (speed up alt_odb_usable() with many alternates, 2021-07-07)
introduces a KHASH_INIT invocation with a trailing ';', which while
commonly expected will trigger warnings with pedantic on both
clang[-Wextra-semi] and gcc[-Wpedantic], because that macro has already
a semicolon and is meant to be invoked without one.

while fixing the macro would be a worthy solution (specially considering
this is a common recurring problem), remove the extra ';' for now to
minimize churn.

Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agooidtree: avoid nested struct oidtree_node
Carlo Marcelo Arenas Belón [Mon, 9 Aug 2021 01:38:31 +0000 (18:38 -0700)] 
oidtree: avoid nested struct oidtree_node

92d8ed8ac1 (oidtree: a crit-bit tree for odb_loose_cache, 2021-07-07)
adds a struct oidtree_node that contains only an n field with a
struct cb_node.

unfortunately, while building in pedantic mode witch clang 12 (as well
as a similar error from gcc 11) it will show:

  oidtree.c:11:17: error: 'n' may not be nested in a struct due to flexible array member [-Werror,-Wflexible-array-extensions]
          struct cb_node n;
                         ^

because of a constrain coded in ISO C 11 6.7.2.1¶3 that forbids using
structs that contain a flexible array as part of another struct.

use a strict cb_node directly instead.

Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agol10n: vi.po(5227t): Updated Vietnamese translation for v2.32.0
Tran Ngoc Quan [Mon, 9 Aug 2021 00:58:57 +0000 (07:58 +0700)] 
l10n: vi.po(5227t): Updated Vietnamese translation for v2.32.0

Signed-off-by: Tran Ngoc Quan <vnwildman@gmail.com>
2 years agoGit 2.33-rc1 v2.33.0-rc1
Junio C Hamano [Fri, 6 Aug 2021 19:53:06 +0000 (12:53 -0700)] 
Git 2.33-rc1

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoMerge branch 'cb/t7508-regexp-fix'
Junio C Hamano [Fri, 6 Aug 2021 19:52:22 +0000 (12:52 -0700)] 
Merge branch 'cb/t7508-regexp-fix'

* cb/t7508-regexp-fix:
  t7508: avoid non POSIX BRE

2 years agoMerge branch 'ab/pickaxe-pcre2'
Junio C Hamano [Fri, 6 Aug 2021 19:52:15 +0000 (12:52 -0700)] 
Merge branch 'ab/pickaxe-pcre2'

* ab/pickaxe-pcre2:
  diff: --pickaxe-all typofix

2 years agoMerge branch 'fc/disable-checkwinsize'
Junio C Hamano [Fri, 6 Aug 2021 19:50:26 +0000 (12:50 -0700)] 
Merge branch 'fc/disable-checkwinsize'

* fc/disable-checkwinsize:
  test: fix for COLUMNS and bash 5

2 years agotest: fix for COLUMNS and bash 5
Felipe Contreras [Thu, 5 Aug 2021 19:48:25 +0000 (14:48 -0500)] 
test: fix for COLUMNS and bash 5

Since c49a177bec (test-lib.sh: set COLUMNS=80 for --verbose
repeatability, 2021-06-29) multiple tests have been failing when using
bash 5 because checkwinsize is enabled by default, therefore COLUMNS is
reset using TIOCGWINSZ even for non-interactive shells.

It's debatable whether or not bash should even be doing that, but for
now we can avoid this undesirable behavior by disabling this option.

Reported-by: Fabian Stelzer <fabian.stelzer@campoint.net>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
[jc: with SZEDER Gábor's suggestion to do this before setting COLUMNS]
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agol10n: bg.po: Updated Bulgarian translation (5227t)
Alexander Shopov [Fri, 6 Aug 2021 09:57:40 +0000 (12:57 +0300)] 
l10n: bg.po: Updated Bulgarian translation (5227t)

Signed-off-by: Alexander Shopov <ash@kambanaria.org>
2 years agoMerge branch 'po-id' of github.com:bagasme/git-po
Jiang Xin [Fri, 6 Aug 2021 00:00:45 +0000 (08:00 +0800)] 
Merge branch 'po-id' of github.com:bagasme/git-po

* 'po-id' of github.com:bagasme/git-po:
  l10n: id: po-id for 2.33.0 (round 1)

2 years agol10n: pt_PT: update git-po-helper
Daniel Santos [Tue, 3 Aug 2021 12:30:05 +0000 (13:30 +0100)] 
l10n: pt_PT: update git-po-helper

Signed-off-by: Daniel Santos <hello@brighterdan.com>
2 years agol10n: pt_PT: remove trailing comments
Daniel Santos [Mon, 2 Aug 2021 13:41:11 +0000 (14:41 +0100)] 
l10n: pt_PT: remove trailing comments

 * removed all unecessary trailing file comments

Signed-off-by: Daniel Santos <hello@brighterdan.com>
2 years agol10n: pt_PT: translation tables
Daniel Santos [Sat, 24 Jul 2021 12:46:59 +0000 (13:46 +0100)] 
l10n: pt_PT: translation tables

 * filled translation table
 * add other translation table helper

Signed-off-by: Daniel Santos <hello@brighterdan.com>
2 years agol10n: id: po-id for 2.33.0 (round 1)
Bagas Sanjaya [Wed, 4 Aug 2021 10:24:39 +0000 (17:24 +0700)] 
l10n: id: po-id for 2.33.0 (round 1)

Translate following new components:
  * builtin/show-branch.c
  * builtin/show-index.c
  * builtin/show-ref.c
  * builtin/shortlog.c
  * builtin/describe.c
  * bisect.c
  * builtin/bisect--helper.c
  * blame.c
  * builtin/blame.c
  * grep.c
  * builtin/grep.c
  * builtin/diff-tree.c
  * builtin/diff.c
  * help.c

Update translation for following components:
  * diff.c
  * builtin/clone.c
  * builtin/fetch.c

Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>
2 years agoMerge branch 'tr-loc-v2.33' of github.com:bitigchi/git-po
Jiang Xin [Thu, 5 Aug 2021 04:56:29 +0000 (12:56 +0800)] 
Merge branch 'tr-loc-v2.33' of github.com:bitigchi/git-po

* 'tr-loc-v2.33' of github.com:bitigchi/git-po:
  l10n: tr: v2.33.0 round 1

2 years agol10n: tr: v2.33.0 round 1
Emir Sarı [Tue, 3 Aug 2021 11:13:08 +0000 (14:13 +0300)] 
l10n: tr: v2.33.0 round 1

Signed-off-by: Emir Sarı <bitigchi@me.com>
2 years agoMerge branch 'fr_v2.33_rnd1' of github.com:jnavila/git
Jiang Xin [Thu, 5 Aug 2021 00:36:31 +0000 (08:36 +0800)] 
Merge branch 'fr_v2.33_rnd1' of github.com:jnavila/git

* 'fr_v2.33_rnd1' of github.com:jnavila/git:
  l10n: fr.po v2.33 rnd 1
  l10n: fr: fix typo