🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.git
Article #1788

[Outreachy PATCH v2 1/2] fast-import: handle --git-completion-helper before reading input

#1788
From: Tanga Joris
Date: Thu, 29 Oct 2026 01:26
61 lines
12996 bytes
fast-import parses its options only after reading the "feature"
lines from its input, and it creates a temporary pack file before
that. So "git fast-import --git-completion-helper" waits for input,
and each run leaves a tmp_pack_* file behind.

bash completion runs the helper with the terminal as input, so
"git fast-import --<TAB>" would freeze once fast-import is no
longer marked with the NO_PARSEOPT flag.

Handle a lone --git-completion-helper or --git-completion-helper-all
right after the -h check, before creating the pack or reading input.

Reported-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Tanga Joris <tangajoris@gmail.com>
---
Changes since v1:
 - New patch 1/2, addressing René's observation that completion would
   block on fast-import
 - 2/2 is unchanged

 builtin/fast-import.c  | 4 ++++
 t/t9300-fast-import.sh | 8 ++++++++
 2 files changed, 12 insertions(+)

diff --git a/builtin/fast-import.c b/builtin/fast-import.c
index 9db3f83eea..f53113d5a5 100644
--- a/builtin/fast-import.c
+++ b/builtin/fast-import.c
@@ -4204,6 +4204,10 @@ int cmd_fast_import(int argc,
 	};
 
 	show_usage_with_options_if_asked(argc, argv, fast_import_usage, fast_import_options);
+	if (argc == 2 && (!strcmp(argv[1], "--git-completion-helper") ||
+			  !strcmp(argv[1], "--git-completion-helper-all")))
+		parse_options(argc, argv, prefix, fast_import_options,
+			      fast_import_usage, 0);
 
 	fast_import_state_init(&state, argc, argv, prefix, fast_import_options);
 
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 73c6e3d448..99d7843217 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -2914,6 +2914,14 @@ test_expect_success 'R: blob appears only once' '
 	test 1 = $n
 '
 
+test_expect_success 'R: --git-completion-helper does not read from stdin' '
+	find .git/objects/pack -name "tmp_pack_*" >before &&
+	echo garbage | git fast-import --git-completion-helper >out &&
+	test_grep -e "--date-format=" out &&
+	find .git/objects/pack -name "tmp_pack_*" >after &&
+	test_cmp before after
+'
+
 ###
 ### series S (mark and path parsing)
 ###
-- 
2.56.0.291.g0b48760bf4
Technical Details
Message-ID: <20261029012616.139783-1-tangajoris@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-73710-linux-kernel-git=dewy.ru
References: <20261024052449.95869-1-tangajoris@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-73710-linux-kernel-git=dewy.ru
From: tangajoris@gmail.com (Tanga Joris)
Newsgroups: linux.kernel.git
Subject: [Outreachy PATCH v2 1/2] fast-import: handle --git-completion-helper before reading input
Date: Thu, 29 Oct 2026 04:26:15 +0300
Organization: Usenet Network
Message-ID: <20261029012616.139783-1-tangajoris@gmail.com>
References: <20261024052449.95869-1-tangajoris@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1910017"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:XqCNHCfivxDKsgRDVFc0i5LAifs= sha256:UniRYUC9cUjigBoDLMalzAjJPcsGAEHxUh7xJ4z0vu4=
	sha1:+kRP+qvkfotpVaRfQTZJurJpCYU= sha256:T6DGCbJcOT7C5NG6+DStVHGvys+ga132r23ACC6KcQk=
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 403D7125C51; Thu, 29 Oct 2026 04:29:28 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -2.047
X-Spam-Status: No, score=-2.047 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, FORGED_GMAIL_RCVD=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,
	URIBL_BLOCKED=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 JSxOxLfuwDDs;
	Thu, 29 Oct 2026 04:29:24 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=git+bounces-73710-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 25C82125C4D; Thu, 29 Oct 2026 04:29:15 +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 E614D28A82; Thu, 29 Oct 2026 01:28:40 +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=1793237320;
	b=MseHnyemck2v0KaBQkeS0CAni12bdmGhl0ZsYQKXNZ28Ms4Unp609oVAl0XJUb2eaO4P
	 MIg4Hfiomt6SbfNIW+G6XmSKUf7O2Iz/VznN3vzPJzldHEAgVKwQukvo6tal4u7UG805l
	 KyMzE+D/BJUy0rG9Cab04QNSG1Rk5DUWRTBwuC3d9w1MGaHvE7SSGII+V6NfVmfhIDhu2
	 a5DXzFxTZ36zI+XWBMLL0vIPBwpq5LdOxAz9OEC7abr0cep4frr+HMKiQ31kZYb15fGjr
	 +aW+y3YdnklPZCP7svyHc+4cZJLV2BWwNbgYomzpX5LMEeRXrRabSmoH+Zhbvl30Lxg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793237320;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
	 X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
	 Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:
	 References:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type:
	 Content-Transfer-Encoding;
	bh=xv7sbkMVcbslMZLnsvxC0AhqN52qkDKxRsjdDm9QkmM=;
	b=vKu37+8Cj3X8c4zNYxWLi4ZKoPWbLm/orX7zd9Rr4eUTIqVceN6mD6IE1kpOWGuAD9g8
	 kwrLcSV2AM29MOo01Rw70s5/ugtLkzQr1fKoSP6RWvORK0pZ8xDQI3oYrUS2aFkXlY/o6
	 O/Se/oKAiErhlHuc6tlAlUf1dn5bC3hpl3s2Aq92RlqYozcqy8ABztLHiJXo3Kemhp5co
	 ZdLMhNYLV32fu8I8oO8xHvoqeWcQd3Ono15IJ2SZMppBN892qLC3U+kEuw2uqQebex6dH
	 OmOV1z+NV1hOHXNJJIeCKbilX6FXdKhgxMbTJ8C2kd/1YxjzvJ1ZNORfYS9eHqi4ONw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=IvsVwk4w;
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.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 BAE66606A324;
	Thu, 29 Oct 2026 01:28:40 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=IvsVwk4w
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.46
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1793237319;
	b=tmrcoDgsHXGMLrjFNo8Pi5tPtP5n015SD8kmXpe77wsgPhF90FGmf7R22zrvCQmjea3U
	 Tp0LcQBhD8M4wFqVpOBkpmsTNHslrJxq2oBHc9iZj5yiE9sachwnpIaMqiQ/PwdvTYhKv
	 G3zKE4hADX/2D8lBnnsFxefEgseZg5YAxPXnW3vsSF3aDpUvMTbV63akvZsJUeonGA6i9
	 Shf5jbKQsjJanvw4tUj2TbkhhV+YtETnGq6PlyNECkzwardGjMkco2pUGTUQ/DqJq8Y7e
	 zrc4txp5QIjoT7ilZAnwzlbhYuVxbzY6w4l3qg4qXG8/eQaaCXjWsM/Kz71XRGED7ag==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793237319;
	h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
	 X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:
	 Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version:
	 Content-Type:Content-Transfer-Encoding;
	bh=xv7sbkMVcbslMZLnsvxC0AhqN52qkDKxRsjdDm9QkmM=;
	b=WgfGRDsjcqkvhgVEApSU98+A4h3RkGlW+SMjAoEfsGF2a+8aXT9CfGjClDYV3MB4VuS0
	 C/PiwQbbwCyxsooduUE4TqpOLOKhzlIbYDcSxdpq0hxd6tHmxrGPBe7Q0Yug5lw3TGcso
	 kzwZtVmxziDgaPjqv5NHfq5Zgjdk7yyzVe3jjOR4z8dq2ikXThZHVYjH56NyKWcNdvveP
	 QM9qi4BohlsN9/i+cOY4wph8V15GemAF7duqk9MiB/gZuOGf+Y+HWFdwqqdkxNIi+mrDt
	 l2PeYMu3XZKYzkC73zF5oFM2Rc0tJ/E8pzQhISRP9WSGe+rgDcTWrlaPKfi9YzI2Gug==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=IvsVwk4w;
	arc=none smtp.remote-ip=209.85.221.46
X-Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 83886606A31E
	for <git@vger.kernel.org>; Thu, 29 Oct 2026 01:28:39 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 83886606A31E
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-wr1-f46.google.com with SMTP id ffacd0b85a97d-48afbd2c386so941168f8f.3
        for <git@vger.kernel.org>; Wed, 28 Oct 2026 18:28:39 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20260707; t=1793237318; x=1793842118; darn=vger.kernel.org;
        h=content-transfer-encoding:content-type:mime-version:references
         :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject
         :date:message-id:reply-to:content-type;
        bh=xv7sbkMVcbslMZLnsvxC0AhqN52qkDKxRsjdDm9QkmM=;
        b=IvsVwk4wETxx0bt/ZUXTNLVFqaTTD97hG9xZmJVPfy8tOgzncOo2kcrfETvHtvfH0w
         8+6Jra8qNDQ764sP2QCMOHuxz8tLdinp2IIJwqGyS4ul4D6bb+W8v1LUd4Fo4Q76ABjM
         eX+Xvo5cxJXAD13YYESBuBt+Lnsx0F6uh43ocdO1GzwuQQ8P4y2QBiGCSVDedJU/VFmy
         I7inoEmerRKzfgcsMlP1u4/6Rmhv6bB9S/ctNGl8Mp1B03wdzGsBm1S42vV/Eq2omB4i
         91uHfLCkg6GJwYqcLvgtiZDGncBxeJcscUikjARE0gugD/owBorm+ncWdiCa2c+Uoycl
         jAZA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1793237318; x=1793842118;
        h=content-transfer-encoding:content-type:mime-version:references
         :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg
         :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to
         :content-type;
        bh=xv7sbkMVcbslMZLnsvxC0AhqN52qkDKxRsjdDm9QkmM=;
        b=qu1xQ/1dP+R4Cx+G+S5/bDPzaTlsfI3qvD9RyNqAll4ekBDqLJQwCmXokXU46piKfa
         MJ45u1RwTQ4aNTOX2rh/edurtR+WO6yHzRbArKhWZ8FQ2gYKa8CNnbGE4mZM+qlN3wri
         ZhDQLK4UAPwB9Ox97grAhUIYR7vvvf8UY1UF/ogJJk+4HyoDDtby8oWap2eBiatc1hyx
         AyWHNBwxYXFFwmYTdk1vcz01uWmu4YDmauRK1d5K5qjnjl30VQ/Z/RJABq9bkLLbXxcM
         OiuD7T2kknMWpFN5i3azJO0QPzvuho7PFHRROcWqIxhOcRgSpcKB9ygJ/KTB09Q0FtUV
         8Vog==
X-Gm-Message-State: AFq9FYL1XoPYv1wIIs8F7wb49xxJhVBh4OMFohWPTacbiVqOBq/UUCyt
	N0bCAVjPOzddB0Q0w66H3CC/4w6y3rp4Ng4pZeaBa4+TG60rxLLVw//KVZRMhlpQ
X-Gm-Gg: AYBFou1UmIis/dTPeCxqGmSJGEnnxvShr6VASSS8GJW6H+m2fGufD5GbZUIrmafOjld
	LRJIy97dM5L+ccjvydr4BxENV2XqP0zztVXrAGzCL7m8PPnWBRTjZdMfjjyzk17nAQuhqE3exKf
	tCnnh9YwIRqDYxeX26mMogrvkUMPKekcJcGDVP1uXv0O60qRpsS0lPpKBnBY/55hbNsLxkeYeLu
	1MlUJUhOP5wpqo+9nM1EAl0GXriqnc6lEnVzv0X0V6ZW3s/dbZ9wYkgb77kjyWlbX1vhVELq2At
	ElFwjPnehEfb3AzpycAwmo+UPseUSYsVDaK25XzKIRcYe2ZQwY1veG+0owmuFjpo/2GAT3arvQf
	/ZJYEZV3WylyrSIg2ufp+rbQKmm9wFuuwKZVV50pi8ECxOFghcjhgks49yRhVSrNH2Hk5RSSzG0
	eesPoysFm1uChfKeZcLr7jPSp01Cj7R4Jlli4eIVXHyyclCzIPD/pTP/OjWV7i4G/w/r0pt7wNK
	mhFkPTsBAEk+LfNB0Y9PqROk7Nqpkoval6jQU9cieaX6PhvJxZJjvWwBSKK4p+jf3hg/7urCDFD
	Z8GKUnb4RYKAuWe1M1xWl7Gz+sGKJKrlR8qCZxXaW7g1vphiykADNhAyO4f68ot+YV7aVZe33Rz
	c59IGK3TXkZJRlc/ldZZY6SinFw00vyQ=
X-Received: by 2002:adf:f0c6:0:b0:48c:7143:610c with SMTP id ffacd0b85a97d-48e5d5d0a49mr7758265f8f.36.1793237317847;
        Wed, 28 Oct 2026 18:28:37 -0700 (PDT)
X-Received: from HP ([105.163.2.5])
        by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e3ebc39b3sm32311325f8f.10.2026.10.28.18.28.34
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Wed, 28 Oct 2026 18:28:37 -0700 (PDT)
X-Cc: l.s.r@web.de,
	gitster@pobox.com,
	christian.couder@gmail.com,
	siddharthasthana31@gmail.com,
	kaartic.sivaraam@gmail.com,
	usmanakinyemi202@gmail.com,
	Tanga Joris <tangajoris@gmail.com>
X-Mailer: git-send-email 2.56.0.291.g0b48760bf4
X-In-Reply-To: <20261024052449.95869-1-tangajoris@gmail.com>
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