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

Re: [PATCH v4 02/13] column: add API to print items in columns

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 3, 2012, 23:16 UTC
Message-ID
<7vsjirld82.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1328276078-27955-3-git-send-email-pclouds@gmail.com>
Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:
Show 20 quoted lines
> +#define MODE(mode) ((mode) & COL_MODE)
> + ...
> +void print_columns(const struct string_list *list, int mode,
> +		   struct column_options *opts)
> +{
> +	const char *indent = "", *nl = "\n";
> +	int padding = 1, width = term_columns();
> +
> +	if (!list->nr)
> +		return;
> +	if (opts) {
> +		if (opts->indent)
> +			indent = opts->indent;
> +		if (opts->nl)
> +			nl = opts->nl;
> +		if (opts->width)
> +			width = opts->width;
> +		padding = opts->padding;
> +	}
> +	if (width <= 1 || !(mode & COL_ENABLED)) {

Unless there is a compelling reason not to, make a flag word used as collection of bitfields an unsigned, i.e. not "int mode".

Previous: Junio C HamanoNext: Nguyễn Thái Ngọc Duy
Message 5 of 43 in “Column display again”
  1. 00/13 Column display againNguyễn Thái Ngọc Duy, Feb 3, 2012
  2. 01/13 Save terminal width before setting up pagerNguyễn Thái Ngọc Duy, Feb 3, 2012
  3. 02/13 column: add API to print items in columnsNguyễn Thái Ngọc Duy, Feb 3, 2012
  4. Junio C HamanoFeb 3, 2012
  5. Junio C HamanoFeb 3, 2012
  6. 03/13 parseopt: make OPT_INTEGER support hexadecimal as wellNguyễn Thái Ngọc Duy, Feb 3, 2012
  7. Junio C HamanoFeb 3, 2012
  8. Nguyen Thai Ngoc DuyFeb 4, 2012
  9. Junio C HamanoFeb 4, 2012
  10. Nguyen Thai Ngoc DuyFeb 4, 2012
  11. 04/13 Add git-column and column mode parsingNguyễn Thái Ngọc Duy, Feb 3, 2012
  12. 05/13 Stop starting pager recursivelyNguyễn Thái Ngọc Duy, Feb 3, 2012
  13. 06/13 column: add columnar layoutNguyễn Thái Ngọc Duy, Feb 3, 2012
  14. 07/13 column: support columns with different widthsNguyễn Thái Ngọc Duy, Feb 3, 2012
  15. 08/13 column: add column.ui for default column output settingsNguyễn Thái Ngọc Duy, Feb 3, 2012
  16. Junio C HamanoFeb 3, 2012
  17. 09/13 help: reuse print_columns() for help -aNguyễn Thái Ngọc Duy, Feb 3, 2012
  18. Junio C HamanoFeb 3, 2012
  19. 10/13 branch: add --columnNguyễn Thái Ngọc Duy, Feb 3, 2012
  20. Junio C HamanoFeb 3, 2012
  21. Nguyen Thai Ngoc DuyFeb 4, 2012
  22. 11/13 status: add --columnNguyễn Thái Ngọc Duy, Feb 3, 2012
  23. Junio C HamanoFeb 3, 2012
  24. 12/13 column: support piping stdout to external git-column processNguyễn Thái Ngọc Duy, Feb 3, 2012
  25. 13/13 tag: add --columnNguyễn Thái Ngọc Duy, Feb 3, 2012
  26. Junio C HamanoFeb 3, 2012
  27. 00/12 Column displayNguyễn Thái Ngọc Duy, Feb 4, 2012
  28. 01/12 Save terminal width before setting up pagerNguyễn Thái Ngọc Duy, Feb 4, 2012
  29. 02/12 column: add API to print items in columnsNguyễn Thái Ngọc Duy, Feb 4, 2012
  30. 03/12 Add git-column and column mode parsingNguyễn Thái Ngọc Duy, Feb 4, 2012
  31. 03/12 Add git-column and column mode parsingNguyễn Thái Ngọc Duy, Feb 4, 2012
  32. 04/12 Stop starting pager recursivelyNguyễn Thái Ngọc Duy, Feb 4, 2012
  33. 05/12 column: add columnar layoutNguyễn Thái Ngọc Duy, Feb 4, 2012
  34. 06/12 column: support columns with different widthsNguyễn Thái Ngọc Duy, Feb 4, 2012
  35. 07/12 column: add column.ui for default column output settingsNguyễn Thái Ngọc Duy, Feb 4, 2012
  36. 07/12 column: add column.ui for default column output settingsNguyễn Thái Ngọc Duy, Feb 4, 2012
  37. 08/12 help: reuse print_columns() for help -aNguyễn Thái Ngọc Duy, Feb 4, 2012
  38. 09/12 branch: add --columnNguyễn Thái Ngọc Duy, Feb 4, 2012
  39. Junio C HamanoFeb 6, 2012
  40. 10/12 status: add --columnNguyễn Thái Ngọc Duy, Feb 4, 2012
  41. 11/12 column: support piping stdout to external git-column processNguyễn Thái Ngọc Duy, Feb 4, 2012
  42. 12/12 tag: add --columnNguyễn Thái Ngọc Duy, Feb 4, 2012
  43. Junio C HamanoFeb 6, 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.