|
3 | 3 | #include "strbuf.h"
|
4 | 4 | #include "help.h"
|
5 | 5 | #include "compat/compiler.h"
|
| 6 | +#include "run-command.h" |
| 7 | + |
6 | 8 |
|
7 | 9 | static void get_system_info(struct strbuf *sys_info)
|
8 | 10 | {
|
@@ -31,6 +33,53 @@ static void get_system_info(struct strbuf *sys_info)
|
31 | 33 | get_libc_info(sys_info);
|
32 | 34 | }
|
33 | 35 |
|
| 36 | +static void get_populated_hooks(struct strbuf *hook_info, int nongit) |
| 37 | +{ |
| 38 | + /* |
| 39 | + * NEEDSWORK: Doesn't look like there is a list of all possible hooks; |
| 40 | + * so below is a transcription of `git help hooks`. Later, this should |
| 41 | + * be replaced with some programmatically generated list (generated from |
| 42 | + * doc or else taken from some library which tells us about all the |
| 43 | + * hooks) |
| 44 | + */ |
| 45 | + static const char *hook[] = { |
| 46 | + "applypatch-msg", |
| 47 | + "pre-applypatch", |
| 48 | + "post-applypatch", |
| 49 | + "pre-commit", |
| 50 | + "pre-merge-commit", |
| 51 | + "prepare-commit-msg", |
| 52 | + "commit-msg", |
| 53 | + "post-commit", |
| 54 | + "pre-rebase", |
| 55 | + "post-checkout", |
| 56 | + "post-merge", |
| 57 | + "pre-push", |
| 58 | + "pre-receive", |
| 59 | + "update", |
| 60 | + "post-receive", |
| 61 | + "post-update", |
| 62 | + "push-to-checkout", |
| 63 | + "pre-auto-gc", |
| 64 | + "post-rewrite", |
| 65 | + "sendemail-validate", |
| 66 | + "fsmonitor-watchman", |
| 67 | + "p4-pre-submit", |
| 68 | + "post-index-change", |
| 69 | + }; |
| 70 | + int i; |
| 71 | + |
| 72 | + if (nongit) { |
| 73 | + strbuf_addstr(hook_info, |
| 74 | + _("not run from a git repository - no hooks to show\n")); |
| 75 | + return; |
| 76 | + } |
| 77 | + |
| 78 | + for (i = 0; i < ARRAY_SIZE(hook); i++) |
| 79 | + if (find_hook(hook[i])) |
| 80 | + strbuf_addf(hook_info, "%s\n", hook[i]); |
| 81 | +} |
| 82 | + |
34 | 83 | static const char * const bugreport_usage[] = {
|
35 | 84 | N_("git bugreport [-o|--output-directory <file>] [-s|--suffix <format>]"),
|
36 | 85 | NULL
|
@@ -114,6 +163,9 @@ int cmd_main(int argc, const char **argv)
|
114 | 163 | get_header(&buffer, _("System Info"));
|
115 | 164 | get_system_info(&buffer);
|
116 | 165 |
|
| 166 | + get_header(&buffer, _("Enabled Hooks")); |
| 167 | + get_populated_hooks(&buffer, nongit_ok); |
| 168 | + |
117 | 169 | /* fopen doesn't offer us an O_EXCL alternative, except with glibc. */
|
118 | 170 | report = open(report_path.buf, O_CREAT | O_EXCL | O_WRONLY, 0666);
|
119 | 171 |
|
|
0 commit comments