MCPcopy Create free account
hub / github.com/git/git / pack_refs_core

Function pack_refs_core

pack-refs.c:9–56  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7#include "revision.h"
8
9int pack_refs_core(int argc,
10 const char **argv,
11 const char *prefix,
12 struct repository *repo,
13 const char * const *usage_opts)
14{
15 struct ref_exclusions excludes = REF_EXCLUSIONS_INIT;
16 struct string_list included_refs = STRING_LIST_INIT_NODUP;
17 struct refs_optimize_opts optimize_opts = {
18 .exclusions = &excludes,
19 .includes = &included_refs,
20 .flags = REFS_OPTIMIZE_PRUNE,
21 };
22 struct string_list option_excluded_refs = STRING_LIST_INIT_NODUP;
23 struct string_list_item *item;
24 int pack_all = 0;
25 int ret;
26
27 struct option opts[] = {
28 OPT_BOOL(0, "all", &pack_all, N_("pack everything")),
29 OPT_BIT(0, "prune", &optimize_opts.flags, N_("prune loose refs (default)"), REFS_OPTIMIZE_PRUNE),
30 OPT_BIT(0, "auto", &optimize_opts.flags, N_("auto-pack refs as needed"), REFS_OPTIMIZE_AUTO),
31 OPT_STRING_LIST(0, "include", optimize_opts.includes, N_("pattern"),
32 N_("references to include")),
33 OPT_STRING_LIST(0, "exclude", &option_excluded_refs, N_("pattern"),
34 N_("references to exclude")),
35 OPT_END(),
36 };
37 repo_config(repo, git_default_config, NULL);
38 if (parse_options(argc, argv, prefix, opts, usage_opts, 0))
39 usage_with_options(usage_opts, opts);
40
41 for_each_string_list_item(item, &option_excluded_refs)
42 add_ref_exclusion(optimize_opts.exclusions, item->string);
43
44 if (pack_all)
45 string_list_append(optimize_opts.includes, "*");
46
47 if (!optimize_opts.includes->nr)
48 string_list_append(optimize_opts.includes, "refs/tags/*");
49
50 ret = refs_optimize(get_main_ref_store(repo), &optimize_opts);
51
52 clear_ref_exclusions(&excludes);
53 string_list_clear(&included_refs, 0);
54 string_list_clear(&option_excluded_refs, 0);
55 return ret;
56}

Callers 2

cmd_pack_refsFunction · 0.85
cmd_refs_optimizeFunction · 0.85

Calls 9

parse_optionsFunction · 0.85
usage_with_optionsFunction · 0.85
add_ref_exclusionFunction · 0.85
refs_optimizeFunction · 0.85
get_main_ref_storeFunction · 0.85
clear_ref_exclusionsFunction · 0.85
string_list_clearFunction · 0.85
repo_configFunction · 0.70
string_list_appendFunction · 0.70

Tested by

no test coverage detected