Re: [PATCH v8 10/15] bugreport: add config values from safelist
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Feb 20, 2020, 20:47 UTC
- Message-ID
- <xmqqimk19ear.fsf@gitster-ct.c.googlers.com>
- In-Reply-To
- <20200220015858.181086-11-emilyshaffer@google.com>
Emily Shaffer <emilyshaffer@google.com> writes:
Show 15 quoted lines
> @@ -94,6 +120,7 @@ int cmd_main(int argc, const char **argv)
> char *option_output = NULL;
> char *option_suffix = "%F-%H%M";
> struct stat statbuf;
> + int nongit_ok = 0;
>
> const struct option bugreport_options[] = {
> OPT_STRING('o', "output-directory", &option_output, N_("path"),
> @@ -102,6 +129,10 @@ int cmd_main(int argc, const char **argv)
> N_("specify a strftime format suffix for the filename")),
> OPT_END()
> };
> +
> + /* Prerequisite for hooks and config checks */
> + setup_git_directory_gently(&nongit_ok);Now this starts to break "-o" option when the command is run from a subdirectory of a git working tree, I suspect.
The setup() will discover that you are in a Git controlled working tree, goes up to the top-level of the working tree, so a user may expect
cd t && git bugreport -o frotz
to create a new directory t/frotz, but it would instead create the directory frotz next to t/, no?
Using OPT_FILENAME and feeding correct prefix to parse_options() will correct this.
> argc = parse_options(argc, argv, "", bugreport_options, > bugreport_usage, 0);