Skip to content

Commit 1b296b0

Browse files
committed
Merge branch 'jk/midx-write-v1-by-default' into next
As writing version 2 MIDX files by default breaks older versions of Git and its reimplementations, use V2 only when necessary. * jk/midx-write-v1-by-default: MIDX: revert the default version to v1
2 parents 4f5dca5 + a12382f commit 1b296b0

3 files changed

Lines changed: 7 additions & 2 deletions

File tree

Documentation/git-multi-pack-index.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ compact::
9898
--[no-]bitmap::
9999
Control whether or not a multi-pack bitmap is written.
100100
--
101+
+
102+
Note that the compact command requires writing a version-2 midx that
103+
cannot be read by versions of Git prior to v2.54.
101104

102105
verify::
103106
Verify the contents of the MIDX file.

midx-write.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1259,7 +1259,6 @@ static int write_midx_internal(struct write_midx_opts *opts)
12591259
struct tempfile *incr;
12601260
struct write_midx_context ctx = {
12611261
.preferred_pack_idx = NO_PREFERRED_PACK,
1262-
.version = MIDX_VERSION_V2,
12631262
};
12641263
struct multi_pack_index *midx_to_free = NULL;
12651264
int bitmapped_packs_concat_len = 0;
@@ -1275,6 +1274,9 @@ static int write_midx_internal(struct write_midx_opts *opts)
12751274
ctx.repo = r;
12761275
ctx.source = opts->source;
12771276

1277+
ctx.version = ((opts->flags & MIDX_WRITE_COMPACT)
1278+
? MIDX_VERSION_V2
1279+
: MIDX_VERSION_V1);
12781280
repo_config_get_int(ctx.repo, "midx.version", &ctx.version);
12791281
if (ctx.version != MIDX_VERSION_V1 && ctx.version != MIDX_VERSION_V2)
12801282
die(_("unknown MIDX version: %d"), ctx.version);

t/t5319-multi-pack-index.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ midx_read_expect () {
2121
EXTRA_CHUNKS="$5"
2222
{
2323
cat <<-EOF &&
24-
header: 4d494458 2 $HASH_LEN $NUM_CHUNKS $NUM_PACKS
24+
header: 4d494458 1 $HASH_LEN $NUM_CHUNKS $NUM_PACKS
2525
chunks: pack-names oid-fanout oid-lookup object-offsets$EXTRA_CHUNKS
2626
num_objects: $NUM_OBJECTS
2727
packs:

0 commit comments

Comments
 (0)