Skip to content

Commit edfd45d

Browse files
committed
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 <[email protected]> Acked-by: Linus Torvalds <[email protected]>
1 parent 737e31a commit edfd45d

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

builtin-blame.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1996,7 +1996,6 @@ static struct commit *fake_working_tree_commit(const char *path, const char *con
19961996
if (!contents_from || strcmp("-", contents_from)) {
19971997
struct stat st;
19981998
const char *read_from;
1999-
unsigned long fin_size;
20001999

20012000
if (contents_from) {
20022001
if (stat(contents_from, &st) < 0)
@@ -2008,17 +2007,15 @@ static struct commit *fake_working_tree_commit(const char *path, const char *con
20082007
die("Cannot lstat %s", path);
20092008
read_from = path;
20102009
}
2011-
fin_size = xsize_t(st.st_size);
20122010
mode = canon_mode(st.st_mode);
20132011
switch (st.st_mode & S_IFMT) {
20142012
case S_IFREG:
20152013
if (strbuf_read_file(&buf, read_from, st.st_size) != st.st_size)
20162014
die("cannot open or read %s", read_from);
20172015
break;
20182016
case S_IFLNK:
2019-
if (readlink(read_from, buf.buf, buf.alloc) != fin_size)
2017+
if (strbuf_readlink(&buf, read_from, st.st_size) < 0)
20202018
die("cannot readlink %s", read_from);
2021-
buf.len = fin_size;
20222019
break;
20232020
default:
20242021
die("unsupported file type %s", read_from);

0 commit comments

Comments
 (0)