πŸš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.git
Article #31

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

#31
From: Junio C Hamano
Date: Wed, 07 Oct 2026 17:15
42 lines
11490 bytes
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?

> 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?

Thanks.
Technical Details
Message-ID: <xmqqa4opa0up.fsf@gitster.g>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-71381-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>

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-71381-linux-kernel-git=dewy.ru
From: gitster@pobox.com (Junio C Hamano)
Newsgroups: linux.kernel.git
Subject: Re: [PATCH 2/2] stash push: remove duplicate changes detection
Date: Wed, 07 Oct 2026 10:15:26 -0700
Organization: Usenet Network
Message-ID: <xmqqa4opa0up.fsf@gitster.g>
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>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: usenet.network;
	logging-data="694210"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:IYc8NFVu1kmSDRoEEL58HJPVhfg= sha256:WEFzK1oAc5BMINDM/DCcGXsYDWHCLI7yYcqBMkI4iM8=
	sha1:mVrudpY0mk9M3RqaGxnlKSsws1c= sha256:TpXNif688gpZsTrA+3GYRcBInTvTkwFjKSCUnbQuPZE=
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 74DD710F1BA; Wed,  7 Oct 2026 20:15:47 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.051
X-Spam-Status: No, score=-3.051 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, 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=pobox.com header.b=nExfauVp; dkim=pass (2048-bit key)
	header.d=messagingengine.com header.b=QkmxZs5o
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 QhDVNlxri9NJ;
	Wed,  7 Oct 2026 20:15:43 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=git+bounces-71381-linux-kernel-git=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=pobox.com
X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
	by mail.dewy.ru (Postfix) with ESMTPS id C412310F108; Wed,  7 Oct 2026 20:15:38 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1])
	by sin.lore.kernel.org (Postfix) with ESMTP id EC91826DB6; Wed,  7 Oct 2026 17:15:34 +0000 (UTC)
X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id A93B03CD8B5;
	Wed,  7 Oct 2026 17:15:31 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=pobox.com header.i=@pobox.com header.b="nExfauVp";
	dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="QkmxZs5o"
X-Received: from fout-a2-smtp.messagingengine.com (fout-a2-smtp.messagingengine.com [103.168.172.145])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1DC2B34C130
	for <git@vger.kernel.org>; Wed,  7 Oct 2026 17:15:28 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.145
X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1791393330; cv=none; b=Jv9xNa9mbwLveHxDeKSQOuj/hZfb1vC2IOuJB9bU08OMYX4fu3/7gLP0nr9DUBabAEx32KCHaYaPvAjc756ucIjQfZUrlLVRjF6cU8fIN1NlMmxiwI5maX8hioC+UpHhG8CFF4/H2yd3IDHNuf1g1BcYE41rRmv+5cpM9V8gews=
X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1791393330; c=relaxed/simple;
	bh=9QjHUqNRkJD4NIljA7qZVYQ358OswRVIvDN0hOnMoJw=;
	h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID:
	 MIME-Version:Content-Type; b=mQFXA5DvX37hdjf72Zt1NjRaEfFhpt10V6RP6iP6mmxqoc7Ad8lw9YGVi+tdLGGumc3D/dLmJsdhh3wlwUZSKEIQoB2KFsZeKfZDUkgyxds0UAbCX9eEIgrPQXtkG/BcNdoJhWHogZjfw273dM+1xAFr2pzQciOu/ltPAfKAJ90=
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com; spf=pass smtp.mailfrom=pobox.com; dkim=pass (2048-bit key) header.d=pobox.com header.i=@pobox.com header.b=nExfauVp; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=QkmxZs5o; arc=none smtp.client-ip=103.168.172.145
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pobox.com
X-Received: from phl-compute-03.internal (phl-compute-03.internal [10.202.2.43])
	by mailfout.phl.internal (Postfix) with ESMTP id 43BACEC0479
	for <git@vger.kernel.org>; Wed,  7 Oct 2026 13:15:28 -0400 (EDT)
X-Received: from phl-frontend-02 ([10.202.2.161])
  by phl-compute-03.internal (MEProxy); Wed, 07 Oct 2026 13:15:28 -0400
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pobox.com; h=cc
	:cc:content-type:content-type:date:date:from:from:in-reply-to
	:in-reply-to:message-id:mime-version:references:reply-to:subject
	:subject:to:to; s=fm1; t=1791393328; x=1791479728; bh=x7joEPmNS8
	IGzCmEms5DFc9Wxt53CcmYFW8LuOYBhEs=; b=nExfauVpREbpNGr2ySgH3HUVmS
	rCIU7WVE5iQzV1ubqGoeRaPgQL42iLxWNFnp6hVcJSzI4pCdcrsxnMIjYTvv0hOj
	TCTOO8xW8HMIsjYJ97ueqLFsWy/roSepcerbRsQ7Ml67FE0VfV4pswHU2YkYmBxL
	Ter8ZMETJW0j9Qw+D+n8tadae9lW8VkoAbkHH5yis/tADFHMOdIGjO/QEkg3S3dN
	Wqqy8EbV7bLpyPCcZoXCfBgoTdd7WrItI+5i+08xWeiEDAK4Jfg9hLATG2L+mmLF
	wexB7GnvLtIxGL+t9KjhXYDNzCMPPIIVhUiPHE6W4JlXmuZPOQ2wyR8GZX8w==
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
	messagingengine.com; h=cc:cc:content-type:content-type:date:date
	:feedback-id:feedback-id:from:from:in-reply-to:in-reply-to
	:message-id:mime-version:references:reply-to:subject:subject:to
	:to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=
	1791393328; x=1791479728; bh=x7joEPmNS8IGzCmEms5DFc9Wxt53CcmYFW8
	LuOYBhEs=; b=QkmxZs5obqExhUF+8D4UBE9WHTop3WE1L5JlOiTKc2WgGlH2zmb
	KkwCg2P8Q6CTyjLR+tmO3b52sxcJ7qBmkfAmrPo683XSkKVp+zUX+l8cmkwXebNT
	VudaZPs3QC2lRG/hw8g625az3UMe0ToFAapLcfxtvqGGJqrAWlLSBYlk1U1KANZY
	OatiU8XgxTNbKQC5hSzKiaHwzrPn9D7gyzGjTGTm9nmh8/7ZnIesiWaF8hF3NPUn
	4StWP8RARR4iIR7Okl9lm8p0Bkavsh5rQF0w+wAXxNSxxUBSbqEt4fq4QWBFKnvo
	7biwt27XCwD+B7OxYuCDripbfejiCKsAwpQ==
X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-06;
	repo=github.com/dkim2wg/interop; date=2026-10-04; sw=lmtpprox;
	action=sign d=pobox.com a=rsa-sha256;
X-DKIM2-Signature: i=1; m=1; t=1791393328; d=pobox.com;
	mf=PGdpdHN0ZXJAcG9ib3guY29tPg==;
	rt=PGdpdEB2Z2VyLmtlcm5lbC5vcmc+;
	s=fm1:rsa-sha256:Wqrfm0sblEBj3d86NEDPDNPwU+1y06YCCMIun98QAC0VvZ/
	wnyU10H32lzQwICEvGcgBodQ6Ub2B6RS+ZI/PmvEilebJgaoxvO2EjGhN6DQ+4XR
	Ritfj1s4yR997hsdtgQHWXG57ctTqjjp13cKed+Q0xsRE0b95khfgKFTOV8TQ+bj
	Yb5CGzJ7v/+j1E2CuhHQMvs6uyC03XPLA3dOAZ7BZr2WYZZNPm1VSAuZguRIrP/G
	ErTSr5nS0o4MmQ7hE4cTpHXQDpSW1o9GpJy1WPfZZDmrlaGk/s0du18kymegNi17
	/G0q5HQgnlUVtXprjq2Cro3d0QxjOAyw1QbXjbg==;
X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-06;
	repo=github.com/dkim2wg/interop; date=2026-10-04; sw=lmtpprox;
	action=mi-m=1; hc=12;
	hn=cc,content-type,date,feedback-id,from,in-reply-to,message-id,
	mime-version,references,subject,to,user-agent;
X-Message-Instance: m=1; h=sha256:wBYRF+QRHQuDJy9WZ5/3dk3lO0BLABxU8i2pxNkmDVs=:9QjHUqNRkJD4NIljA7qZVYQ358OswRVI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gai2S-BKCTfrxroYbl0PC-Wvja9tVHx96eyAShpFutn_KUKRBhA>
    <xmx:MH7Gaujg59uHkhbCQB2vIX0Wno0R6yioo4fyy8HDI9Gma7v47fmIgQ>
    <xmx:MH7GaqeAQcrCQvccN19Idt3yAjsmXfHkEppdBUysBa9Fii-zm4wGLw>
    <xmx:MH7GapnkWOtiVpPs2gQ2iPc0aq-6k2u9LiGzgy8wMu6INOWWMpNPeA>
    <xmx:MH7GanAu_112ji5NpIzvePXcPMJUtacrzhEtADw7kTUxGyt6qEpOlHAv>
X-Feedback-ID: if26b431b:Fastmail
X-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed,
 7 Oct 2026 13:15:27 -0400 (EDT)
X-Cc: git@vger.kernel.org,  重田一聖
 <kazumasa.shigeta@kanamei.com>
X-In-Reply-To: <725487d3-5a07-40c6-a603-990a661e0193@gmail.com> (Phillip Wood's
	message of "Wed, 7 Oct 2026 14:46:08 +0100")
X-User-Agent: Gnus/5.13 (Gnus v5.13)
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>