t/helper: drop pack-refs wrapper

The test helper provides a "ref-store <store> pack-refs" wrapper that more or less directly invokes `refs_pack_refs()`. This helper is only used in a single test with the "PACK_REFS_PRUNE" and "PACK_REFS_ALL" flags. Both of these flags can directly be accessed via git-pack-refs(1) though via the `--all` and `--prune` flags, which makes the helper superfluous. Refactor the test to use git-pack-refs(1) instead of the test helper. Drop the now-unused test helper command. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Mar 25, 2024 at 11:02 UTC ed12124d4a809c832ae7f963ecc71104ba5cd55b
2 files changed +9 -24
t/helper/test-ref-store.c
-20
@@ -112,25 +112,6 @@ static const char **get_store(const char **argv, struct ref_store **refs)
112 return argv + 1;
113 }
114
115 -static struct flag_definition pack_flags[] = { FLAG_DEF(PACK_REFS_PRUNE),
116 - FLAG_DEF(PACK_REFS_ALL),
117 - { NULL, 0 } };
118 -
119 -static int cmd_pack_refs(struct ref_store *refs, const char **argv)
120 -{
121 - unsigned int flags = arg_flags(*argv++, "flags", pack_flags);
122 - static struct ref_exclusions exclusions = REF_EXCLUSIONS_INIT;
123 - static struct string_list included_refs = STRING_LIST_INIT_NODUP;
124 - struct pack_refs_opts pack_opts = { .flags = flags,
125 - .exclusions = &exclusions,
126 - .includes = &included_refs };
127 -
128 - if (pack_opts.flags & PACK_REFS_ALL)
129 - string_list_append(pack_opts.includes, "*");
130 -
131 - return refs_pack_refs(refs, &pack_opts);
132 -}
133 -
115 static int cmd_create_symref(struct ref_store *refs, const char **argv)
116 {
117 const char *refname = notnull(*argv++, "refname");
@@ -326,7 +307,6 @@ struct command {
307 };
308
309 static struct command commands[] = {
329 - { "pack-refs", cmd_pack_refs },
310 { "create-symref", cmd_create_symref },
311 { "delete-refs", cmd_delete_refs },
312 { "rename-ref", cmd_rename_ref },
t/t0601-reffiles-pack-refs.sh
+9 -4
@@ -32,11 +32,16 @@ test_expect_success 'prepare a trivial repository' '
32 HEAD=$(git rev-parse --verify HEAD)
33 '
34
35 -test_expect_success 'pack_refs(PACK_REFS_ALL | PACK_REFS_PRUNE)' '
36 - N=`find .git/refs -type f | wc -l` &&
35 +test_expect_success 'pack-refs --prune --all' '
36 + test_path_is_missing .git/packed-refs &&
37 + git pack-refs --no-prune --all &&
38 + test_path_is_file .git/packed-refs &&
39 + N=$(find .git/refs -type f | wc -l) &&
40 test "$N" != 0 &&
38 - test-tool ref-store main pack-refs PACK_REFS_PRUNE,PACK_REFS_ALL &&
39 - N=`find .git/refs -type f` &&
41 +
42 + git pack-refs --prune --all &&
43 + test_path_is_file .git/packed-refs &&
44 + N=$(find .git/refs -type f) &&
45 test -z "$N"
46 '
47