Re: [RFC PATCH] config: Introduce functions to write non-standard file
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jul 18, 2011, 23:54 UTC
- Message-ID
- <7vr55n9mc3.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <1311025032-835-1-git-send-email-artagnon@gmail.com>
Ramkumar Ramachandra <artagnon@gmail.com> writes:
Show 12 quoted lines
> +int git_config_set_in_file(const char *key, const char *value,
> + const char *filename)
> +{
> + const char *saved;
> + int ret;
> +
> + saved = config_exclusive_filename;
> + config_exclusive_filename = filename;
> + ret = git_config_set_multivar(key, value, NULL, 0);
> + config_exclusive_filename = saved;
> + return ret;
> +}Yuck, what an ugly hack when you are so close. Why not restructure the code in such a way that the updated config-set-multivar and set-in-file share the code better? If the former takes a hardcoded logic to decide which file to write to while the latter takes the filename to write to as its argument, wouldn't it be a lot more natural to make config-set-multivar call set-in-file after computing what filename parameter to pass?