🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.git
Article #741

[PATCH v3 4/5] worktree repair: reduce .git file reads

#741
From: "Yoichi NAKAYAMA via GitGitGadge...
Date: Sat, 17 Oct 2026 12:55
55 lines
9662 bytes
From: Yoichi NAKAYAMA <yoichi.nakayama@gmail.com>

Pass the loaded contents of the .git file to infer_backlink().

Signed-off-by: Yoichi NAKAYAMA <yoichi.nakayama@gmail.com>
---
 worktree.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/worktree.c b/worktree.c
index 3627dbc044..879941a977 100644
--- a/worktree.c
+++ b/worktree.c
@@ -806,27 +806,20 @@ static int is_main_worktree_path(struct repository *repo, const char *path)
  * Returns -1 on failure and strbuf.len on success.
  */
 static ssize_t infer_backlink(struct repository *repo,
-			      const char *gitfile,
+			      const char *dotgit_contents,
 			      struct strbuf *inferred)
 {
-	struct strbuf contents = STRBUF_INIT;
 	const char *id;
-	int err;
 
-	err = read_gitfile_raw(&contents, gitfile);
-	if (err)
-		goto error;
-	id = get_worktree_id(contents.buf);
+	id = get_worktree_id(dotgit_contents);
 	if (!*id)
 		goto error;
 	repo_common_path_replace(repo, inferred, "worktrees/%s", id);
 	if (!is_directory(inferred->buf))
 		goto error;
 
-	strbuf_release(&contents);
 	return inferred->len;
 error:
-	strbuf_release(&contents);
 	strbuf_reset(inferred); /* clear invalid path */
 	return -1;
 }
@@ -877,7 +870,7 @@ void repair_worktree_at_path(struct repository *repo,
 	}
 
 	dotgit_contents = contents.buf;
-	infer_backlink(repo, dotgit.buf, &inferred_backlink);
+	infer_backlink(repo, dotgit_contents, &inferred_backlink);
 	strbuf_realpath_forgiving(&inferred_backlink, inferred_backlink.buf, 0);
 
 	if (is_absolute_path(dotgit_contents)) {
-- 
gitgitgadget
Technical Details
Message-ID: <e35285a4ea5a5f7b11cd112df841948e9a0a3ab9.1792241702.git.gitgitgadget@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-72312-linux-kernel-git=dewy.ru
References: <pull.2225.git.1789269613.gitgitgadget@gmail.com> <pull.2225.v3.git.1792241702.gitgitgadget@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-72312-linux-kernel-git=dewy.ru
From: gitgitgadget@gmail.com ("Yoichi NAKAYAMA via GitGitGadget")
Newsgroups: linux.kernel.git
Subject: [PATCH v3 4/5] worktree repair: reduce .git file reads
Date: Sat, 17 Oct 2026 12:55:01 +0000
Organization: Usenet Network
Message-ID: <e35285a4ea5a5f7b11cd112df841948e9a0a3ab9.1792241702.git.gitgitgadget@gmail.com>
References: <pull.2225.git.1789269613.gitgitgadget@gmail.com>
	<pull.2225.v3.git.1792241702.gitgitgadget@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3043619"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:yfCrxUKEtfp/ld5fxq2ZsUkoQq4= sha256:SABJlxK2TI28NOvLk/SM8lzvTx7iOMzn1qV1jDW5OmE=
	sha1:HMwGh58unNf3OEs0El3T0Ibc5Iw= sha256:t+w+Qm4pS72HMJx2YmodRmHrGNQ9OIY5esAwu4TyZWU=
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 555A31106E3; Sat, 17 Oct 2026 15:55:49 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -1.948
X-Spam-Status: No, score=-1.948 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.25,
	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 7aM8I6ah1bs7;
	Sat, 17 Oct 2026 15:55:47 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=git+bounces-72312-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 064BD1106DE; Sat, 17 Oct 2026 15:55:38 +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 1F92F36215; Sat, 17 Oct 2026 12:55:20 +0000 (UTC)
X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 774BF3C8C68;
	Sat, 17 Oct 2026 12:55:13 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="sSIaFnHK"
X-Received: from mail-qt1-f174.google.com (mail-qt1-f174.google.com [209.85.160.174])
	(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 3FD63492E24
	for <git@vger.kernel.org>; Sat, 17 Oct 2026 12:55:11 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.174
X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1792241712; cv=none; b=SLDAziVvm08y45TWepGDvv9EA738oedupndSvqup+MWf+RmrVwEqVfsmHo0J69NF91d7s0+KeublUDHtMS5cH6wjIzFdw6B3Zvv/6Fq0snTdVYDW2MsrB6KtrdKhnl23AbcEAyKaFvvGl6JKbpWb2SZT2w0g+DbM/XW29cNsDcU=
X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1792241712; c=relaxed/simple;
	bh=PyRc/KyDgnJrxFyd76PSRpGHCtanp2IIOLbmtOg7IgE=;
	h=Message-Id:In-Reply-To:References:From:Date:Subject:Content-Type:
	 MIME-Version:To:Cc; b=hfPfHqLUEwcr28Bk50UKXggZm6Aj4P5wsmIlPtoP0rnLCfYwRUBss6+/1W9yg1E4ybvDIqJ8/eMoRmMZvIXyKieqs1zPLk/JhU3wRfHdQAH+WZynKEK/LPRKZjXn0OuK7zHuxQFxAIDbHURo3u/eCNoiBqAosnbQoyUuPydBTiM=
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=sSIaFnHK; arc=none smtp.client-ip=209.85.160.174
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-qt1-f174.google.com with SMTP id d75a77b69052e-5351748222cso5527411cf.1
        for <git@vger.kernel.org>; Sat, 17 Oct 2026 05:55:11 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20251104; t=1792241710; x=1792846510; darn=vger.kernel.org;
        h=cc:to:mime-version:content-transfer-encoding:content-type:fcc
         :subject:date:from:references:in-reply-to:message-id:from:to:cc
         :subject:date:message-id:reply-to:content-type;
        bh=MTIYfxBv/0zKkgIT6woxe+FX0VFaukjCklSCHYMho8E=;
        b=sSIaFnHKGVcjxSS8iITNzgxdR0UboAYqFuYTZdtv9SjF83ercnwOoh2G9mM6hzJqdB
         552NpMKq9UZg5n4apzT6eKAO+ENqEFLtqjEBzGFyVhTrRSE1MMjOsjl4/FDm635MeHt9
         dnScSv5dXUGx+z7FcQnaXHdT2AJFceFPaCCl5BQ4oDbtdXKI/AD5AHxSpuH2YCz4ti3s
         GtMU2V14yfnvhFffunGTRtZDdSuZtwHWu8fwpGotMZAGLdDL68tG2n64XuyIERYBJUGz
         WGwqAiqHxd9diaJK9wjrkQkhdBPr36RB/htck6RCQh6RZRmHeq/YPgxP+4ziGWhVKQhg
         7ZTQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1792241710; x=1792846510;
        h=cc:to:mime-version:content-transfer-encoding:content-type:fcc
         :subject:date:from:references:in-reply-to:message-id:x-gm-gg
         :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to
         :content-type;
        bh=MTIYfxBv/0zKkgIT6woxe+FX0VFaukjCklSCHYMho8E=;
        b=aQzZpfbA7T7vPKrQqlU3BG1PVB32tnVFXSsKjyCoKaTm95XzUc+Sox0IFke1QrNeSO
         G4gaqYs9v95WVxJlEAcXa+9mgGJFC8ey1ZdYYfhXffLgH35T4/94+7w1FPnrgyEwkV9J
         ui4wyEf+hf7iYlOm6BGmFR8ttHHKLdGKzmx2MgxJQVN+7dBw05LkEc5yYnp68wB7diRt
         IJ89ReUpb0QB49f910+XWxkMI0e9AqMMikiW/1vh+EqsrfF2SBg8L3fbke4xE0nhETVJ
         bUxeNHbX6Mxks3SpQXlupXH04Zvwv6o9qCUHkDQx5IGusGr/0A6uRIUz2hMSIQakmR/K
         rf1A==
X-Gm-Message-State: AFq9FYLpkRx/u39D2an7Lo+VlB9pqc1x7DCa31AGDSS5KpJekSYtC9jk
	gN/w6sInfAfd1xgyZtlEjeOebbo0QqlRzAgJTmtdrTaq+uRcV8TZKcQb3BvSN9H+
X-Gm-Gg: AYBFou1Tqa8dgek5ijqWLg70TAavGrAcmcB7JFJibG3iOOXiWZppnF0oaqY6GhWJ8XG
	8WWXbBkmSwruAVgjqDtoxGUg+9nIwLjqALfTbhzV5ZVVXIkD5k+OcLwmjiACe5XOJ6geWzSHTDg
	Sh/HHP0ubz4LcscMUxOPrn7mLofFdorQ/hxXAJrNjCEJDNdWP/t1XxOi/ODxg7y75H0D/mQl2qt
	aPrQxuEs+PjVST8JGOblm/3EIkJG+QJbXeRSLCva242NR15g9RAw+hv0XaRpAEV16lh1qwiuYU3
	N3Fu0vdcoGAdRwUUTE1KHrgWPqbRZJTt6IG3ngUr1A2KnmohHNuPOej6I9OLDwj2yunJ5I03GD1
	EVG6osSssFKf4DurioHUD71RUh7h3D5eeQNoVuaa/bdhgVAJzGUvRMKDsH94lwdJy+3wCO+7Vgh
	3WIM17DY2WLxkBwqs4sey3N75tA+iP/aHFlDkacPyunRfq15vyI3hBXcdBz1JbQ0EFwUOC6RYX9
	5k=
X-Received: by 2002:a05:620a:a2c4:20b0:93f:2ed6:1f3a with SMTP id af79cd13be357-93f2ed61fecmr123518685a.49.1792241710053;
        Sat, 17 Oct 2026 05:55:10 -0700 (PDT)
X-Received: from [127.0.0.1] ([52.152.180.199])
        by smtp.gmail.com with ESMTPSA id 6a1803df08f44-91bcedd6952sm42659996d6.39.2026.10.17.05.55.08
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Sat, 17 Oct 2026 05:55:08 -0700 (PDT)
X-In-Reply-To: <pull.2225.v3.git.1792241702.gitgitgadget@gmail.com>
X-Fcc: Sent
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-Cc: Eric Sunshine <sunshine@sunshineco.com>,
    Yoichi NAKAYAMA <yoichi.nakayama@gmail.com>,
    Yoichi NAKAYAMA <yoichi.nakayama@gmail.com>,
    Yoichi NAKAYAMA <yoichi.nakayama@gmail.com>