Re: [PATCH v5] Add default merge options for all branches

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

 



Jonathan Nieder <jrnieder@xxxxxxxxx> writes:

>> +static void parse_branch_merge_options(char *bmo)
>> +{
>> +	const char **argv;
>> +	int argc;
>> +	char *buf;
>> +
>> +	if (!bmo)
>> +		return;
>> +	argc = split_cmdline(bmo, &argv);
>> +	if (argc < 0)
>> +		die("Bad branch.%s.mergeoptions string", branch);
>> +	argv = xrealloc(argv, sizeof(*argv) * (argc + 2));
>> +	memmove(argv + 1, argv, sizeof(*argv) * (argc + 1));
>
> This is not new code, but it might make sense to do
>
> 	argv[0] = "merge.*.options";
>
> for a saner error message when someone tries
>
> 	[branch "master"]
> 		mergeoptions = --nonsense

Yes, either we stuff a fixed string "branch.*.mergeoptions" to argv[0], or
use another static to recall which variable gave us that value and use
it.  The former is of course easier and less nicer.

>> +	argc++;
>> +	parse_options(argc, argv, NULL, builtin_merge_options,
>> +		      builtin_merge_usage, 0);
>> +	free(buf);
>
> [*]
> This buf seems to be left over.  (I don't think the intent is to
> call free on an uninitialized pointer. ;-))

I also forgot to free argv[].

--
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]