Re: [PATCH v1 3/3] convert: ce_compare_data() checks for a sha1 of a path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



tboegi@xxxxxx 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 majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]