summaryrefslogtreecommitdiff
path: root/builtin-blame.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2008-12-17 12:37:53 -0800
committerJunio C Hamano <gitster@pobox.com>2008-12-17 13:36:35 -0800
commitedfd45d2a0fc85d55479e13e8e3dc7e975a313ce (patch)
treee974c8d298fa3bacec6988eba1cc0fc7218698e6 /builtin-blame.c
parent737e31af7ae365d6251bb196e06d18afda9c98a8 (diff)
downloadgit-edfd45d2a0fc85d55479e13e8e3dc7e975a313ce.tar.gz
builtin-blame.c: use strbuf_readlink()
When faking a commit out of the work tree contents, use strbuf_readlink() to read the contents of symbolic links. Signed-off-by: Junio C Hamano <gitster@pobox.com> Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'builtin-blame.c')
-rw-r--r--builtin-blame.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/builtin-blame.c b/builtin-blame.c
index a0d60145f2..aae14ef8bb 100644
--- a/builtin-blame.c
+++ b/builtin-blame.c
@@ -1996,7 +1996,6 @@ static struct commit *fake_working_tree_commit(const char *path, const char *con
if (!contents_from || strcmp("-", contents_from)) {
struct stat st;
const char *read_from;
- unsigned long fin_size;
if (contents_from) {
if (stat(contents_from, &st) < 0)
@@ -2008,7 +2007,6 @@ static struct commit *fake_working_tree_commit(const char *path, const char *con
die("Cannot lstat %s", path);
read_from = path;
}
- fin_size = xsize_t(st.st_size);
mode = canon_mode(st.st_mode);
switch (st.st_mode & S_IFMT) {
case S_IFREG:
@@ -2016,9 +2014,8 @@ static struct commit *fake_working_tree_commit(const char *path, const char *con
die("cannot open or read %s", read_from);
break;
case S_IFLNK:
- if (readlink(read_from, buf.buf, buf.alloc) != fin_size)
+ if (strbuf_readlink(&buf, read_from, st.st_size) < 0)
die("cannot readlink %s", read_from);
- buf.len = fin_size;
break;
default:
die("unsupported file type %s", read_from);