Skip to content

Commit

Permalink
combine-diff.c: use strbuf_readlink()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Junio C Hamano committed Dec 17, 2008
1 parent edfd45d commit 912342d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions combine-diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) &&
Expand Down

0 comments on commit 912342d

Please sign in to comment.