git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Patrick Steinhardt <ps@pks.im>
To: git@vger.kernel.org
Cc: "Ronan Pigott" <ronan@rjp.ie>, shejialuo <shejialuo@gmail.com>,
	"René Scharfe" <l.s.r@web.de>
Subject: [PATCH 1/2] t1305: exercise edge cases of "onbranch" includes
Date: Tue, 24 Sep 2024 12:05:42 +0200	[thread overview]
Message-ID: <615df98339e9451bc237decea087716ca15d157d.1727171197.git.ps@pks.im> (raw)
In-Reply-To: <cover.1727171197.git.ps@pks.im>

Add a couple more tests for "onbranch" includes for several edge cases.
All tests except for the last one pass, so for the most part this change
really only aims to nail down behaviour of include conditionals further.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 t/t1305-config-include.sh | 40 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/t/t1305-config-include.sh b/t/t1305-config-include.sh
index 5cde79ef8c4..ad08db72308 100755
--- a/t/t1305-config-include.sh
+++ b/t/t1305-config-include.sh
@@ -357,4 +357,44 @@ test_expect_success 'include cycles are detected' '
 	grep "exceeded maximum include depth" stderr
 '
 
+test_expect_success 'onbranch with unborn branch' '
+	test_when_finished "rm -rf repo" &&
+	git init repo &&
+	(
+		cd repo &&
+		git config set includeIf.onbranch:"*".path config.inc &&
+		git config set -f .git/config.inc foo.bar baz &&
+		git config get foo.bar
+	)
+'
+
+test_expect_success 'onbranch with detached HEAD' '
+	test_when_finished "rm -rf repo" &&
+	git init repo &&
+	(
+		cd repo &&
+		git config set "includeIf.onbranch:*.path" config.inc &&
+		git config set -f .git/config.inc foo.bar baz &&
+		test_commit initial &&
+		git switch --detach HEAD &&
+		test_must_fail git config get foo.bar
+	)
+'
+
+test_expect_success 'onbranch without repository' '
+	test_when_finished "rm -f .gitconfig config.inc" &&
+	git config set -f .gitconfig "includeIf.onbranch:**.path" config.inc &&
+	git config set -f config.inc foo.bar baz &&
+	git config get foo.bar &&
+	test_must_fail nongit git config get foo.bar
+'
+
+test_expect_failure 'onbranch without repository but explicit nonexistent Git directory' '
+	test_when_finished "rm -f .gitconfig config.inc" &&
+	git config set -f .gitconfig "includeIf.onbranch:**.path" config.inc &&
+	git config set -f config.inc foo.bar baz &&
+	git config get foo.bar &&
+	test_must_fail nongit git --git-dir=nonexistent config get foo.bar
+'
+
 test_done
-- 
2.46.0.551.gc5ee8f2d1c.dirty


  reply	other threads:[~2024-09-24 10:05 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-20 17:37 BUG: refs.c:1933: reference backend is unknown Ronan Pigott
2024-09-21 16:09 ` shejialuo
2024-09-21 18:06   ` Ronan Pigott
2024-09-21 21:22     ` René Scharfe
2024-09-22  6:51       ` shejialuo
2024-09-22 14:41         ` shejialuo
2024-09-24 10:05 ` [PATCH 0/2] config: fix evaluating "onbranch" with nonexistent git dir Patrick Steinhardt
2024-09-24 10:05   ` Patrick Steinhardt [this message]
2024-09-24 16:05     ` [PATCH 1/2] t1305: exercise edge cases of "onbranch" includes Junio C Hamano
2024-09-24 10:05   ` [PATCH 2/2] config: fix evaluating "onbranch" with nonexistent git dir Patrick Steinhardt
2024-09-24 14:11     ` shejialuo
2024-09-24 16:17     ` Junio C Hamano
2024-09-24 14:20   ` [PATCH 0/2] " shejialuo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=615df98339e9451bc237decea087716ca15d157d.1727171197.git.ps@pks.im \
    --to=ps@pks.im \
    --cc=git@vger.kernel.org \
    --cc=l.s.r@web.de \
    --cc=ronan@rjp.ie \
    --cc=shejialuo@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).