Commit a60272b3 authored by Linus Torvalds's avatar Linus Torvalds Committed by Junio C Hamano

Make 'ce_compare_link()' use the new 'strbuf_readlink()'

This simplifies the code, and also makes ce_compare_link now able to
handle filesystems with odd 'st_size' return values for symlinks.
Signed-off-by: default avatarLinus Torvalds <>
Signed-off-by: default avatarJunio C Hamano <>
parent b11b7e13
......@@ -99,27 +99,21 @@ static int ce_compare_data(struct cache_entry *ce, struct stat *st)
static int ce_compare_link(struct cache_entry *ce, size_t expected_size)
int match = -1;
char *target;
void *buffer;
unsigned long size;
enum object_type type;
int len;
struct strbuf sb = STRBUF_INIT;
target = xmalloc(expected_size);
len = readlink(ce->name, target, expected_size);
if (len != expected_size) {
if (strbuf_readlink(&sb, ce->name, expected_size))
return -1;
buffer = read_sha1_file(ce->sha1, &type, &size);
if (!buffer) {
return -1;
if (buffer) {
if (size == sb.len)
match = memcmp(buffer, sb.buf, size);
if (size == expected_size)
match = memcmp(buffer, target, size);
return match;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment