user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH 3/3] remove GIT_DIR env usage in favor of --git-dir
  @ 2016-04-25  9:52  7% ` Eric Wong
  0 siblings, 0 replies; 1+ results
From: Eric Wong @ 2016-04-25  9:52 UTC (permalink / raw)
  To: meta

No need to maintain per-block environment state when we can
localize it to per-command.  We've had --git-dir= in git
since 1.4.2 (2006-08-12) and already use it all over the
place.
---
 t/cgi.t |  7 ++-----
 t/mda.t | 11 ++++-------
 2 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/t/cgi.t b/t/cgi.t
index d7e3ac5..dcbfb4c 100644
--- a/t/cgi.t
+++ b/t/cgi.t
@@ -62,8 +62,7 @@ zzzzzz
 EOF
 		my $in = $simple->as_string;
 		run_with_env({PATH => $main_path}, [$mda], \$in);
-		local $ENV{GIT_DIR} = $maindir;
-		my $rev = `git rev-list HEAD`;
+		my $rev = `git --git-dir=$maindir rev-list HEAD`;
 		like($rev, qr/\A[a-f0-9]{40}/, "good revision committed");
 	}
 
@@ -85,8 +84,7 @@ what?
 EOF
 		my $in = $reply->as_string;
 		run_with_env({PATH => $main_path}, [$mda], \$in);
-		local $ENV{GIT_DIR} = $maindir;
-		my $rev = `git rev-list HEAD`;
+		my $rev = `git --git-dir=$maindir rev-list HEAD`;
 		like($rev, qr/\A[a-f0-9]{40}/, "good revision committed");
 	}
 
@@ -169,7 +167,6 @@ EOF
 		local $ENV{ORIGINAL_RECIPIENT} = $addr;
 		run_with_env({PATH => $main_path}, [$mda], \$in);
 	}
-	local $ENV{GIT_DIR} = $maindir;
 
 	my $res = cgi_run("/test/slashy%2fasdf%40example.com/raw");
 	like($res->{body}, qr/Message-Id: <\Q$slashy_mid\E>/,
diff --git a/t/mda.t b/t/mda.t
index 6b7527d..ad6a091 100644
--- a/t/mda.t
+++ b/t/mda.t
@@ -92,11 +92,10 @@ EOF
 	{
 		local $ENV{PATH} = $main_path;
 		run([$mda], \$in);
-		local $ENV{GIT_DIR} = $maindir;
-		my $rev = `git rev-list HEAD`;
+		my $rev = `git --git-dir=$maindir rev-list HEAD`;
 		like($rev, qr/\A[a-f0-9]{40}/, "good revision committed");
 		chomp $rev;
-		my $cmt = `git cat-file commit $rev`;
+		my $cmt = `git --git-dir=$maindir cat-file commit $rev`;
 		like($cmt, qr/^author Me <me\@example\.com> 0 \+0000\n/m,
 			"author info set correctly");
 		like($cmt, qr/^committer test <test-public\@example\.com>/m,
@@ -109,8 +108,7 @@ EOF
 		ok(!-e $failbox, "nothing in PI_EMERGENCY before");
 		local $ENV{PATH} = $fail_path;
 		run([$mda], \$in);
-		local $ENV{GIT_DIR} = $maindir;
-		my @revs = `git rev-list HEAD`;
+		my @revs = `git --git-dir=$maindir rev-list HEAD`;
 		is(scalar @revs, 1, "bad revision not committed");
 		ok(-s $failbox > 0, "PI_EMERGENCY is written to");
 	}
@@ -330,8 +328,7 @@ sub fail_bad_header {
 	my ($out, $err) = ("", "");
 	local $ENV{PATH} = $main_path;
 	run([$mda], \$in, \$out, \$err);
-	local $ENV{GIT_DIR} = $maindir;
-	my $rev = `git rev-list HEAD`;
+	my $rev = `git --git-dir=$maindir rev-list HEAD`;
 	chomp $rev;
 	is($rev, $good_rev, "bad revision not commited ($msg)");
 	ok(-s $failbox > 0, "PI_EMERGENCY is written to ($msg)");
-- 
EW


^ permalink raw reply related	[relevance 7%]

Results 1-1 of 1 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2016-04-25  9:52     [PATCH 0/3] remove ssoma dependency from public-inbox Eric Wong
2016-04-25  9:52  7% ` [PATCH 3/3] remove GIT_DIR env usage in favor of --git-dir Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).