summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8cf58c4)
raw | patch | inline | side by side (parent: 8cf58c4)
author | Jonas Fonseca <fonseca@diku.dk> | |
Wed, 31 Dec 2008 06:56:55 +0000 (01:56 -0500) | ||
committer | Jonas Fonseca <fonseca@diku.dk> | |
Tue, 13 Jan 2009 21:55:18 +0000 (22:55 +0100) |
tig.c | patch | blob | history |
index cb2c09fd10ab416bccecff5cd50a188540867d48..7275a993591e8e3cf241bab26ae4014a34f234fe 100644 (file)
--- a/tig.c
+++ b/tig.c
return io->buf;
}
+static bool
+run_io_buf(const char **argv, char buf[], size_t bufsize)
+{
+ struct io io = {};
+ bool error;
+
+ if (!run_io_rd(&io, argv, FORMAT_NONE))
+ return FALSE;
+
+ io.buf = buf;
+ io.bufalloc = bufsize;
+ error = !io_gets(&io) && io_error(&io);
+ io.buf = NULL;
+
+ return done_io(&io) || error;
+}
+
/*
* User requests
static bool
add_describe_ref(char *buf, size_t *bufpos, const char *commit_id, const char *sep)
{
+ const char *describe_argv[] = { "git", "describe", commit_id, NULL };
char refbuf[SIZEOF_STR];
char *ref = NULL;
- FILE *pipe;
-
- if (!string_format(refbuf, "git describe %s 2>/dev/null", commit_id))
- return TRUE;
- pipe = popen(refbuf, "r");
- if (!pipe)
- return TRUE;
-
- if ((ref = fgets(refbuf, sizeof(refbuf), pipe)))
- ref = chomp_string(ref);
- pclose(pipe);
+ if (run_io_buf(describe_argv, refbuf, sizeof(refbuf)))
+ ref = chomp_string(refbuf);
if (!ref || !*ref)
return TRUE;