Re: [PATCH 1/2] pretty: add %(describe)
flat view
From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2021-02-17 00:59:30
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?
quoted hunk ↗ jump to hunk
+ 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.