static int should_include_pack(const struct write_midx_context *ctx,
const char *file_name)
{
+ struct multi_pack_index *m = ctx->m;
/*
- * Note that at most one of ctx->m and ctx->to_include are set,
+ * When writing incrementally, ctx->m may contain layers above
+ * the selected base MIDX, which must be included in the new
+ * layer.
+ */
+ if (ctx->incremental)
+ m = ctx->base_midx;
+
+ /*
+ * Note that at most one of m and ctx->to_include are set,
* so we are testing midx_contains_pack() and
* string_list_has_string() independently (guarded by the
* appropriate NULL checks).
* should be performed independently (likely checking
* to_include before the existing MIDX).
*/
- if (ctx->m && midx_contains_pack(ctx->m, file_name))
- return 0;
- else if (ctx->base_midx && midx_contains_pack(ctx->base_midx,
- file_name))
+ if (m && midx_contains_pack(m, file_name))
return 0;
else if (ctx->to_include &&
!string_list_has_string(ctx->to_include, file_name))
test_grep "cannot use --base without --no-write-chain-file" err
'
-test_expect_failure 'write MIDX layer with --base=none and --no-write-chain-file' '
+test_expect_success 'write MIDX layer with --base=none and --no-write-chain-file' '
test_commit base-none &&
git repack -d &&
cp "$midx_chain.bak" "$midx_chain"
'
-test_expect_failure 'write MIDX layer with --base=<hash> and --no-write-chain-file' '
+test_expect_success 'write MIDX layer with --base=<hash> and --no-write-chain-file' '
test_commit base-hash &&
git repack -d &&