🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.git
Article #15

Re: [PATCH v2 2/2] merge: remember conflict labels

#15
From: Phillip Wood
Date: Wed, 07 Oct 2026 13:38
59 lines
10183 bytes
On 06/10/2026 16:46, Junio C Hamano wrote:
> Phillip Wood <phillip.wood123@gmail.com> writes:
> 
>> @@ -4969,6 +4973,13 @@ void merge_switch_to_result(struct merge_options *opt,
>>   			return;
>>   		}
>>   		trace2_region_leave("merge", "write_auto_merge", opt->repo);
>> +
>> +		trace2_region_enter("merge", "write_merge_labels", opt->repo);
>> +		opt->priv = result->priv;
>> +		write_merge_labels(opt->repo, opt->priv->labels[0], opt->priv->labels[1],
>> +				   opt->priv->labels[2]);
>> +		opt->priv = NULL;
>> +		trace2_region_leave("merge", "write_merge_labels", opt->repo);
> 
> A "if (result->clean >= 0 && update_worktree_and_index)" condition
> guards this code path, so we unconditionall call
> write_merge_labels(), whether the result is clean or with conflict.
> Am I reading the code correctly?

Yes, I think so. Ouch! how did I miss that?

Will fix, thanks

Phillip
>> @@ -5234,6 +5245,14 @@ static void move_opt_priv_to_result_priv(struct merge_options *opt,
>>   	 * to move it.
>>   	 */
>>   	assert(opt->priv && !result->priv);
>> +	if (!result->clean) {
>> +		opt->priv->labels[0] =
>> +			mem_pool_strdup(&opt->priv->pool, opt->ancestor);
>> +		opt->priv->labels[1] =
>> +			mem_pool_strdup(&opt->priv->pool, opt->branch1);
>> +		opt->priv->labels[2] =
>> +			mem_pool_strdup(&opt->priv->pool, opt->branch2);
>> +	}
> 
> But we only populate the labels[] when conflicted.  What would we
> write when we do not have conflicts?
> 
>> +int write_merge_labels(struct repository *r, const char *base,
>> +			  const char *ours, const char *theirs)
>> +{
>> +	FILE *f = fopen_or_warn(git_path_merge_labels(r), "w");
>> +
>> +	if (!f)
>> +		return -1;
>> +
>> +	fprintf(f, "%s\n%s\n%s\n", base, ours, theirs);
>> +	if (fclose(f))
>> +		return error_errno("could not write '%s'",
>> +				   git_path_merge_labels(r));
>> +
>> +	return 0;
>> +}
> 
> Would the answer be "(null)\n(null)\n(null)\n"?
Technical Details
Message-ID: <42d3f663-6eff-4311-9bdb-d437a757bff5@gmail.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-71358-linux-kernel-git=dewy.ru
References: <cover.1790761727.git.phillip.wood@dunelm.org.uk> <cover.1791206658.git.phillip.wood@dunelm.org.uk> <18bdf7df49dde2c8e7f73f3b46c656abb6b26293.1791206658.git.phillip.wood@dunelm.org.uk> <xmqqh5iyg7bx.fsf@gitster.g>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-71358-linux-kernel-git=dewy.ru
From: phillip.wood123@gmail.com (Phillip Wood)
Newsgroups: linux.kernel.git
Subject: Re: [PATCH v2 2/2] merge: remember conflict labels
Date: Wed, 7 Oct 2026 14:38:58 +0100
Organization: Usenet Network
Message-ID: <42d3f663-6eff-4311-9bdb-d437a757bff5@gmail.com>
References: <cover.1790761727.git.phillip.wood@dunelm.org.uk>
 <cover.1791206658.git.phillip.wood@dunelm.org.uk>
 <18bdf7df49dde2c8e7f73f3b46c656abb6b26293.1791206658.git.phillip.wood@dunelm.org.uk>
 <xmqqh5iyg7bx.fsf@gitster.g>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
	logging-data="660023"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:JY61qIt9mvgB0yAPVtwQxoU29xU= sha256:yKtuXly/1Ot/Yj6uK9DRva5ctnp/XX5rruZdbm4ozi0=
	sha1:wI5L5cTPRqAafNdyR8s88rFva9w= sha256:GLSe921b+ZtAE55tgiNSW8BZxQM6pJI7va+6Pm6sj1M=
Content-Language: en-US
List-ID: <git.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 316B910E23E; Wed,  7 Oct 2026 17:08:13 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: 0.351
X-Spam-Status: No, score=0.351 tagged_above=-9999 required=6.31
	tests=[DCC_CHECK=1.1, DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
	FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
	MAILING_LIST_MULTI=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
	autolearn=no autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id rIOFIO0VG0kj;
	Wed,  7 Oct 2026 17:08:10 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=git+bounces-71358-linux-kernel-git=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 7E79D10F17F; Wed,  7 Oct 2026 17:08:07 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1])
	by tor.lore.kernel.org (Postfix) with ESMTP id 7B600345DB; Wed,  7 Oct 2026 13:39:14 +0000 (UTC)
X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id D2E593F825B;
	Wed,  7 Oct 2026 13:39:12 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="oG0D+hjf"
X-Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4E3D748E0E3
	for <git@vger.kernel.org>; Wed,  7 Oct 2026 13:39:02 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.46
X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1791380350; cv=none; b=rrMx0btD9WoIe7HPlYGS++3na0bNnDPwB5Ukg55noP1h0L+hCskgPESy/3Y8wkVhVnyLgMHidven27OiUFp8gYn7mF7Yxae7nvZujFEV+ZwCTZUQFYHfg0LzaCZVcGWC48Op+1FGC/LAC2DZVG5U0Z4KVd2TURWFFOlSGVYWDx4=
X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1791380350; c=relaxed/simple;
	bh=v8Q/8DuOnoBSiu/5jrUNlSK+OQ7Sm98MmJdiYl0idBM=;
	h=Message-ID:Date:MIME-Version:From:Subject:To:Cc:References:
	 In-Reply-To:Content-Type; b=c6NbwmyX5mIQnNVdUSR1ZP4BGUAl+BO+hIIUMGuMmxdk2FpHBywn/5sgKLeOk4+VrqIrhbpffRmTgdt5G7E4BMsJMts0tOHH3P5BSLSb0gew43YKOk//F60dsTI22gFXwMEc0yKioUexKTbnlCBhcMk44Ah1TDA4s/bSbIPoMsw=
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=oG0D+hjf; arc=none smtp.client-ip=209.85.218.46
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-c2e8e738ae0so269234966b.1
        for <git@vger.kernel.org>; Wed, 07 Oct 2026 06:39:01 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20251104; t=1791380340; x=1791985140; darn=vger.kernel.org;
        h=content-transfer-encoding:content-type:in-reply-to:content-language
         :references:cc:to:subject:reply-to:from:user-agent:mime-version:date
         :message-id:from:to:cc:subject:date:message-id:reply-to:content-type;
        bh=5fBGPtaVy1uySLXv2ORfiPoCNXjUQXCYhGAyRP5iAWM=;
        b=oG0D+hjfIVGlBLDPJCn4CAAuv3WZWpE7fCvuZmXjmadBmod3s7/Rjh3+eXX99hteb5
         GBEw4FTD9euWbH5D3pfTzQu0lNY9kmcv94gTraRfwc4GGSkOlNwIYPftNAObgMB63QO+
         j3xAkFaEcbHkRDK2Co4ynVDREs8M+PlQ7tCQpSYtzhePF8JWgPr64UgQUf7WXCeuIg3y
         qcfBWo7GdRX/nu8AqOWKymO4VcwinlBEMyW9pD3GX7j6zExVtTcAqWfVRx/tJfSNXhH1
         D4SeHGAYjgXZrxryn2sD3LCnny5OVga13XIEBA8BqdRTih3m6Cs+HBiaRBehqd+PIcEZ
         uPBg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1791380340; x=1791985140;
        h=content-transfer-encoding:content-type:in-reply-to:content-language
         :references:cc:to:subject:reply-to:from:user-agent:mime-version:date
         :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date
         :message-id:reply-to:content-type;
        bh=5fBGPta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ML
	BsAXsDTC1LRBT8VsuRKJnmEBXHBcSB8ll5/9f41vbmg29hpHC64manWTos88ig=
X-Received: by 2002:a17:907:3d89:b0:c2a:f1e7:d1ff with SMTP id a640c23a62f3a-c317bb4cba8mr215191166b.4.1791380340130;
        Wed, 07 Oct 2026 06:39:00 -0700 (PDT)
X-Received: from ?IPV6:2a0a:ef40:724:6601:f3ff:aebc:61f8:d91f? ([2a0a:ef40:724:6601:f3ff:aebc:61f8:d91f])
        by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c317c176e4dsm107346266b.14.2026.10.07.06.38.59
        (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
        Wed, 07 Oct 2026 06:38:59 -0700 (PDT)
X-Precedence: bulk
X-Mailing-List: git@vger.kernel.org
X-List-Subscribe: <mailto:git+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:git+unsubscribe@vger.kernel.org>
X-User-Agent: Mozilla Thunderbird
X-Reply-To: phillip.wood@dunelm.org.uk
X-Cc: git@vger.kernel.org, Elijah Newren <newren@gmail.com>,
 Johannes Sixt <j6t@kdbg.org>
X-In-Reply-To: <xmqqh5iyg7bx.fsf@gitster.g>