Re: [PATCH v9 1/9] 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 column_config(const char *var, const char *value,
> +			 const char *key, unsigned int *colopts)
> +{
> +	if (parse_config(colopts, value))
> +		return error("invalid %s mode %s", key, value);
> +	return 0;
> +}
> +
> +int git_column_config(const char *var, const char *value,
> +		      const char *command, unsigned int *colopts)
> +{
> +	if (!strcmp(var, "column.ui"))
> +		return column_config(var, value, "column.ui", colopts);

I do not think there is anything that reads column.ui from a configuration
file (or "git -c column.ui") in this step, but later patches seem to use
it from their configuration callback (e.g. git_branch_config()) and at
that point you will segfault because you ignore the case where value is

> +	if (command) {
> +		struct strbuf sb = STRBUF_INIT;
> +		int ret = 0;
> +		strbuf_addf(&sb, "column.%s", command);
> +		if (!strcmp(var, sb.buf))
> +			ret = column_config(var, value, sb.buf, colopts);
> +		strbuf_release(&sb);
> +		return ret;
> +	}

This whole thing looks overly wasteful.  How about doing it this way?

	const char *it = skip_prefix(var, "column.");
        if (!it)
		return 0;
	if (!strcmp(it, "ui"))
		parse "ui";
	else if (!strcmp(it, command))
		parse "command";

and make the third parameter to column_config() be without the constant
prefix "column."?
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at

[Newbies FAQ]     [Linux Kernel Development]     [Free Online Dating]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Free Online Dating]     [Photo]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]     [Linux Resources]

Add to Google