From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fhigh-a7-smtp.messagingengine.com (fhigh-a7-smtp.messagingengine.com [103.168.172.158]) (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 A1E4C42AFB7 for ; Wed, 12 Aug 2026 11:22:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.158 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786533752; cv=none; b=e9HufGfos/PZ5WaxkXB7cg9B7RmhEacW54trb39traP6OvtB1i4apRax5pSq1VrkQxL2p2GFC761OHI7q4rbuU0EwfPBDUxUtbPKmM7YGsL1aMN5MaNcq2ReVTe+tE1Z4ADzeUXguPvuWvUyN8/2KL3PtaB3tr3/UT9xlZZqjII= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786533752; c=relaxed/simple; bh=eYNQ5a0LpGFEasaPtT6VUjBxnBqbgu4JawShbkvrWe0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=R2jM0vrl0/2oUfbNbI2dRfwZora+LfFLl9TvpR468pDPLMw6cSKDEb74YmBZis96e0ZfqOCza3hxCLqRusBVSBq6pfYrozokij0haMu4qReKUU6YgXtGJLi//9PfPHdbu5x5C8ZtDnxDSdN9J1yjk/4aWEQeUjQ928MMDwp55F4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=ho3p3ngF; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=M2R9VMhR; arc=none smtp.client-ip=103.168.172.158 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="ho3p3ngF"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="M2R9VMhR" Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfhigh.phl.internal (Postfix) with ESMTP id B5DAB140017E; Wed, 12 Aug 2026 07:22:29 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-06.internal (MEProxy); Wed, 12 Aug 2026 07:22:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; 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=fm3; t=1786533749; x=1786620149; bh=rPKs/D19C1 HHcDXX6eQCm/uAbSlgNHlEh1cq7/Kn0pk=; b=ho3p3ngFWcOD0DXpMFSyy5D2Ln GuYAe1J0+eu+68IdQrR5Ir7jnt//lHi4KRj28Ir8PtdVxDcOP8ZvIn2gdLG9A2HI msnATr0bnosKKeJYdlxpG2M6BKaPvZr8fQ3oxM+yJiHlxSjoFOf6aKe0J1+/i5hy q2MbgMDiFhVY6qAnltnbmFTD0qxzSApwfydjOUGBytt8uu3VvZ9FlM+/52PMRh8b 39Q/s97YUeqVJYbuJhiKmvczEleD1vMaewobSpw1eKiMPLuz1fYyGELax86QxOoJ pg4/2jK+1Mm1Wp3uIf24phQZtwQKhCDQKVD7rOyskqF24SmZC45ZFkh5Qm3g== 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= 1786533749; x=1786620149; bh=rPKs/D19C1HHcDXX6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v4mof3tlm2G9SGcXlCmwvmyuNA X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 12 Aug 2026 07:22:28 -0400 (EDT) Received: by mail (OpenSMTPD) with ESMTPSA id 1de8cc1c (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Wed, 12 Aug 2026 11:22:25 +0000 (UTC) Date: Wed, 12 Aug 2026 13:22:22 +0200 From: Patrick Steinhardt To: Christian Couder Cc: git@vger.kernel.org, Junio C Hamano , Elijah Newren , Jeff King , "brian m . carlson" , Johannes Schindelin , Justin Tobler Subject: Re: [PATCH] git: avoid segfault on "git --shallow-file" without a value Message-ID: References: <20260811121446.2080190-1-christian.couder@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260811121446.2080190-1-christian.couder@gmail.com> On Tue, Aug 11, 2026 at 02:14:46PM +0200, Christian Couder wrote: > diff --git a/git.c b/git.c > index e5f1811b6b..96df15b5cd 100644 > --- a/git.c > +++ b/git.c > @@ -304,11 +304,15 @@ static int handle_options(const char ***argv, int *argc, int *envchanged) > if (envchanged) > *envchanged = 1; > } else if (!strcmp(cmd, "--shallow-file")) { > - (*argv)++; > - (*argc)--; > - setenv(GIT_SHALLOW_FILE_ENVIRONMENT, (*argv)[0], 1); > + if (*argc < 2) { > + fprintf(stderr, _("no file given for '%s' option\n" ), "--shallow-file"); > + usage(git_usage_string); Should we maybe condense this into a single line? usage(_("no file given for '%s' option\n")), "--shallow-file") I think that also printing the usage string is only distracting and doesn't really give the user a lot of extra context. Other than that this patch looks good to me, thanks! Patrick