Re: [PATCH v2] builtin/log.c: prepend "RFC" on --rfc
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 28, 2023, 23:53 UTC
- Message-ID
- <xmqqledug1vd.fsf@gitster.g>
- In-Reply-To
- <ZO0sFWJLX8YaJ2F/@nand.local>
Taylor Blau <me@ttaylorr.com> writes:
Show 8 quoted lines
> I am not super familiar with this code, so could easily be missing
> something here, but I think that you can do this in a more direct way
> like so:
> ...
> static int rfc_callback(const struct option *opt, const char *arg, int unset)
> {
> + free(subject_prefix);
> + subject_prefix = xstrfmt("RFC %s", revs->subject_prefix);As Phillip Wood pointed out, this approach no longer works once "--rfc" is "no matter what subject-prefix says, we prepend RFC in front", as the order of command line flags is not forced. At this point, revs->subject_prefix may be one value (or worse, even not initialized), and then --subject-prefix=<new-prefix> command line argument may yet to be parsed.
> + return subject_prefix_callback(opt, subject_prefix, unset); > }
So, we'd most likely need to treat subject_prefix and rfc as two separate strings while parse_options() is doing its work, and then after that prepend the rfc string, if set, to the final version of the subject_prefix string.