git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: larsxschneider@gmail.com
Cc: git@vger.kernel.org, sschuberth@gmail.com,
	ramsay@ramsayjones.plus.com, sunshine@sunshineco.com,
	hvoigt@hvoigt.net, sbeller@google.com
Subject: Re: [PATCH v3 3/3] config: add '--show-origin' option to print the origin of a config value
Date: Sat, 13 Feb 2016 13:04:13 -0500	[thread overview]
Message-ID: <20160213180412.GA9516@sigill.intra.peff.net> (raw)
In-Reply-To: <20160213174449.GH30144@sigill.intra.peff.net>

On Sat, Feb 13, 2016 at 12:44:49PM -0500, Jeff King wrote:

> > +test_expect_success '--show-origin' '
> [...]
> I see you split this up more, but there's still quite a bit going on in
> this one block. IMHO, it would be more customary in our tests to put the
> setup into one test_expect_success block, then each of these
> expect-run-cmp blocks into their own test_expect_success.

Here's a squashable patch that shows what I mean.

---
diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh
index 112f7c8..c7496aa 100755
--- a/t/t1300-repo-config.sh
+++ b/t/t1300-repo-config.sh
@@ -1207,26 +1207,34 @@ test_expect_success POSIXPERM,PERL 'preserves existing permissions' '
 	  "die q(badrename) if ((stat(q(.git/config)))[2] & 07777) != 0600"
 '
 
-test_expect_success '--show-origin' '
-	>.git/config &&
-	>"$HOME"/.gitconfig &&
+test_expect_success 'set up --show-origin tests' '
 	INCLUDE_DIR="$HOME/include" &&
 	mkdir -p "$INCLUDE_DIR" &&
-	cat >"$INCLUDE_DIR"/absolute.include <<-EOF &&
+	cat >"$INCLUDE_DIR"/absolute.include <<-\EOF &&
 		[user]
 			absolute = include
 	EOF
-	cat >"$INCLUDE_DIR"/relative.include <<-EOF &&
+	cat >"$INCLUDE_DIR"/relative.include <<-\EOF &&
 		[user]
 			relative = include
 	EOF
-	test_config_global user.global "true" &&
-	test_config_global user.override "global" &&
-	test_config_global include.path "$INCLUDE_DIR"/absolute.include &&
-	test_config include.path ../include/relative.include &&
-	test_config user.local "true" &&
-	test_config user.override "local" &&
+	cat >"$HOME"/.gitconfig <<-EOF &&
+		[user]
+			global = true
+			override = global
+		[include]
+			path = "$INCLUDE_DIR/absolute.include"
+	EOF
+	cat >.git/config <<-\EOF
+		[include]
+			path = ../include/relative.include
+		[user]
+			local = true
+			override = local
+	EOF
+'
 
+test_expect_success '--show-origin with --list' '
 	cat >expect <<-EOF &&
 		file:$HOME/.gitconfig	user.global=true
 		file:$HOME/.gitconfig	user.override=global
@@ -1239,8 +1247,10 @@ test_expect_success '--show-origin' '
 		cmdline:	user.cmdline=true
 	EOF
 	git -c user.cmdline=true config --list --show-origin >output &&
-	test_cmp expect output &&
+	test_cmp expect output
+'
 
+test_expect_success '--show-origin with --list --null' '
 	cat >expect <<-EOF &&
 		file:$HOME/.gitconfigQuser.global
 		trueQfile:$HOME/.gitconfigQuser.override
@@ -1253,25 +1263,32 @@ test_expect_success '--show-origin' '
 		localQcmdline:Quser.cmdline
 		trueQ
 	EOF
-	git -c user.cmdline=true config --null --list --show-origin | nul_to_q >output &&
+	git -c user.cmdline=true config --null --list --show-origin >output.raw &&
+	nul_to_q <output.raw >output &&
 	echo >>output &&
-	test_cmp expect output &&
+	test_cmp expect output
+'
 
+test_expect_success '--show-origin with single file' '
 	cat >expect <<-\EOF &&
 		file:.git/config	include.path=../include/relative.include
 		file:.git/config	user.local=true
 		file:.git/config	user.override=local
 	EOF
 	git config --local --list --show-origin >output &&
-	test_cmp expect output &&
+	test_cmp expect output
+'
 
+test_expect_success '--show-origin with --get-regexp' '
 	cat >expect <<-EOF &&
 		file:$HOME/.gitconfig	user.global true
 		file:.git/config	user.local true
 	EOF
 	git config --show-origin --get-regexp "user\.[g|l].*" >output &&
-	test_cmp expect output &&
+	test_cmp expect output
+'
 
+test_expect_success '--show-origin getting a single key' '
 	cat >expect <<-\EOF &&
 		file:.git/config	local
 	EOF
@@ -1279,11 +1296,13 @@ test_expect_success '--show-origin' '
 	test_cmp expect output
 '
 
-CUSTOM_CONFIG_FILE="file\twith\ttabs.conf" &&
-cat >"$CUSTOM_CONFIG_FILE" <<-\EOF &&
-	[user]
-		custom = true
-EOF
+test_expect_success 'set up custom config file' '
+	CUSTOM_CONFIG_FILE="file\twith\ttabs.conf" &&
+	cat >"$CUSTOM_CONFIG_FILE" <<-\EOF
+		[user]
+			custom = true
+	EOF
+'
 
 test_expect_success '--show-origin escape special file name characters' '
 	cat >expect <<-\EOF &&
@@ -1302,8 +1321,6 @@ test_expect_success '--show-origin stdin' '
 '
 
 test_expect_success '--show-origin stdin with file include' '
-	INCLUDE_DIR="$HOME/include" &&
-	mkdir -p "$INCLUDE_DIR" &&
 	cat >"$INCLUDE_DIR"/stdin.include <<-EOF &&
 		[user]
 			stdin = include

  reply	other threads:[~2016-02-13 18:05 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-13 14:24 [PATCH v3 0/3] config: add '--sources' option to print the source of a config value larsxschneider
2016-02-13 14:24 ` [PATCH v3 1/3] git-config.txt: describe '--includes' default behavior larsxschneider
2016-02-13 17:17   ` Jeff King
2016-02-13 21:00     ` Junio C Hamano
2016-02-14  0:34       ` Jeff King
2016-02-14 12:17     ` Lars Schneider
2016-02-14 16:05       ` Jeff King
2016-02-13 14:24 ` [PATCH v3 2/3] config: add 'type' to config_source struct that identifies config type larsxschneider
2016-02-13 17:24   ` Jeff King
2016-02-13 21:04     ` Junio C Hamano
2016-02-14 12:26       ` Lars Schneider
2016-02-14 12:24     ` Lars Schneider
2016-02-14 16:07       ` Jeff King
2016-02-13 14:24 ` [PATCH v3 3/3] config: add '--show-origin' option to print the origin of a config value larsxschneider
2016-02-13 17:44   ` Jeff King
2016-02-13 18:04     ` Jeff King [this message]
2016-02-13 18:15       ` Jeff King
2016-02-15  9:41         ` Lars Schneider
2016-02-14 12:48     ` Lars Schneider
2016-02-14 16:18       ` Jeff King
2016-02-15  7:53         ` Johannes Schindelin
2016-02-13 14:43 ` [PATCH v3 0/3] config: add '--sources' option to print the source " Mike Rappazzo
2016-02-13 17:26   ` Sebastian Schuberth
2016-02-13 18:19   ` Jeff King
2016-02-13 21:05     ` Junio C Hamano

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=20160213180412.GA9516@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=hvoigt@hvoigt.net \
    --cc=larsxschneider@gmail.com \
    --cc=ramsay@ramsayjones.plus.com \
    --cc=sbeller@google.com \
    --cc=sschuberth@gmail.com \
    --cc=sunshine@sunshineco.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).