Skip to content

Commit c977334

Browse files
ttaylorrgitster
authored andcommitted
builtin/pack-objects.c: respect 'pack.writeReverseIndex'
Now that we have an implementation that can write the new reverse index format, enable writing a .rev file in 'git pack-objects' by consulting the pack.writeReverseIndex configuration variable. Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e37d0b8 commit c977334

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

builtin/pack-objects.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2955,6 +2955,13 @@ static int git_pack_config(const char *k, const char *v, void *cb)
29552955
pack_idx_opts.version);
29562956
return 0;
29572957
}
2958+
if (!strcmp(k, "pack.writereverseindex")) {
2959+
if (git_config_bool(k, v))
2960+
pack_idx_opts.flags |= WRITE_REV;
2961+
else
2962+
pack_idx_opts.flags &= ~WRITE_REV;
2963+
return 0;
2964+
}
29582965
if (!strcmp(k, "uploadpack.blobpackfileuri")) {
29592966
struct configured_exclusion *ex = xmalloc(sizeof(*ex));
29602967
const char *oid_end, *pack_end;

t/t5325-reverse-index.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,17 @@ test_expect_success 'index-pack infers reverse index name with -o' '
6868
test_path_is_file other.rev
6969
'
7070

71+
test_expect_success 'pack-objects respects pack.writeReverseIndex' '
72+
test_when_finished "rm -fr pack-1-*" &&
73+
74+
git -c pack.writeReverseIndex= pack-objects --all pack-1 &&
75+
test_path_is_missing pack-1-*.rev &&
76+
77+
git -c pack.writeReverseIndex=false pack-objects --all pack-1 &&
78+
test_path_is_missing pack-1-*.rev &&
79+
80+
git -c pack.writeReverseIndex=true pack-objects --all pack-1 &&
81+
test_path_is_file pack-1-*.rev
82+
'
83+
7184
test_done

0 commit comments

Comments
 (0)