Article View: linux.kernel.git
Article #2473Re: [PATCH v4 5/7] stash create: rework temporary index creation
From: Junio C Hamano
Date: Thu, 05 Nov 2026 21:55
Date: Thu, 05 Nov 2026 21:55
49 lines
14289 bytes
14289 bytes
Phillip Wood <phillip.wood123@gmail.com> writes:
> Use create_index_from_tree() instead of reset_tree() so that we
> can create temporary index file without overwriting the in-memory
> index or relying on set_alternate_index_output().
This is very nice simplification.
> As create_index_from_tree() does not
> modify the in-memory index it is clearly safe to remove the call to
> repo_read_index_preload() which saves one lstat() call per changed
> path.
;-)
> It would probably be safe to remove that call without moving away
> from reset_tree() but it is much easier to reason about now that the
> in-memory index is not modified when we create the temporary index file.
Indeed.
> @@ -1458,22 +1458,15 @@ static int stash_working_tree(struct stash_info *info, const struct pathspec *ps
> repo_init_revisions(the_repository, &rev, NULL);
> copy_pathspec(&rev.prune_data, ps);
>
> - set_alternate_index_output(stash_index_path.buf);
> - if (reset_tree(&info->i_tree, 0, 0)) {
> + if (create_index_from_tree(&info->i_tree, stash_index_path.buf, false)) {
> ret = -1;
> goto done;
> }
> - set_alternate_index_output(NULL);
>
> rev.diffopt.output_format = DIFF_FORMAT_CALLBACK;
> rev.diffopt.format_callback = add_diff_to_buf;
> rev.diffopt.format_callback_data = &diff_output;
>
> - if (repo_read_index_preload(the_repository, &rev.diffopt.pathspec, 0) < 0) {
> - ret = -1;
> - goto done;
> - }
> -
Yup, removal of these is indeed very nice.
> add_pending_object(&rev, parse_object(the_repository, &info->b_commit),
> "");
> run_diff_index(&rev, 0);
Technical Details
Message-ID:
<xmqqmrrnq6xh.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-74613-linux-kernel-git=dewy.ruReferences:
<cover.1791218125.git.phillip.wood@dunelm.org.uk> <cover.1792767794.git.phillip.wood@dunelm.org.uk> <b62d3d080a8ff0d9e14741a886aa45d70019bd64.1792767795.git.phillip.wood@dunelm.org.uk>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-74613-linux-kernel-git=dewy.ru
From: gitster@pobox.com (Junio C Hamano)
Newsgroups: linux.kernel.git
Subject: Re: [PATCH v4 5/7] stash create: rework temporary index creation
Date: Thu, 05 Nov 2026 13:55:54 -0800
Organization: Usenet Network
Message-ID: <xmqqmrrnq6xh.fsf@gitster.g>
References: <cover.1791218125.git.phillip.wood@dunelm.org.uk>
<cover.1792767794.git.phillip.wood@dunelm.org.uk>
<b62d3d080a8ff0d9e14741a886aa45d70019bd64.1792767795.git.phillip.wood@dunelm.org.uk>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: usenet.network;
logging-data="3739651"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:PFl2o4Yiqdfi4Hin/KSxEa9FqRM= sha256:gducYfPYilGaWO32nJqUZrrVkRMfZJW5YxUhsdqLMac=
sha1:iRiUBa8mOjt7l2t1j3ilPVjE8FA= sha256:1c84ENBuhrkEYcxz4wsvPEKY11C8ThncnJt3hl7gDb8=
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 7AD0F1130D3; Fri, 6 Nov 2026 01:00:53 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.05
X-Spam-Status: No, score=-3.05 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, URIBL_BLOCKED=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=a+p5Nh+Y; dkim=pass (2048-bit key)
header.d=messagingengine.com header.b=va0pGdiL
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 j6EZb9zJzKsN;
Fri, 6 Nov 2026 01:00:49 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=git+bounces-74613-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by mail.dewy.ru (Postfix) with ESMTPS id 67D531130C2; Fri, 6 Nov 2026 01:00:36 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sea.lore.kernel.org (Postfix) with ESMTP id 2F6232B043; Thu, 5 Nov 2026 21:55:59 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1793915758;
b=r7SrgJ38kmM9FGj4DLe+6DFMb8R5Cq8zjR5NId3Poz10TMT3/XuCngXbRW8P5sZHpMK6
WkYo+SV4XP0h7hG6f97OfiSewNLpkPM9EzCk45Ijb6fdkCFiXwTqgRumfS80b3Eo7eHxA
donqKDTns7/IPBG8d2SZKql0t6tbc6BW8/q3t07P0JDF6gURNPWxuKx9hNAd5WWa8fnzb
+d9dkcWQVDyQm9z31JASyXyYmDzxfLemhF7TsQ1fZfRb0QBkBY4TerUbKbW4a4PMW10om
WkJSpD8r+y0jQLl0q7Z8loIySdkSKfKfGIaIUkLeyYu6dR0iac+g4z2kEw+8013agAA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1793915758;
h=X-Original-To:Received:DMARC-Filter:Received:Received:DKIM-Signature:
DKIM-Signature:X-DKIM2-Info:DKIM2-Signature:X-DKIM2-Info:
Message-Instance:X-ME-Sender:X-ME-Received:X-ME-Proxy-Cause:
X-ME-Proxy:Feedback-ID:Received:From:To:Cc:Subject:In-Reply-To:
References:Date:Message-ID:User-Agent:X-Mailing-List:List-Id:
List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
Precedence:MIME-Version:Content-Type;
bh=gWDBxdp7v3HeofEzGc9vuks/GHsWM2wvpOu0YkVHyM0=;
b=bQSFpmRw29HSEnlX0PWjLxQe1FvathHHcSYAm4lrPhTeP4mWFwAISujDxHubyfWhHMbY
Lc/bc4yrXSys7lvLpIdiQpYW9YfrEx0Jw2Q0JqDgoVF4SDWqffhvFfrW6iaWd9z499Hjy
qRe8jUjzja2fhW5YUuMeTB3XsXKmD1mSWT0yqfuT5ZqaBP8FDW90BLMeKCPWMdwdHXKY3
7FqPcxDufEk/SE5n1OFu463aieAbZH7WQxeixxMUYhYQ6z4nLswpV7f4dIfSdZ7WwTgrr
ixP/0HtfduD3LViWb6km8cDoZB6pTydr+MMXhUz3EKlyZPkEAuCOy8cmQOJHiQDFXnA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=pobox.com header.i=@pobox.com header.a=rsa-sha256 header.s=fm2 header.b=a+p5Nh+Y;
dkim=pass header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=va0pGdiL;
dmarc=pass header.from=pobox.com;
spf=pass smtp.mailfrom=pobox.com;
arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id 88D01606A329;
Thu, 5 Nov 2026 21:55:58 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key, unprotected) header.d=pobox.com header.i=@pobox.com header.a=rsa-sha256 header.s=fm2 header.b=a+p5Nh+Y;
dkim=pass (2048-bit key, unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=va0pGdiL
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=103.168.172.153
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1793915757;
b=S3zrOIXVjDv7iMdh02bCiTJDLXfMZG319p8CDHtv8ZQIdk/M/jqXtTSpne7QGgOaAsUs
Khu6+geDbI32hcBFx6nenfW6G6XktL4cssqiqybiwEHPSL1i7l3ONsIuQQ1gLJ7+385eV
MzS+exDxo5D09qso/nNRpMgaGYogYmrfluzRVVVTXTePI734qqVoUqb7F/T2++hh9L3x5
ymnnChHQ98Ne043GKB9kjKanWICeuF8iBpmzUNQWyo+suNFV6tAMOd0zsgmI5pfbqwEWr
RVU8AcTl/icHTznY0fKSeYXoyYTx/OM3BNa2FXkTCoJYPaPf9nr29vPRtQiYTl6n7ig==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1793915757;
h=DMARC-Filter:Received:Received:DKIM-Signature:DKIM-Signature:
X-DKIM2-Info:DKIM2-Signature:X-DKIM2-Info:Message-Instance:
X-ME-Sender:X-ME-Received:X-ME-Proxy-Cause:X-ME-Proxy:Feedback-ID:
Received:From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID:
User-Agent:MIME-Version:Content-Type;
bh=gWDBxdp7v3HeofEzGc9vuks/GHsWM2wvpOu0YkVHyM0=;
b=yxdCy6EIpX23cfUsZhjMOR0Df5YnD14NeTSGy01unm3+94x0x1yTV6b0559QK4spsup6
VNRuBE7j9gQdiY2tUxi8zHBPXbQ6ch42281wCRSLPhwCX2C2dikeFcdj3rxuAWujfA0VR
EaP876LzC0u7GAkH6LL703LxFMBagAunK0YF411cKXUYPKS9epRT1fBsIBApsk2XhWACD
Ev1imEgTl1y1H+T4AGrejl23ojJp8iu0qBaxpEeP96MufgtxurK4IRxdpvEqBgdnrr/jy
t3yg4ac6EzaZPKJvtvxb3KLhpctRGZZYSb0blAZSR8m73Z7DGI0MVQmYPDI9imCu2Ww==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=pobox.com;
spf=pass smtp.mailfrom=pobox.com;
dkim=pass header.d=pobox.com header.i=@pobox.com header.a=rsa-sha256 header.s=fm2 header.b=a+p5Nh+Y;
dkim=pass header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=va0pGdiL;
arc=none smtp.remote-ip=103.168.172.153
X-Received: from fhigh-a2-smtp.messagingengine.com (fhigh-a2-smtp.messagingengine.com [103.168.172.153])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange X25519 server-signature ECDSA (prime256v1))
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 21D25606A328
for <git@vger.kernel.org>; Thu, 5 Nov 2026 21:55:56 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 21D25606A328
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-02.internal (phl-compute-02.internal [10.202.2.42])
by mailfhigh.phl.internal (Postfix) with ESMTP id 578B31400135
for <git@vger.kernel.org>; Thu, 5 Nov 2026 16:55:56 -0500 (EST)
X-Received: from phl-frontend-01 ([10.202.2.160])
by phl-compute-02.internal (MEProxy); Thu, 05 Nov 2026 16:55:56 -0500
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=fm2; t=1793915756; x=1794002156; bh=gWDBxdp7v3
HeofEzGc9vuks/GHsWM2wvpOu0YkVHyM0=; b=a+p5Nh+YvCct+/0Mw4GSUVGAlh
meDHZoSGjJuSWKn1Np2jcv98x1zQQ6WZltu+QVuo7qDWhuOlK5R+d+5jRsC7OFVr
3hfBOLylH32joEuJDHVnvmanwCS1wByRZQtQJW/DtJvOsIIMkeT/g1ehNXPxE/4D
Au05gT/W6thv7/GcjdjEMxbOIaR5X3npbVeOGMENUAwGPhJdMaITuVpLBgYF5CIz
K/akdYoaqMACeunQ5LXs5YfvG9t/BJ6aKXKIp8RmmVn9XCy8FCZYXQmPFDtsps4r
Dvv4eHpg53Py3ONyp1RzJ6nNH6VGlnKUAqiHULjAJg5KKeI8YQlbUfwBLATw==
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=fm3; t=
1793915756; x=1794002156; bh=gWDBxdp7v3HeofEzGc9vuks/GHsWM2wvpOu
0YkVHyM0=; b=va0pGdiL+N7Jnb3SwLi5eBIzU4K7mR9jWmc/pPVsMg3xdufUe1b
GZ6mEBwEzqttoDLAG7SULBvfabUCSqfRVBY2bJRk/H4qmA8MkwJxkFbQwJaRBRhF
PvCFOigUU5u3IhfdcYbICE4EIo9VymVrzQklg/RFUdNlwOa01/CE311LxlzuBS8f
byfRphZs74hCdjD3Mr6AN1CI73BMd1rSGpMMQnmSPaueQVloLBeacAlf/XAkjMHA
yqk7LzbwqocFIaryS0Mvd77FPqaXY0x9tatECxf1GTPWcC3/5vkPAL6dg/VvEigx
4jZpsg403MmkcwB0gXmmdQ41x6EHy05vDeA==
X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09;
repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox;
action=sign d=pobox.com a=rsa-sha256;
X-DKIM2-Signature: i=1; m=1; t=1793915756; d=pobox.com;
mf=PGdpdHN0ZXJAcG9ib3guY29tPg==;
rt=PGdpdEB2Z2VyLmtlcm5lbC5vcmc+;
s=fm2:rsa-sha256:kFkrzv67BNHppavNIP3Ng5nSPmvPLeeFEdSaxZWkLUomGPy
AOsOEnMgCRUaqx8+ZjKKP88Sch/1/vCqLVKgKJZstzQAPNe2/cQz2yun9S3JAYiy
9YLdf5fwBq5b9aN6mi7N3ygbfY+E3w8IwJ2PSwX+kK5FlZlOew/cCkGT/YesyBWp
jBlCjF/0QJ8YJ5e9nfAHegeF0Y30nqRmDm+jRcAaC7xu9+GF+Z4T7KPoXuqIf/I5
M0cAvUpbYxO2uXcc161UkKQuRi9oBIlg4HJ2+M1hXrS2F3D3vRQ4TpMqH+vudB9d
Mr0VOzPucHHWycBUJUMeLCUY6Mmjc1Pl6l6YNXg==;
X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09;
repo=github.com/dkim2wg/interop; date=2026-11-03; 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:3xl8nZe+u6CctHeuTpOW+4QTdYRAFipJAHwHiS6tr9M=:c1G+S1rV1COijgfHPXcZq9fGElGmmUto8gIzctJH0as=;
X-ME-Sender: <xms:bPvsat8FavKw-559NhZ1OnQdyilYXj2YVl6QKjnqnCYhWXwaD1q9Hw>
<xme:bPvsaouaLaexZLAjZK1sGtWtYs7vgNCdUmv2CHnqxrwT5-LOlCdWZO7HMrdPOOxoS
fE72LB8-CLM1JEpTI0IxMvui2C95IlEFDJGdKhZJp6PaQudCOw7rMY>
X-ME-Received: <xmr:bPvsagC9UZcwJGye3EKCsn0kFnA0oAnZJ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pMa-oKz44S6-4>
X-Feedback-ID: if26b431b:Fastmail
X-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu,
5 Nov 2026 16:55:55 -0500 (EST)
X-Cc: git@vger.kernel.org, ιη°δΈθ
<kazumasa.shigeta@kanamei.com>
X-In-Reply-To: <b62d3d080a8ff0d9e14741a886aa45d70019bd64.1792767795.git.phillip.wood@dunelm.org.uk>
(Phillip Wood's message of "Fri, 23 Oct 2026 16:03:33 +0100")
X-User-Agent: Gnus/5.13 (Gnus v5.13)
X-Mailing-List: git@vger.kernel.org
X-List-Post: <mailto:git@vger.kernel.org>
X-List-Help: <mailto:git+help@vger.kernel.org>
X-List-Subscribe: <mailto:git+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:git+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:git+owner@vger.kernel.org>
X-Precedence: list