user/dev discussion of public-inbox itself
 help / color / mirror / Atom feed
* [PATCH] lei_store: quiet down "git var" failures
@ 2021-01-01  9:20 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2021-01-01  9:20 UTC (permalink / raw)
  To: meta

$git->qx and $git->popen now $env and $opt for redirects
like lower-level popen_rd.  This may be beneficial in other
places.
---
 lib/PublicInbox/Git.pm      | 14 +++++++++-----
 lib/PublicInbox/LeiStore.pm |  4 +++-
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm
index 49c0d5d6..f7332bb6 100644
--- a/lib/PublicInbox/Git.pm
+++ b/lib/PublicInbox/Git.pm
@@ -352,15 +352,19 @@ sub fail { # may be augmented in subclasses
 	croak(ref($self) . ' ' . ($self->{git_dir} // '') . ": $msg");
 }
 
+# $git->popen(qw(show f00)); # or
+# $git->popen(qw(show f00), { GIT_CONFIG => ... }, { 2 => ... });
 sub popen {
-	my ($self, @cmd) = @_;
-	@cmd = ('git', "--git-dir=$self->{git_dir}", @cmd);
-	popen_rd(\@cmd);
+	my ($self, $cmd) = splice(@_, 0, 2);
+	$cmd = [ 'git', "--git-dir=$self->{git_dir}",
+		ref($cmd) ? @$cmd : ($cmd, grep { defined && !ref } @_) ];
+	popen_rd($cmd, grep { !defined || ref } @_); # env and opt
 }
 
+# same args as popen above
 sub qx {
-	my ($self, @cmd) = @_;
-	my $fh = $self->popen(@cmd);
+	my $self = shift;
+	my $fh = $self->popen(@_);
 	local $/ = wantarray ? "\n" : undef;
 	<$fh>;
 }
diff --git a/lib/PublicInbox/LeiStore.pm b/lib/PublicInbox/LeiStore.pm
index a23efed5..7c62ffea 100644
--- a/lib/PublicInbox/LeiStore.pm
+++ b/lib/PublicInbox/LeiStore.pm
@@ -54,7 +54,9 @@ sub git_epoch_max  {
 
 sub git_ident ($) {
 	my ($git) = @_;
-	chomp(my $i = $git->qx(qw(var GIT_COMMITTER_IDENT)));
+	open my $null, '>', '/dev/null' or die "open /dev/null: $!";
+	my $opt = { 2 => $null };
+	chomp(my $i = $git->qx(qw(var GIT_COMMITTER_IDENT), undef, $opt));
 	warn "$git->{git_dir} GIT_COMMITTER_IDENT failed\n" if $?;
 	$i =~ /\A(.+) <([^>]+)> [0-9]+ [-\+]?[0-9]+$/ ? ($1, $2) :
 		('lei user', 'x@example.com')

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-01-01  9:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-01  9:20 [PATCH] lei_store: quiet down "git var" failures Eric Wong

user/dev discussion of public-inbox itself

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/meta
	git clone --mirror http://czquwvybam4bgbro.onion/meta
	git clone --mirror http://hjrcffqmbrq6wope.onion/meta
	git clone --mirror http://ou63pmih66umazou.onion/meta

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 meta meta/ https://public-inbox.org/meta \
		meta@public-inbox.org
	public-inbox-index meta

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.mail.public-inbox.meta
	nntp://ou63pmih66umazou.onion/inbox.comp.mail.public-inbox.meta
	nntp://czquwvybam4bgbro.onion/inbox.comp.mail.public-inbox.meta
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.mail.public-inbox.meta
	nntp://news.gmane.io/gmane.mail.public-inbox.general
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for the project(s) associated with this inbox:

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

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git