From patchwork Tue May 7 04:53:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13656232 Received: from fhigh1-smtp.messagingengine.com (fhigh1-smtp.messagingengine.com [103.168.172.152]) (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 7FBBA6A8C1 for ; Tue, 7 May 2024 04:53:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.152 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715057620; cv=none; b=rIdVrhcH9UML4J6kj33lS743dhsISLEKA5n3/Gw0rahUWDqXjruXBgY0tjtlLg8s8BrGAyDje8r+LoPDYkk8vXqCooGfwrSAT4rmE0KZziM1yclHfb5FaHhOR/soTBzQcmQEiFvR4HzR2YeQLsjI9bmqMJvdm70hi/dNAQgXnW0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715057620; c=relaxed/simple; bh=um/ZiYIjRyHmiatTbwJwRJ62jGVzBwK3/FD+Bf+i6Ys=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=sigArcvRelliaCIPJ8GQ33mlHf2TOl8gZnBsjpH8rQmEL3BXn7JaJNUyyeddj81Rgr30jsAmNoTW/hGqg7e5BC6DAElT5oanl2f6XpSw4PojZTOikUrhHV179H5J7yJSICsZ6SUWn6/hoAjKBFmEMGbW65muG2bCtahhpn2lNsg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none 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=tO993VDF; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=D28jrKob; arc=none smtp.client-ip=103.168.172.152 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none 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="tO993VDF"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="D28jrKob" Received: from compute7.internal (compute7.nyi.internal [10.202.2.48]) by mailfhigh.nyi.internal (Postfix) with ESMTP id D2A8311400BC; Tue, 7 May 2024 00:53:38 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Tue, 07 May 2024 00:53:38 -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=1715057618; x=1715144018; bh=YxvvcvgkVU OqrSf9YV8Wf5dWTkAsYFc8yeRTzteR+GU=; b=tO993VDF2f/v4jHJd/5NsM0IFD TRZlnzreFrLL6lCG+u8DyXcTj4mVSpzAzFHEbr2eSXCrWqC49AH0BHqRdtJZLpds d7ojjzccWchR4Y9Ff2ZjxtubshdHSAnDsfwz/JLoeWMBuW1XudxDPKUCjZjN8BBE rgBfXQZg92YV/icYMKpZ63szziN1pEZtKV5lnwi+aUauPEcNff9ACA20TJePDyRx v1Lt9vp0cmAr3jxbG944WgeHwbls1eeWIsRQvSOV4Wm9LW3SCLxUhOQ3N7fg8iLH eSbwEuw08sqUmwWGZQV6EqPtXB30V2dmSH5NX+MypZbNvR0R9GmLRN/XY+gQ== 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-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1715057618; x=1715144018; bh=YxvvcvgkVUOqrSf9YV8Wf5dWTkAs YFc8yeRTzteR+GU=; b=D28jrKobbnXb/2nI6IsfyUCjXeVssrQDlcwkP60vs3bd oDA+aJrAvC7z22NBwQc2AGNq6VXCKdpJutWUtF6T5jfVcz6hKsdAnsP6C9rOiF1p Yb9qPPxP5ESvorzzGq8179Dk27NWn2fgtCOEl1zl98wf0sAKSvf3jAO5ld+dwmoP q26XJGHqypgT29/infp7cG9mgVgQgIPAsnw1GYLrAt+a4bs57I5qycIzT5MY5N/C Xwshfs0tXrSUyCHFDh1Ehbkji1jLxvbCjMtwmJl0LPPFw88R1VAsgomXaYc+I1F4 FehgEyou9ao8qUNyUg8xsv0rnqCgs7ZpDFK2D4N1pw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvddvjedgkeefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesghdtreertddtvdenucfhrhhomheprfgrthhr ihgtkhcuufhtvghinhhhrghrughtuceophhssehpkhhsrdhimheqnecuggftrfgrthhtvg hrnhepueektdevtdffveeljeetgfehheeigeekleduvdeffeeghefgledttdehjeelffet necuvehluhhsthgvrhfuihiivgepfeenucfrrghrrghmpehmrghilhhfrhhomhepphhsse hpkhhsrdhimh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 7 May 2024 00:53:37 -0400 (EDT) Received: by localhost (OpenSMTPD) with ESMTPSA id 009af09f (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 7 May 2024 04:53:30 +0000 (UTC) Date: Tue, 7 May 2024 06:53:35 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Cc: Junio C Hamano , "brian m. carlson" , Justin Tobler Subject: [PATCH v4 11/13] builtin/shortlog: don't set up revisions without repo Message-ID: References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: It is possible to run git-shortlog(1) outside of a repository by passing it output from git-log(1) via standard input. Obviously, as there is no repository in that context, it is thus unsupported to pass any revisions as arguments. Regardless of that we still end up calling `setup_revisions()`. While that works alright, it is somewhat strange. Furthermore, this is about to cause problems when we unset the default object hash. Refactor the code to only call `setup_revisions()` when we have a repository. This is safe to do as we already verify that there are no arguments when running outside of a repository anyway. Signed-off-by: Patrick Steinhardt --- builtin/shortlog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/shortlog.c b/builtin/shortlog.c index 3c7cd2d6ef..d4daf31e22 100644 --- a/builtin/shortlog.c +++ b/builtin/shortlog.c @@ -434,9 +434,9 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix) error(_("too many arguments given outside repository")); usage_with_options(shortlog_usage, options); } - if (setup_revisions(argc, argv, &rev, NULL) != 1) { + if (!nongit && setup_revisions(argc, argv, &rev, NULL) != 1) { error(_("unrecognized argument: %s"), argv[1]); usage_with_options(shortlog_usage, options); }