about summary refs log tree commit homepage
path: root/lib/PublicInbox/Config.pm
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2014-02-06 22:19:20 +0000
committerEric Wong <normalperson@yhbt.net>2014-02-07 03:05:06 +0000
commit419f8eb672754cd99d6ec12a1f7af0d85ae70795 (patch)
treea1801cf48372768f86ef1cc1621538d0f483f8b3 /lib/PublicInbox/Config.pm
parent3f0cf5ba17204bc6ce9e3c1f197d6b4d66831eb8 (diff)
downloadpublic-inbox-419f8eb672754cd99d6ec12a1f7af0d85ae70795.tar.gz
We'll be using git config files after all...
Diffstat (limited to 'lib/PublicInbox/Config.pm')
-rw-r--r--lib/PublicInbox/Config.pm18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/PublicInbox/Config.pm b/lib/PublicInbox/Config.pm
new file mode 100644
index 00000000..4078585a
--- /dev/null
+++ b/lib/PublicInbox/Config.pm
@@ -0,0 +1,18 @@
+# Copyright (C) 2014, Eric Wong <normalperson@yhbt.net> and all contributors
+# License: AGPLv3 or later (https://www.gnu.org/licenses/agpl-3.0.txt)
+package PublicInbox::Config;
+
+# returns key-value pairs of config directives in a hash
+sub dump {
+        my ($class, $file) = @_;
+
+        local $ENV{GIT_CONFIG} = $file;
+
+        my @cfg = `git config -l`;
+        $? == 0 or die "git config -l failed: $?\n";
+        chomp @cfg;
+        my %rv = map { split(/=/, $_, 2) } @cfg;
+        \%rv;
+}
+
+1;