Re: [PATCH] perl: add new module Git::Config for cached 'git config' access

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Apr 06, 2009 at 11:46:15AM +1200, Sam Vilain wrote:
> +	my ($fh, $c) = $git->command_output_pipe(
> +		'config', ( $which ? ("--$which") : () ),
> +		'--list',
> +	       );
> +	my $read_state = {};
> +
> +	while (<$fh>) {
> +		my ($item, $value) = m{(.*?)=(.*)};
> +		my $sl = \( $read_state->{$item} );
> +		if (!defined $$sl) {
> +			$$sl = $value;
> +		}
> +		elsif (!ref $$sl) {
> +			$$sl = [ $$sl, $value ];
> +		}
> +		else {
> +			push @{ $$sl }, $value;
> +		}
> +	}

Any reason why you don't use --null here? The output of --list without --null
is not reliably parsable, since people can put newlines in values.

Gruesse,
-- 
Frank Lichtenheld <frank@xxxxxxxxxxxxxx>
www: http://www.djpig.de/
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]