Subject: Re: [PATCH 02/14] combine-diff: add combine_diff_path_new()

From: Junio C Hamano <[email-masked]>
Date: Thu, 09 Jan 2025 10:05:41 -0800

Jeff King <[email-masked]> writes:

> +struct combine_diff_path *combine_diff_path_new(const char *path,
> +						size_t path_len,
> +						unsigned int mode,
> +						const struct object_id *oid,
> +						size_t num_parents)
> +{
> +	struct combine_diff_path *p;
> +
> +	p = xmalloc(combine_diff_path_size(num_parents, path_len));
> +	p->path = (char *)&(p->parent[num_parents]);
> +	memcpy(p->path, path, path_len);
> +	p->path[path_len] = 0;
> +	p->next = NULL;
> +	p->mode = mode;
> +	oidcpy(&p->oid, oid);
> +
> +	memset(p->parent, 0, sizeof(p->parent[0]) * num_parents);
> +
> +	return p;
> +}

OK, I can see how the structure is laid out clearly in this code,
but I have to say it is one ugly hack X-<.  At least with the
refactoring, it becomes much easier to see what the caller is doing.