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

Function list

builtin/hook.c:27–118  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25};
26
27static int list(int argc, const char **argv, const char *prefix,
28 struct repository *repo)
29{
30 static const char *const builtin_hook_list_usage[] = {
31 BUILTIN_HOOK_LIST_USAGE,
32 NULL
33 };
34 struct string_list *head;
35 struct string_list_item *item;
36 const char *hookname = NULL;
37 int line_terminator = '\n';
38 int show_scope = 0;
39 int allow_unknown = 0;
40 int ret = 0;
41
42 struct option list_options[] = {
43 OPT_SET_INT('z', NULL, &line_terminator,
44 N_("use NUL as line terminator"), '\0'),
45 OPT_BOOL(0, "show-scope", &show_scope,
46 N_("show the config scope that defined each hook")),
47 OPT_BOOL(0, "allow-unknown-hook-name", &allow_unknown,
48 N_("allow running a hook with a non-native hook name")),
49 OPT_END(),
50 };
51
52 argc = parse_options(argc, argv, prefix, list_options,
53 builtin_hook_list_usage, 0);
54
55 /*
56 * The only unnamed argument provided should be the hook-name; if we add
57 * arguments later they probably should be caught by parse_options.
58 */
59 if (argc != 1)
60 usage_msg_opt(_("you must specify a hook event name to list"),
61 builtin_hook_list_usage, list_options);
62
63 hookname = argv[0];
64
65 if (!allow_unknown && !is_known_hook(hookname)) {
66 error(_("unknown hook event '%s';\n"
67 "use --allow-unknown-hook-name to allow non-native hook names"),
68 hookname);
69 return 1;
70 }
71
72 head = list_hooks(repo, hookname, NULL);
73
74 if (!head->nr) {
75 warning(_("no hooks found for event '%s'"), hookname);
76 ret = 1; /* no hooks found */
77 goto cleanup;
78 }
79
80 for_each_string_list_item(item, head) {
81 struct hook *h = item->util;
82
83 switch (h->kind) {
84 case HOOK_TRADITIONAL:

Callers 4

p4_syncFunction · 0.50
p4_editFunction · 0.50
__init__Method · 0.50
applyCommitMethod · 0.50

Calls 8

parse_optionsFunction · 0.85
usage_msg_optFunction · 0.85
is_known_hookFunction · 0.85
errorFunction · 0.85
list_hooksFunction · 0.85
warningFunction · 0.85
config_scope_nameFunction · 0.85
string_list_clear_funcFunction · 0.85

Tested by

no test coverage detected