git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 16, 2012, 16:05 UTC
Message-ID
<7v4nsjy85r.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1334582784-25723-1-git-send-email-pclouds@gmail.com>
Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
Show 33 quoted lines
> +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.

Previous: Nguyễn Thái Ngọc DuyNext: Nguyễn Thái Ngọc Duy
Message 5 of 17 in “Column display”
  1. 0/9 Column displayNguyễn Thái Ngọc Duy, Apr 13, 2012
  2. 1/9 Add column layout skeleton and git-columnNguyễn Thái Ngọc Duy, Apr 13, 2012
  3. Junio C HamanoApr 16, 2012
  4. Add column layout skeleton and git-columnNguyễn Thái Ngọc Duy, Apr 16, 2012
  5. Junio C HamanoApr 16, 2012
  6. Add column layout skeleton and git-columnNguyễn Thái Ngọc Duy, Apr 21, 2012
  7. Junio C HamanoApr 21, 2012
  8. Add column layout skeleton and git-columnNguyễn Thái Ngọc Duy, Apr 21, 2012
  9. Junio C HamanoApr 21, 2012
  10. 2/9 Stop starting pager recursivelyNguyễn Thái Ngọc Duy, Apr 13, 2012
  11. 3/9 column: add columnar layoutNguyễn Thái Ngọc Duy, Apr 13, 2012
  12. 4/9 column: add dense layout supportNguyễn Thái Ngọc Duy, Apr 13, 2012
  13. 5/9 help: reuse print_columns() for help -aNguyễn Thái Ngọc Duy, Apr 13, 2012
  14. 6/9 branch: add --columnNguyễn Thái Ngọc Duy, Apr 13, 2012
  15. 7/9 status: add --columnNguyễn Thái Ngọc Duy, Apr 13, 2012
  16. 8/9 column: support piping stdout to external git-column processNguyễn Thái Ngọc Duy, Apr 13, 2012
  17. 9/9 tag: add --columnNguyễn Thái Ngọc Duy, Apr 13, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.