summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b760d3a)
raw | patch | inline | side by side (parent: b760d3a)
author | Linus Torvalds <torvalds@linux-foundation.org> | |
Wed, 17 Dec 2008 18:26:13 +0000 (10:26 -0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 17 Dec 2008 21:36:34 +0000 (13:36 -0800) |
This makes all tests pass on a system where 'lstat()' has been hacked to
return bogus data in st_size for symlinks.
Of course, the test coverage isn't complete, but it's a good baseline.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
return bogus data in st_size for symlinks.
Of course, the test coverage isn't complete, but it's a good baseline.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff.c | patch | blob | history |
index afefe087bba00bc9ec98327a880fbefdcf44a1d1..4b2029caa1c4a33154716ead5c385639f4b3f856 100644 (file)
--- a/diff.c
+++ b/diff.c
s->size = xsize_t(st.st_size);
if (!s->size)
goto empty;
- if (size_only)
- return 0;
if (S_ISLNK(st.st_mode)) {
- int ret;
- s->data = xmalloc(s->size);
- s->should_free = 1;
- ret = readlink(s->path, s->data, s->size);
- if (ret < 0) {
- free(s->data);
+ struct strbuf sb = STRBUF_INIT;
+
+ if (strbuf_readlink(&sb, s->path, s->size))
goto err_empty;
- }
+ s->data = strbuf_detach(&sb, &s->size);
+ s->should_free = 1;
return 0;
}
+ if (size_only)
+ return 0;
fd = open(s->path, O_RDONLY);
if (fd < 0)
goto err_empty;