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

[PATCH 1/3] column.c: pass column_options to down to display_plain

From
Stefan Beller <sbeller@google.com>
Date
Mar 30, 2017, 01:42 UTC
Message-ID
<20170330014238.30032-2-sbeller@google.com>
In-Reply-To
<20170330014238.30032-1-sbeller@google.com>

In a later patch we want to use more of the column_options members at places, where we do actual output, so it will be handy to have the whole struct around in `display_plain`.

Signed-off-by: Stefan Beller <sbeller@google.com>
---
 column.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/column.c b/column.c
index d55ead18ef..4851b9aa04 100644
--- a/column.c
+++ b/column.c
@@ -109,12 +109,12 @@ static void shrink_columns(struct column_data *data)
 
 /* Display without layout when not enabled */
 static void display_plain(const struct string_list *list,
-			  const char *indent, const char *nl)
+			  const struct column_options *opts)
 {
 	int i;
 
 	for (i = 0; i < list->nr; i++)
-		printf("%s%s%s", indent, list->items[i].string, nl);
+		printf("%s%s%s", opts->indent, list->items[i].string, opts->nl);
 }
 
 /* Print a cell to stdout with all necessary leading/traling space */
@@ -201,12 +201,14 @@ void print_columns(const struct string_list *list, unsigned int colopts,
 	nopts.padding = opts ? opts->padding : 1;
 	nopts.width = opts && opts->width ? opts->width : term_columns() - 1;
 	if (!column_active(colopts)) {
-		display_plain(list, "", "\n");
+		nopts.indent = "";
+		nopts.nl = "\n";
+		display_plain(list, &nopts);
 		return;
 	}
 	switch (COL_LAYOUT(colopts)) {
 	case COL_PLAIN:
-		display_plain(list, nopts.indent, nopts.nl);
+		display_plain(list, &nopts);
 		break;
 	case COL_ROW:
 	case COL_COLUMN:
-- 
2.12.2.511.g2abb8caf66
Previous: Duy Nguyen
Message 9 of 9 in “Respect column.ui in commented status in git-commit”
  1. 0/3 Respect column.ui in commented status in git-commitStefan Beller, Mar 30, 2017
  2. 2/3 column: allow for custom printfStefan Beller, Mar 30, 2017
  3. Jeff KingMar 30, 2017
  4. Duy NguyenApr 10, 2017
  5. 3/3 WIP - Allow custom printf function for column printingStefan Beller, Mar 30, 2017
  6. Jeff KingMar 30, 2017
  7. Stefan BellerMar 30, 2017
  8. Duy NguyenApr 10, 2017
  9. 1/3 column.c: pass column_options to down to display_plainStefan Beller, Mar 30, 2017

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.