Add applygitconfig script

Simple Perl script to apply a git config from any gitconfig file
master
nirenjan 2013-08-09 19:34:27 -07:00
parent 7f0e20cfef
commit fec04c7037
1 changed files with 27 additions and 0 deletions

27
applygitconfig 100755
View File

@ -0,0 +1,27 @@
#!/usr/bin/env perl
# Script to apply git configuration to global gitconfig
my $section = 'unknown';
my $variable;
my $value;
my $command;
while(<>) {
chomp;
if (m/^\[(\w+)\]$/) {
$section = $1;
#print "Section: $section\n";
} elsif (m/^\[(\w+) +"(\w+)"\]/) {
$section = "$1.$2";
#print "Section: $section\n";
} elsif (m/(\w+) += +(.+)$/) {
$variable = $1;
$value = $2;
$value =~ s/"/\\"/g;
#print "\t$section.$variable = \"$value\"\n";
$command = "git config --global $section.$variable \"$value\"";
print "$command\n";
system($command);
}
}