Skip to content

Commit 549ca8a

Browse files
committed
Merge branch 'jk/index-pack-maint'
"index-pack --strict" has been taught to make sure that it runs the final object integrity checks after making the freshly indexed packfile available to itself. * jk/index-pack-maint: index-pack: correct install_packed_git() args index-pack: handle --strict checks of non-repo packs prepare_commit_graft: treat non-repository as a noop
2 parents 4d605b0 + 3737746 commit 549ca8a

File tree

4 files changed

+25
-2
lines changed

4 files changed

+25
-2
lines changed

builtin/index-pack.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,8 +1482,12 @@ static void final(const char *final_pack_name, const char *curr_pack_name,
14821482
} else
14831483
chmod(final_index_name, 0444);
14841484

1485-
if (do_fsck_object)
1486-
add_packed_git(final_index_name, strlen(final_index_name), 0);
1485+
if (do_fsck_object) {
1486+
struct packed_git *p;
1487+
p = add_packed_git(final_index_name, strlen(final_index_name), 0);
1488+
if (p)
1489+
install_packed_git(the_repository, p);
1490+
}
14871491

14881492
if (!from_stdin) {
14891493
printf("%s\n", sha1_to_hex(hash));

commit.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,9 @@ static void prepare_commit_graft(void)
207207

208208
if (commit_graft_prepared)
209209
return;
210+
if (!startup_info->have_repository)
211+
return;
212+
210213
graft_file = get_graft_file();
211214
read_graft_file(graft_file);
212215
/* make sure shallows are read */

t/t5300-pack-object.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,12 @@ test_expect_success 'index-pack <pack> works in non-repo' '
421421
test_path_is_file foo.idx
422422
'
423423

424+
test_expect_success 'index-pack --strict <pack> works in non-repo' '
425+
rm -f foo.idx &&
426+
nongit git index-pack --strict ../foo.pack &&
427+
test_path_is_file foo.idx
428+
'
429+
424430
test_expect_success !PTHREADS,C_LOCALE_OUTPUT 'index-pack --threads=N or pack.threads=N warns when no pthreads' '
425431
test_must_fail git index-pack --threads=2 2>err &&
426432
grep ^warning: err >warnings &&

t/t7415-submodule-names.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,16 @@ test_expect_success 'transfer.fsckObjects handles odd pack (index)' '
122122
test_must_fail git -C dst.git index-pack --strict --stdin <odd.pack
123123
'
124124

125+
test_expect_success 'index-pack --strict works for non-repo pack' '
126+
rm -rf dst.git &&
127+
git init --bare dst.git &&
128+
cp odd.pack dst.git &&
129+
test_must_fail git -C dst.git index-pack --strict odd.pack 2>output &&
130+
# Make sure we fail due to bad gitmodules content, not because we
131+
# could not read the blob in the first place.
132+
grep gitmodulesName output
133+
'
134+
125135
test_expect_success 'fsck detects symlinked .gitmodules file' '
126136
git init symlink &&
127137
(

0 commit comments

Comments
 (0)