|
1 | 1 | #include "builtin.h" |
2 | | -#include "config.h" |
3 | | -#include "environment.h" |
4 | 2 | #include "gettext.h" |
5 | | -#include "parse-options.h" |
6 | | -#include "refs.h" |
7 | | -#include "revision.h" |
8 | | - |
9 | | -static char const * const pack_refs_usage[] = { |
10 | | - N_("git pack-refs [--all] [--no-prune] [--auto] [--include <pattern>] [--exclude <pattern>]"), |
11 | | - NULL |
12 | | -}; |
| 3 | +#include "pack-refs.h" |
13 | 4 |
|
14 | 5 | int cmd_pack_refs(int argc, |
15 | 6 | const char **argv, |
16 | 7 | const char *prefix, |
17 | 8 | struct repository *repo) |
18 | 9 | { |
19 | | - struct ref_exclusions excludes = REF_EXCLUSIONS_INIT; |
20 | | - struct string_list included_refs = STRING_LIST_INIT_NODUP; |
21 | | - struct pack_refs_opts pack_refs_opts = { |
22 | | - .exclusions = &excludes, |
23 | | - .includes = &included_refs, |
24 | | - .flags = PACK_REFS_PRUNE, |
25 | | - }; |
26 | | - struct string_list option_excluded_refs = STRING_LIST_INIT_NODUP; |
27 | | - struct string_list_item *item; |
28 | | - int pack_all = 0; |
29 | | - int ret; |
30 | | - |
31 | | - struct option opts[] = { |
32 | | - OPT_BOOL(0, "all", &pack_all, N_("pack everything")), |
33 | | - OPT_BIT(0, "prune", &pack_refs_opts.flags, N_("prune loose refs (default)"), PACK_REFS_PRUNE), |
34 | | - OPT_BIT(0, "auto", &pack_refs_opts.flags, N_("auto-pack refs as needed"), PACK_REFS_AUTO), |
35 | | - OPT_STRING_LIST(0, "include", pack_refs_opts.includes, N_("pattern"), |
36 | | - N_("references to include")), |
37 | | - OPT_STRING_LIST(0, "exclude", &option_excluded_refs, N_("pattern"), |
38 | | - N_("references to exclude")), |
39 | | - OPT_END(), |
| 10 | + static char const * const pack_refs_usage[] = { |
| 11 | + N_("git pack-refs " PACK_REFS_OPTS), |
| 12 | + NULL |
40 | 13 | }; |
41 | | - repo_config(repo, git_default_config, NULL); |
42 | | - if (parse_options(argc, argv, prefix, opts, pack_refs_usage, 0)) |
43 | | - usage_with_options(pack_refs_usage, opts); |
44 | | - |
45 | | - for_each_string_list_item(item, &option_excluded_refs) |
46 | | - add_ref_exclusion(pack_refs_opts.exclusions, item->string); |
47 | | - |
48 | | - if (pack_all) |
49 | | - string_list_append(pack_refs_opts.includes, "*"); |
50 | | - |
51 | | - if (!pack_refs_opts.includes->nr) |
52 | | - string_list_append(pack_refs_opts.includes, "refs/tags/*"); |
53 | | - |
54 | | - ret = refs_pack_refs(get_main_ref_store(repo), &pack_refs_opts); |
55 | 14 |
|
56 | | - clear_ref_exclusions(&excludes); |
57 | | - string_list_clear(&included_refs, 0); |
58 | | - string_list_clear(&option_excluded_refs, 0); |
59 | | - return ret; |
| 15 | + return pack_refs_core(argc, argv, prefix, repo, pack_refs_usage); |
60 | 16 | } |
0 commit comments