πŸš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.git
Article #98

Re: [PATCH 2/2] stash push: remove duplicate changes detection

#98
From: Phillip Wood
Date: Thu, 08 Oct 2026 13:35
54 lines
10633 bytes
On 07/10/2026 18:15, Junio C Hamano wrote:
> Phillip Wood <phillip.wood123@gmail.com> writes:
> 
>>> Before the precontext of this hunk, repo_refresh_and_write_index()
>>> is called to refresh the index.  We used to leave early when
>>> check_changes() saw no need to save.  We no longer do so, and
>>> instead keep going.
>>>
>>>> @@ -1743,8 +1737,15 @@ static int do_push_stash(const struct pathspec *ps, const char *stash_msg, int q
>>>>    
>>>>    	if (stash_msg)
>>>>    		strbuf_addstr(&stash_msg_buf, stash_msg);
>>>> -	if (do_create_stash(ps, &stash_msg_buf, include_untracked, patch_mode,
>>>> -			    interactive_opts, only_staged, &info, &patch, quiet)) {
>>>> +	ret =  do_create_stash(ps, &stash_msg_buf, include_untracked,
>>>> +			       patch_mode, interactive_opts, only_staged, &info,
>>>> +			       &patch, quiet);
>>>
>>> And we call do_create_stash().  The first thing it does is to call
>>> repo_read_index_preload() and repo_refresh_and_write_index().
>>>
>>> Are we refreshing the index twice now, even though we know nothing
>>> has changed in between, when we run "git stash push"?
>>
>> We've always been doing that when there is something to stash (which is
>> the normal case).
> 
> So when there is nothing to stash, we only refreshed once but now
> refreshing twice is not a regression?

If there are no changes then the first refresh will mark all the index 
entries as up-to-date, which means the second refresh wont stat anything 
so I'm not sure there is a noticeable change. To me the more important 
problem is that we're lstat()ing each changed file half a dozen times 
before we call check_changes() when we should be lstat()ing them twice.

>> To avoid that we need to make the callers of do_create_stash()
>> responsible for refreshing the index.  At the moment
>> create_stash() calls do_create_stash() without evening reading the
>> index, but do_push_stash() needs to read the index to check if it
>> the pathspec contains paths that don't match the index. That would
>> also avoid calling preload_index() multiple times.
> 
> Yes, that exactly is the right direction.  Then we can reduce the
> number of check_changes() without increasing the number of
> refreshes, right?

Yes and improve things for the case where we actually have something to 
stash.

Thanks

Phillip
Technical Details
Message-ID: <82bf1054-8455-489d-b832-302909711b2a@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-71487-linux-kernel-git=dewy.ru
References: <cover.1791218125.git.phillip.wood@dunelm.org.uk> <95b7d582a2f86a3db4a9e182e482e9eb904ddeee.1791218125.git.phillip.wood@dunelm.org.uk> <xmqqpkxmgb00.fsf@gitster.g> <725487d3-5a07-40c6-a603-990a661e0193@gmail.com> <xmqqa4opa0up.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-71487-linux-kernel-git=dewy.ru
From: phillip.wood123@gmail.com (Phillip Wood)
Newsgroups: linux.kernel.git
Subject: Re: [PATCH 2/2] stash push: remove duplicate changes detection
Date: Thu, 8 Oct 2026 14:35:40 +0100
Organization: Usenet Network
Message-ID: <82bf1054-8455-489d-b832-302909711b2a@gmail.com>
References: <cover.1791218125.git.phillip.wood@dunelm.org.uk>
 <95b7d582a2f86a3db4a9e182e482e9eb904ddeee.1791218125.git.phillip.wood@dunelm.org.uk>
 <xmqqpkxmgb00.fsf@gitster.g> <725487d3-5a07-40c6-a603-990a661e0193@gmail.com>
 <xmqqa4opa0up.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="892174"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:aWui3Kpgjy2Fsq3J8erdVqBSYLk= sha256:waa+pr90sIMoD48qxJzD94RjntJXu52QCRzt3t0WFCo=
	sha1:f/oE+6Oi4ep2w9okRxpEe0gqtEY= sha256:M0xk3xvqFWi+M+07SU7h2IG0/m2DjAgO/ulxmL/45Ow=
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 BAEAA10F409; Thu,  8 Oct 2026 16:43:43 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -1.949
X-Spam-Status: No, score=-1.949 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, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham 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 uXTGtaArwasQ;
	Thu,  8 Oct 2026 16:43:40 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=git+bounces-71487-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 96E3C10F3E4; Thu,  8 Oct 2026 16:43:37 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1])
	by sea.lore.kernel.org (Postfix) with ESMTP id EEC3F629FC; Thu,  8 Oct 2026 13:35:56 +0000 (UTC)
X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id D9EDC446053;
	Thu,  8 Oct 2026 13:35:52 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="U5suLyvS"
X-Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44])
	(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 73D7544F561
	for <git@vger.kernel.org>; Thu,  8 Oct 2026 13:35:50 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44
X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1791466551; cv=none; b=DgkZV/X1KY7KlHgk8SN2mhoNfpw2ZKDHPNgTfhx8lWN9jdO0bPIh02khCHoHPjC99fVPPQaDMWDRgHEqO6db0ysDWE3G1V4xjo13mkQb9odD7wrWPHU36XFtONfUyGRtZq6aYjrbwtumYHXZmFkOKex7ifNlGWIf3tPd3IxjZZU=
X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1791466551; c=relaxed/simple;
	bh=mnnPylEUZPXkfDd/gQqNOI42UKsRRFuSLyKcM9CXfDo=;
	h=Message-ID:Date:MIME-Version:From:Subject:To:Cc:References:
	 In-Reply-To:Content-Type; b=p1CFTXwJf9ordaDOpZMBRA8FvoH7A0vKb7q+xo10QvoCbOowIaLnEgA3R3YIvCiHYxEq4oisNBXLN8We7BkzJ3hBTS/9jrBSCqKMWmZd8N8y0dxNXpmkMBlTdZhOzzbtaaCBNfLBz1aX36z4JwCeKn344eQ/WmafaOAKEJKUhCM=
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=U5suLyvS; arc=none smtp.client-ip=209.85.128.44
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-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4a140e7405dso53406135e9.3
        for <git@vger.kernel.org>; Thu, 08 Oct 2026 06:35:50 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20251104; t=1791466549; x=1792071349; 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=IHVZuywW14fp5O11hLt3ci6TAfQtasjQHr/O8uua9UY=;
        b=U5suLyvSw9vCY8xCzxGiWajDJyEtXuhtriCTd8ocUeKsbeQ6+b64IcqeZnuHbJ0tX4
         IRCSlVjMWe4dedQnCqpjt/6Z+MRsAjeIMQTRY9xCsQ4R7mNRRmsnZaBSoPX/lH7k6Vh8
         wA2USrevQLPbKry87qBUNLtv0eyGM4qIvMaHDN6Cxhsdk7WPEgkcRSmC5aoFVzxoHsor
         i+gPShapCPWM5/HpVF8/9JE4ySDnm8KoMgv3peTo0u6gWNNHqfiJbc1/sZ6zQYNkU+vD
         Zq0PhsZct1djAt6aOv3AlvukBGDgfDAmuFpy2ieuyl7SnExq7ezx0g2S4dm2n1g7BTHb
         50oA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1791466549; x=1792071349;
        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=IHVZuywW14fp5O11hLt3ci6TAfQtasjQHr/O8uua9UY=;
        b=1yvtiSs9G0gnHpb3cyS0CAVgNbtDmOcMMw2puT4cUPBv2J9jfqwr0+2/YcherlAoKp
         Tv3bZmU4wDYOmJhruYWobsr43qMRH8GG+bTCvtCgouVKlMRD9j10OSo2r6mjsP5kjLts
         PRL0qC3NAzVaOPnxSQF0PY1ufY0ynS5nhyEpT5vs0emPkeUcW8KQJNOtz0YZwIviY4CP
         X1M5VVIV0+NROI7TUKFwA1gRhoNs6jFbTiHxTHg0WUPajTDeH1HtOnmzJe10IbpAeYt2
         RH1yuUHQPS53iPZqd7KxakmnvBLJvBulxkhie0Xzrd7goARVjFxbKGhbbeNT1VxFy0j0
         TWDw==
X-Gm-Message-State: AFuF++n1GHye9/r3KUddZ2MSQ5HUUiE4wyA+iS78QS7hCj2NFoBvzcWm
	vyEvdhUFt8L2VP+avawF6p/MsN78Wrk29lPLAGlvd+M5bBqrojDLg9dTBk4ddBp9
X-Gm-Gg: AYBFou1xDGGEyGpPWvHi1L+JSCCI3Ped/LnuDpEENvxi5Es+zIi0CXo+p2Y7kjK8pr6
	PJ0+UBaoWi/dUBdACyjkB4bTChfRhHF5BYOCp41GCLRxFEILgTCPK0WCzt0Cc9By21fnf6bgHl9
	SSO2rnwZhZlXHuKpFhQJlUZkIdMElNk17/XwTUSlKULRGH/V79STZIEMvNYz26RWZtbpTnE3kWa
	M61+lgDj+9/D2BEgb54n4NSBddnlJWwvvJGzg6umH8oOoI1W+6D+zpUpXJGbc3VDPeiJG1pJWog
	JKi+OiW2f4O1EG78MHP4AMbpd5quFh+uV2uxQ4WYubGB7aVpTKnL1h2iV/M5VNaSXedcmMgP150
	7O6W0aKb9VIVJYEZklLQ9R2giX3lxZdiycI5KXVRrgW0aYcnWmYPbF51ulomecbQ7no/sw/YYPf
	14xBYgdDpp5Lb6DFPh+nqaNeoRyX1+h1v2IEhLpDHoi2WSNPt1jOt4fO9EuDqcbo9ZoMqSrTIfM
	hMKbpqANOrfUdTdxKDv4G8gRtVBEDhZd+xMwI84a7/8dDNGbHOb
X-Received: by 2002:a05:600c:810c:b0:4a1:7163:3e41 with SMTP id 5b1f17b1804b1-4a1804234ffmr93546205e9.9.1791466548086;
        Thu, 08 Oct 2026 06:35:48 -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 ffacd0b85a97d-48c71d3d44asm11897870f8f.54.2026.10.08.06.35.45
        (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
        Thu, 08 Oct 2026 06:35:47 -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, 重田一聖
 <kazumasa.shigeta@kanamei.com>
X-In-Reply-To: <xmqqa4opa0up.fsf@gitster.g>