Re: [PATCH v3 1/1] bugreport: include +i in outfile suffix as needed
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Oct 16, 2023, 22:55 UTC
- Message-ID
- <xmqq4jiqkwi1.fsf@gitster.g>
- In-Reply-To
- <20231016214045.146862-2-jacob@initialcommit.io>
Jacob Stopak <jacob@initialcommit.io> writes:
> builtin/bugreport.c | 83 +++++++++++++++++++++++++++++++-------------- > 1 file changed, 57 insertions(+), 26 deletions(-)
Looking good. It is not easy to do an automated and reliable test for this one for obvious reasons ;-), so let's queue it as-is.
Thanks.
Show 13 quoted lines
> - /* fopen doesn't offer us an O_EXCL alternative, except with glibc. */
> - report = xopen(report_path.buf, O_CREAT | O_EXCL | O_WRONLY, 0666);
> + again:
> + /* fopen doesn't offer us an O_EXCL alternative, except with glibc. */
> + report = open(report_path.buf, O_CREAT | O_EXCL | O_WRONLY, 0666);
> + if (report < 0 && errno == EEXIST && !option_suffix_is_from_user) {
> + build_path(&report_path, prefixed_filename,
> + "git-bugreport-", option_suffix, now, &i,
> + ".txt");
> + goto again;
> + } else if (report < 0) {
> + die_errno(_("unable to open '%s'"), report_path.buf);
> + }I didn't expect a rewrite to add an extra level of indentation like this, though ;-).