Re: [PATCH] Add column layout skeleton and git-column

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

 



Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> writes:

> +static int parse_config(unsigned int *colopts, const char *value)
> +{
> +	const char *sep = " ,";
> +	int group_set = 0;
> +
> +	while (*value) {
> +		int len = strcspn(value, sep);
> +		if (len) {
> +			if (parse_option(value, len, colopts, &group_set))
> +				return -1;
> +
> +			value += len;
> +		}
> +		value += strspn(value, sep);
> +	}
> +	/*
> +	 * Setting layout implies "always" if neither always, never
> +	 * nor auto is specified.
> +	 *
> +	 * Current COL_ENABLE() value is disregarded. This means if
> +	 * you set column.ui = auto and pass --column=row, then "auto"
> +	 * will become "always".
> +	 */
> +	if ((group_set & LAYOUT_SET) && !(group_set & ENABLE_SET))
> +		*colopts = (*colopts & ~COL_ENABLE_MASK) | COL_ENABLED;
> +	return 0;
> +}
> +
> +static int column_config(const char *var, const char *value,
> +			 const char *key, unsigned int *colopts)
> +{
> +	if (value && parse_config(colopts, value))
> +		return error("invalid column.%s mode %s", key, value);

If column.* can never be a boolean, this code shouldn't silently ignore

	[column]
        	ui

but explicitly error out.  See git_config_string() for an example if you
want to go this route.

On the other hand, it might make sense to equate a "true" with "a sane
default" (i.e. the user declares that s/he trusts whatever default the Git
implementation deems sane), in which case

	if (!value)
		value = "auto,whatever,column,default,mode";
	if (parse_config(colopts, value))
        	return error("invalid column.%s mode...", ...);

might be a better way to go.  If you take this route, a single-token
column.* becomes a variable that takes boolean and more, so the existing
`never` has to gain `no`, `false`, etc. as synonyms, and `true`, `1`,
etc. needs to be interpreted the same as `auto` for consistency.
--
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]