From patchwork Fri Dec 29 07:27:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13506351 Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) (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 5B57EBE76 for ; Fri, 29 Dec 2023 07:27:04 +0000 (UTC) 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="w96ZwXGY"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="NJlCe+u/" Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 7E9485C0175; Fri, 29 Dec 2023 02:27:03 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Fri, 29 Dec 2023 02:27:03 -0500 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=fm2; t=1703834823; x=1703921223; bh=jxVJ9rOYWm lnKgLPm14xSPG0U3p9OJSta0ABiogYLY8=; b=w96ZwXGYqklSXhA8glH6nUJpcD mpoBoXc33hj92/epnnJGsh8WDrb/Srl7o6u+lhy4xLZMGhivBL4O4tz4K2At/F03 Mg1knlPW18Or65U0OV/tv7z+6tGncbIjlUuuiNkHh5cJoyk5yKyXIx0J8OU1BmGX NYWu+F/oeV7sM7lpPNcX3C/tGsWQMIgEtyRNbpWfwGc61No6vAyx3+ulEaPTS235 izWXIO+I0R/NenGp7SDRdoSPYvKF7p9UCD2VqjrQAheqYGZ6dkCHA2Zbbbzgfzs6 lcKn50vekho36IDx4G8A4nE8Y7qtlnb+fM3iC7XyhW/s7tUllz0MikDDypvw== 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= fm2; t=1703834823; x=1703921223; bh=jxVJ9rOYWmlnKgLPm14xSPG0U3p9 OJSta0ABiogYLY8=; b=NJlCe+u/6HozPO7ic4SwLVFm5joRZV7CW3385yaiPNC2 FZd210dg1aRYCZuMmvs088tHkffnztdAfQm8ARwyjjJbGSKRL/qQjCuqYZv6WGzS ssqxMdpWo+5D3evj00Z+qd0FjB3KC/cZS4oMdXYSp1zsx+yEfAtNklPE0L9bbbTG kswIKIpNKVVz34Ar4092TmJ64DzegTJ2mBvKdnStdvHFtTBpsiq3qyPPXOyyA7Fg F01knbeYLggC3+QjVhmPhfExjjabgbHMVfj2vfIpl30j1ALsLpUSUN+8meaXhBGz 1nhAYvyOMGzZBHlqaV+KDppcOqWHCE90DMgZ8dRvtQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdefvddguddutdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvvefukfhfgggtuggjsehgtderredttddvnecuhfhrohhmpefrrght rhhitghkucfuthgvihhnhhgrrhguthcuoehpshesphhkshdrihhmqeenucggtffrrghtth gvrhhnpeeukedtvedtffevleejtefgheehieegkeeluddvfeefgeehgfeltddtheejleff teenucevlhhushhtvghrufhiiigvpedvnecurfgrrhgrmhepmhgrihhlfhhrohhmpehpsh esphhkshdrihhm X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 29 Dec 2023 02:27:02 -0500 (EST) Received: by vm-mail (OpenSMTPD) with ESMTPSA id d5100359 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Fri, 29 Dec 2023 07:24:46 +0000 (UTC) Date: Fri, 29 Dec 2023 08:27:00 +0100 From: Patrick Steinhardt To: git@vger.kernel.org Cc: Karthik Nayak , Junio C Hamano , Eric Sunshine Subject: [PATCH v3 09/12] builtin/rev-parse: introduce `--show-ref-format` flag Message-ID: <4ee3c9a2d169e5a8fa657531919f9b2833f2a1ac.1703833819.git.ps@pks.im> 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: Introduce a new `--show-ref-format` to git-rev-parse(1) that causes it to print the ref format used by a repository. Signed-off-by: Patrick Steinhardt --- Documentation/git-rev-parse.txt | 3 +++ builtin/rev-parse.c | 4 ++++ t/t1500-rev-parse.sh | 17 +++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.txt index 912fab9f5e..546faf9017 100644 --- a/Documentation/git-rev-parse.txt +++ b/Documentation/git-rev-parse.txt @@ -307,6 +307,9 @@ The following options are unaffected by `--path-format`: input, multiple algorithms may be printed, space-separated. If not specified, the default is "storage". +--show-ref-format:: + Show the reference storage format used for the repository. + Other Options ~~~~~~~~~~~~~ diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c index 917f122440..d08987646a 100644 --- a/builtin/rev-parse.c +++ b/builtin/rev-parse.c @@ -1062,6 +1062,10 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix) puts(the_hash_algo->name); continue; } + if (!strcmp(arg, "--show-ref-format")) { + puts(ref_storage_format_to_name(the_repository->ref_storage_format)); + continue; + } if (!strcmp(arg, "--end-of-options")) { seen_end_of_options = 1; if (filter & (DO_FLAGS | DO_REVS)) diff --git a/t/t1500-rev-parse.sh b/t/t1500-rev-parse.sh index 3f9e7f62e4..a669e592f1 100755 --- a/t/t1500-rev-parse.sh +++ b/t/t1500-rev-parse.sh @@ -208,6 +208,23 @@ test_expect_success 'rev-parse --show-object-format in repo' ' grep "unknown mode for --show-object-format: squeamish-ossifrage" err ' +test_expect_success 'rev-parse --show-ref-format' ' + test_detect_ref_format >expect && + git rev-parse --show-ref-format >actual && + test_cmp expect actual +' + +test_expect_success 'rev-parse --show-ref-format with invalid storage' ' + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + git config extensions.refstorage broken && + test_must_fail git rev-parse --show-ref-format 2>err && + grep "error: invalid value for ${SQ}extensions.refstorage${SQ}: ${SQ}broken${SQ}" err + ) +' + test_expect_success '--show-toplevel from subdir of working tree' ' pwd >expect && git -C sub/dir rev-parse --show-toplevel >actual &&