return item;
}
-static int read_from_command(struct child_process *cp, struct strbuf *buf)
-{
- if (run_command(cp))
- return error("running trailer command '%s' failed", cp->argv[0]);
- if (strbuf_read(buf, cp->out, 1024) < 1)
- return error("reading from trailer command '%s' failed", cp->argv[0]);
- strbuf_trim(buf);
- return 0;
-}
-
static const char *apply_command(const char *command, const char *arg)
{
struct strbuf cmd = STRBUF_INIT;
cp.argv = argv;
cp.env = local_repo_env;
cp.no_stdin = 1;
- cp.out = -1;
cp.use_shell = 1;
- if (read_from_command(&cp, &buf)) {
+ if (capture_command(&cp, &buf, 1024)) {
+ error("running trailer command '%s' failed", cmd.buf);
strbuf_release(&buf);
result = xstrdup("");
- } else
+ } else {
+ strbuf_trim(&buf);
result = strbuf_detach(&buf, NULL);
+ }
strbuf_release(&cmd);
return result;