[email protected] writes:
> -static int has_cr_in_index(const char *path)
> +static int has_cr_in_index(const char *path, const unsigned char *sha1)
> {
> unsigned long sz;
> void *data;
> int has_cr;
> -
> - data = read_blob_data_from_cache(path, &sz);
> - if (!data)
> + enum object_type type;
> + if (!sha1)
> + sha1 = get_sha1_from_cache(path);
> + if (!sha1)
> + return 0;
> + data = read_sha1_file(sha1, &type, &sz);
> + if (!data || type != OBJ_BLOB) {
> + free(data);
> return 0;
> + }
> +
> has_cr = memchr(data, '\r', sz) != NULL;
> free(data);
> return has_cr;
> }
Does this really need 2/3? Wouldn't this be equivalent to
if (!sha1) {
data = read_blob_data_from_cache(path, &sz);
} else {
data = read_sha1_file(sha1, &type, &sz);
}
if (!data || type != OBJ_BLOB) {
free(data);
return 0;
}
has_cr = ...
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html