Subject: Re: [PATCH 12/13] Build in merge

From: Olivier Marin <[email-masked]>
Date: Wed, 25 Jun 2008 18:22:45 +0200

Hi,

I did not read your patches yet but I noticed the two following bugs while testing
current pu.

Miklos Vajna a écrit :
>
> +static void finish(const unsigned char *new_head, const char *msg)
> +{

[...]

> +	if (new_head && show_diffstat) {
> +		diff_setup(&opts);
> +		opts.output_format |=
> +			DIFF_FORMAT_SUMMARY | DIFF_FORMAT_DIFFSTAT;
> +		opts.detect_rename = DIFF_DETECT_RENAME;

You probably want to add DIFF_OPT_SET(&opts, COLOR_DIFF) to have a nice colored diff
like the original script.

> +		diff_tree_sha1(head, new_head, "", &opts);
> +		diffcore_std(&opts);
> +		diff_flush(&opts);
> +	}

[...]

> +int cmd_merge(int argc, const char **argv, const char *prefix)
> +{

[...]

> +	} else if (allow_fast_forward && !remoteheads->next &&
> +		!hashcmp(common->item->object.sha1, head)) {
> +		/* Again the most common case of merging one remote. */
> +		struct strbuf msg;
> +		struct object *o;
> +
> +		printf("Updating %s..%s\n",
> +			find_unique_abbrev(head, DEFAULT_ABBREV),
> +			find_unique_abbrev(remoteheads->item->object.sha1,
> +			DEFAULT_ABBREV));

Here, the second call to find_unique_abbrev() will overwrite the previous returned
value because this function return a pointer to a static buffer.

Olivier.