Re: [PATCH v4 11/15] bugreport: collect list of populated hooks
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Dec 13, 2019, 21:47 UTC
- Message-ID
- <xmqqzhfvhp8w.fsf@gitster-ct.c.googlers.com>
- In-Reply-To
- <20191213004312.169753-12-emilyshaffer@google.com>
Emily Shaffer <emilyshaffer@google.com> writes:
> + /* > + * Doesn't look like there is a list of all possible hooks; so below is > + * a transcription of `git help hook`. > + */
We probably would want to employ technique similar to what you used for the list of safe configuration we saw in an earlier patch in the series. What's not even documented is not worth reporting ;-)
Show 58 quoted lines
> + const char *hooks = "applypatch-msg,"
> + "pre-applypatch,"
> + "post-applypatch,"
> + "pre-commit,"
> + "pre-merge-commit,"
> + "prepare-commit-msg,"
> + "commit-msg,"
> + "post-commit,"
> + "pre-rebase,"
> + "post-checkout,"
> + "post-merge,"
> + "pre-push,"
> + "pre-receive,"
> + "update,"
> + "post-receive,"
> + "post-update,"
> + "push-to-checkout,"
> + "pre-auto-gc,"
> + "post-rewrite,"
> + "sendemail-validate,"
> + "fsmonitor-watchman,"
> + "p4-pre-submit,"
> + "post-index-changex";
> + struct string_list hooks_list = STRING_LIST_INIT_DUP;
> + struct string_list_item *iter = NULL;
> + int nongit_ok;
> +
> + setup_git_directory_gently(&nongit_ok);
> +
> + if (nongit_ok) {
> + strbuf_addstr(hook_info,
> + "not run from a git repository - no hooks to show\n");
> + return;
> + }
> +
> + string_list_split(&hooks_list, hooks, ',', -1);
> +
> + for_each_string_list_item(iter, &hooks_list) {
> + if (find_hook(iter->string)) {
> + strbuf_addstr(hook_info, iter->string);
> + strbuf_complete_line(hook_info);
> + }
> + }
> +}
> +
> static const char * const bugreport_usage[] = {
> N_("git bugreport [-o|--output <file>]"),
> NULL
> @@ -188,6 +240,9 @@ int cmd_main(int argc, const char **argv)
> get_header(&buffer, "Safelisted Config Info");
> get_safelisted_config(&buffer);
>
> + get_header(&buffer, "Configured Hooks");
> + get_populated_hooks(&buffer);
> +
> report = fopen_for_writing(report_path.buf);
> strbuf_write(&buffer, report);
> fclose(report);