]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t/helper: drop pack-refs wrapper
authorPatrick Steinhardt <ps@pks.im>
Mon, 25 Mar 2024 10:02:59 +0000 (11:02 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 25 Mar 2024 16:54:07 +0000 (09:54 -0700)
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>
t/helper/test-ref-store.c
t/t0601-reffiles-pack-refs.sh

index 7a0f6cac53d2433ade595ce95ab2d30e214b2ede..82bbf6e2e68b9b57b8c2d159439631aa36a16d20 100644 (file)
@@ -112,25 +112,6 @@ static const char **get_store(const char **argv, struct ref_store **refs)
        return argv + 1;
 }
 
-static struct flag_definition pack_flags[] = { FLAG_DEF(PACK_REFS_PRUNE),
-                                              FLAG_DEF(PACK_REFS_ALL),
-                                              { NULL, 0 } };
-
-static int cmd_pack_refs(struct ref_store *refs, const char **argv)
-{
-       unsigned int flags = arg_flags(*argv++, "flags", pack_flags);
-       static struct ref_exclusions exclusions = REF_EXCLUSIONS_INIT;
-       static struct string_list included_refs = STRING_LIST_INIT_NODUP;
-       struct pack_refs_opts pack_opts = { .flags = flags,
-                                           .exclusions = &exclusions,
-                                           .includes = &included_refs };
-
-       if (pack_opts.flags & PACK_REFS_ALL)
-               string_list_append(pack_opts.includes, "*");
-
-       return refs_pack_refs(refs, &pack_opts);
-}
-
 static int cmd_create_symref(struct ref_store *refs, const char **argv)
 {
        const char *refname = notnull(*argv++, "refname");
@@ -326,7 +307,6 @@ struct command {
 };
 
 static struct command commands[] = {
-       { "pack-refs", cmd_pack_refs },
        { "create-symref", cmd_create_symref },
        { "delete-refs", cmd_delete_refs },
        { "rename-ref", cmd_rename_ref },
index c309d2bae8a19816907b81d82cef9099b2fa21e9..b1cf5873471ce4166e9400242fa95e0a104e9e92 100755 (executable)
@@ -32,11 +32,16 @@ test_expect_success 'prepare a trivial repository' '
        HEAD=$(git rev-parse --verify HEAD)
 '
 
-test_expect_success 'pack_refs(PACK_REFS_ALL | PACK_REFS_PRUNE)' '
-       N=`find .git/refs -type f | wc -l` &&
+test_expect_success 'pack-refs --prune --all' '
+       test_path_is_missing .git/packed-refs &&
+       git pack-refs --no-prune --all &&
+       test_path_is_file .git/packed-refs &&
+       N=$(find .git/refs -type f | wc -l) &&
        test "$N" != 0 &&
-       test-tool ref-store main pack-refs PACK_REFS_PRUNE,PACK_REFS_ALL &&
-       N=`find .git/refs -type f` &&
+
+       git pack-refs --prune --all &&
+       test_path_is_file .git/packed-refs &&
+       N=$(find .git/refs -type f) &&
        test -z "$N"
 '