summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: edfd45d)
raw | patch | inline | side by side (parent: edfd45d)
author | Junio C Hamano <gitster@pobox.com> | |
Wed, 17 Dec 2008 20:37:58 +0000 (12:37 -0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 17 Dec 2008 21:36:35 +0000 (13:36 -0800) |
When showing combined diff using work tree contents, use strbuf_readlink()
to read symbolic links.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
to read symbolic links.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
combine-diff.c | patch | blob | history |
diff --git a/combine-diff.c b/combine-diff.c
index ec8df39bb01347eb035ad94553357b80af652b78..bccc018ab2666e769e7865d3cad1d61f04443700 100644 (file)
--- a/combine-diff.c
+++ b/combine-diff.c
goto deleted_file;
if (S_ISLNK(st.st_mode)) {
- size_t len = xsize_t(st.st_size);
- result_size = len;
- result = xmalloc(len + 1);
- if (result_size != readlink(elem->path, result, len)) {
+ struct strbuf buf = STRBUF_INIT;
+
+ if (strbuf_readlink(&buf, elem->path, st.st_size) < 0) {
error("readlink(%s): %s", elem->path,
strerror(errno));
return;
}
- result[len] = 0;
+ result_size = buf.len;
+ result = strbuf_detach(&buf, NULL);
elem->mode = canon_mode(st.st_mode);
}
else if (0 <= (fd = open(elem->path, O_RDONLY)) &&