summaryrefslogtreecommitdiff
path: root/combine-diff.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2008-12-17 12:37:58 -0800
committerJunio C Hamano <gitster@pobox.com>2008-12-17 13:36:35 -0800
commit912342d9d69a30e49491f3fd4d3aa8dc2f6050f3 (patch)
treed784232c52f8d7cd6338dc172edd11a3a7eaf1b2 /combine-diff.c
parentedfd45d2a0fc85d55479e13e8e3dc7e975a313ce (diff)
downloadgit-912342d9d69a30e49491f3fd4d3aa8dc2f6050f3.tar.gz
combine-diff.c: use strbuf_readlink()
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>
Diffstat (limited to 'combine-diff.c')
-rw-r--r--combine-diff.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/combine-diff.c b/combine-diff.c
index ec8df39bb0..bccc018ab2 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -703,15 +703,15 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
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)) &&