Helper to detect and add default "traditional" hooks from the hookdir. */
| 85 | |
| 86 | /* Helper to detect and add default "traditional" hooks from the hookdir. */ |
| 87 | static void list_hooks_add_default(struct repository *r, const char *hookname, |
| 88 | struct string_list *hook_list, |
| 89 | struct run_hooks_opt *options) |
| 90 | { |
| 91 | const char *hook_path = find_hook(r, hookname); |
| 92 | struct hook *h; |
| 93 | |
| 94 | if (!hook_path) |
| 95 | return; |
| 96 | |
| 97 | CALLOC_ARRAY(h, 1); |
| 98 | |
| 99 | /* |
| 100 | * If the hook is to run in a specific dir, a relative path can |
| 101 | * become invalid in that dir, so convert to an absolute path. |
| 102 | */ |
| 103 | if (options && options->dir) |
| 104 | hook_path = absolute_path(hook_path); |
| 105 | |
| 106 | /* |
| 107 | * Setup per-hook internal state callback data. |
| 108 | * When provided, the alloc/free callbacks are always provided |
| 109 | * together, so use them to alloc/free the internal hook state. |
| 110 | */ |
| 111 | if (options && options->feed_pipe_cb_data_alloc) { |
| 112 | h->feed_pipe_cb_data = options->feed_pipe_cb_data_alloc(options->feed_pipe_ctx); |
| 113 | h->data_free = options->feed_pipe_cb_data_free; |
| 114 | } |
| 115 | |
| 116 | h->kind = HOOK_TRADITIONAL; |
| 117 | h->u.traditional.path = xstrdup(hook_path); |
| 118 | |
| 119 | string_list_append(hook_list, hook_path)->util = h; |
| 120 | } |
| 121 | |
| 122 | /* |
| 123 | * Cache entry stored as the .util pointer of string_list items inside the |
no test coverage detected