Re: [PATCH 1/2] pretty: add %(describe)
- From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- Date
- Feb 17, 2021, 00:58 UTC
- Message-ID
- <87k0r7a4sr.fsf@evledraar.gmail.com>
- In-Reply-To
- <5561d11b-08c3-bcf7-5d37-a7d6c6bfb715@web.de>
On Sun, Feb 14 2021, René Scharfe wrote:
> +'%(describe)':: human-readable name, like linkgit:git-describe[1]; > + empty string for undescribable commits
In the case of undescribable we've got the subcommand exiting non-zero and we ignore it. The right thing in this case given how the rest of format arguments work, but maybe something to explicitly test for?
Show 16 quoted lines
>
> + if (skip_prefix(placeholder, "(describe)", &arg)) {
> + struct child_process cmd = CHILD_PROCESS_INIT;
> + struct strbuf out = STRBUF_INIT;
> + struct strbuf err = STRBUF_INIT;
> +
> + cmd.git_cmd = 1;
> + strvec_push(&cmd.args, "describe");
> + strvec_push(&cmd.args, oid_to_hex(&commit->object.oid));
> + pipe_command(&cmd, NULL, 0, &out, 0, &err, 0);
> + strbuf_rtrim(&out);
> + strbuf_addbuf(sb, &out);
> + strbuf_release(&out);
> + strbuf_release(&err);
> + return arg - placeholder;
> + }There's another edge case in this: if you do "%(describe)%(describe)" it'll be run twice for the rev, 3 times if you add another "%(describe)" etc. I don't know if pretty.c has an easy way to cache/avoid that.