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 <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Taylor Blau committed Jan 25, 2021 at 18:37 UTC c97733435aae270bbef9bd4d179edca678774375
2 files changed +20
builtin/pack-objects.c
+7
@@ -2955,6 +2955,13 @@ static int git_pack_config(const char *k, const char *v, void *cb)
2955 pack_idx_opts.version);
2956 return 0;
2957 }
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 + }
2965 if (!strcmp(k, "uploadpack.blobpackfileuri")) {
2966 struct configured_exclusion *ex = xmalloc(sizeof(*ex));
2967 const char *oid_end, *pack_end;
t/t5325-reverse-index.sh
+13
@@ -68,4 +68,17 @@ test_expect_success 'index-pack infers reverse index name with -o' '
68 test_path_is_file other.rev
69 '
70
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 +
84 test_done