From 95c8ad2490271fd0038321011b07a1bd59a3ec23 Mon Sep 17 00:00:00 2001 From: nirenjan Date: Fri, 9 Aug 2013 19:34:27 -0700 Subject: [PATCH] Add applygitconfig script Simple Perl script to apply a git config from any gitconfig file --- scripts/applygitconfig | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 scripts/applygitconfig diff --git a/scripts/applygitconfig b/scripts/applygitconfig new file mode 100755 index 0000000..dab208e --- /dev/null +++ b/scripts/applygitconfig @@ -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); + } +}