make getpeername() return the original socket address which before it was intercepted
[hband-tools.git] / user-tools / gitconfigexec
blob1557254f0fed6a58af57286174aac296d3e7c630
1 #!/usr/bin/env perl
3 =pod
5 =head1 NAME
7 gitconfigexec - Change git settings for a given command run only
9 =head1 SYNOPSIS
11 gitconfigexec I<KEY>=I<VALUE> [I<KEY>=I<VALUE> [...]] [--] I<COMMAND> I<ARGS>
13 =head1 DESCRIPTION
15 I<KEY> is a valid git config option (see git-config(1)).
16 Set B<GIT_CONFIG_COUNT>, B<GIT_CONFIG_KEY_I<n>>, and B<GIT_CONFIG_VALUE_I<n>>
17 environment variables, so git(1) takes them as session-override settings.
19 =cut
22 while(@ARGV)
24 my $arg = shift @ARGV;
25 if($arg eq '--')
27 last;
29 if(my ($cfg_name, $cfg_value) = $arg =~ /^([^=]+)=(.*)$/)
31 my $idx = int $ENV{'GIT_CONFIG_COUNT'};
32 $ENV{"GIT_CONFIG_KEY_$idx"} = $cfg_name;
33 $ENV{"GIT_CONFIG_VALUE_$idx"} = $cfg_value;
34 $ENV{'GIT_CONFIG_COUNT'}++;
36 else
38 unshift @ARGV, $arg;
39 last;
43 # remaining arguments are the command and its arguments
44 exec {$ARGV[0]} @ARGV;
45 ($errno, $errstr) = (int $!, $!);
46 warn "$0: ${ARGV[0]}: $errstr\n";
47 exit 125+$errno;