diff options
| author | Junio C Hamano <gitster@pobox.com> | 2025-10-02 12:26:12 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-10-02 12:26:12 -0700 |
| commit | db0babf9b2f807e6913b3591d04cb752b8219e9d (patch) | |
| tree | 0931f79efd3cccb0089aed434d99dee32fe7fda4 /builtin/refs.c | |
| parent | Merge branch 'jt/odb-transaction' (diff) | |
| parent | t: add test for git refs optimize subcommand (diff) | |
| download | git-db0babf9b2f807e6913b3591d04cb752b8219e9d.tar.gz git-db0babf9b2f807e6913b3591d04cb752b8219e9d.zip | |
Merge branch 'ms/refs-optimize'
"git refs optimize" is added for not very well explained reason
despite it does the same thing as "git pack-refs"...
* ms/refs-optimize:
t: add test for git refs optimize subcommand
t0601: refactor tests to be shareable
builtin/refs: add optimize subcommand
doc: pack-refs: factor out common options
builtin/pack-refs: factor out core logic into a shared library
builtin/pack-refs: convert to use the generic refs_optimize() API
reftable-backend: implement 'optimize' action
files-backend: implement 'optimize' action
refs: add a generic 'optimize' API
Diffstat (limited to 'builtin/refs.c')
| -rw-r--r-- | builtin/refs.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/builtin/refs.c b/builtin/refs.c index 91548783b7..3064f888b2 100644 --- a/builtin/refs.c +++ b/builtin/refs.c @@ -2,6 +2,7 @@ #include "builtin.h" #include "config.h" #include "fsck.h" +#include "pack-refs.h" #include "parse-options.h" #include "refs.h" #include "strbuf.h" @@ -18,6 +19,9 @@ #define REFS_EXISTS_USAGE \ N_("git refs exists <ref>") +#define REFS_OPTIMIZE_USAGE \ + N_("git refs optimize " PACK_REFS_OPTS) + static int cmd_refs_migrate(int argc, const char **argv, const char *prefix, struct repository *repo UNUSED) { @@ -159,6 +163,17 @@ out: return ret; } +static int cmd_refs_optimize(int argc, const char **argv, const char *prefix, + struct repository *repo) +{ + static char const * const refs_optimize_usage[] = { + REFS_OPTIMIZE_USAGE, + NULL + }; + + return pack_refs_core(argc, argv, prefix, repo, refs_optimize_usage); +} + int cmd_refs(int argc, const char **argv, const char *prefix, @@ -169,6 +184,7 @@ int cmd_refs(int argc, REFS_VERIFY_USAGE, "git refs list " COMMON_USAGE_FOR_EACH_REF, REFS_EXISTS_USAGE, + REFS_OPTIMIZE_USAGE, NULL, }; parse_opt_subcommand_fn *fn = NULL; @@ -177,6 +193,7 @@ int cmd_refs(int argc, OPT_SUBCOMMAND("verify", &fn, cmd_refs_verify), OPT_SUBCOMMAND("list", &fn, cmd_refs_list), OPT_SUBCOMMAND("exists", &fn, cmd_refs_exists), + OPT_SUBCOMMAND("optimize", &fn, cmd_refs_optimize), OPT_END(), }; |
