diff options
author | Pierre Habouzit <madcoder@debian.org> | 2007-09-27 15:25:55 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2007-09-29 21:26:10 -0700 |
commit | 387e7e19d7eb5444be8da8e99ed7491989dc1cbb (patch) | |
tree | b1fcd32479e6d22abc0e2060e70ea7846fa2b273 /builtin-blame.c | |
parent | b315c5c08139c0d3c1e4867a305334e29da01d07 (diff) | |
download | git-387e7e19d7eb5444be8da8e99ed7491989dc1cbb.tar.gz |
strbuf_read_file enhancement, and use it.
* make strbuf_read_file take a size hint (works like strbuf_read)
* use it in a couple of places.
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-blame.c')
-rw-r--r-- | builtin-blame.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/builtin-blame.c b/builtin-blame.c index 16c0ca8206..e3112a2d5b 100644 --- a/builtin-blame.c +++ b/builtin-blame.c @@ -2002,7 +2002,6 @@ static struct commit *fake_working_tree_commit(const char *path, const char *con unsigned char head_sha1[20]; struct strbuf buf; const char *ident; - int fd; time_t now; int size, len; struct cache_entry *ce; @@ -2041,11 +2040,8 @@ static struct commit *fake_working_tree_commit(const char *path, const char *con mode = canon_mode(st.st_mode); switch (st.st_mode & S_IFMT) { case S_IFREG: - fd = open(read_from, O_RDONLY); - if (fd < 0) - die("cannot open %s", read_from); - if (strbuf_read(&buf, fd, 0) != xsize_t(st.st_size)) - die("cannot read %s", read_from); + if (strbuf_read_file(&buf, read_from, st.st_size) != st.st_size) + die("cannot open or read %s", read_from); break; case S_IFLNK: if (readlink(read_from, buf.buf, buf.alloc) != fin_size) |