From: Stefan Beller <sbeller@google.com>
To: git@vger.kernel.org, peff@peff.net
Cc: Stefan Beller <sbeller@google.com>
Subject: [PATCH 1/3] column.c: pass column_options to down to display_plain
Date: Wed, 29 Mar 2017 18:42:36 -0700 [thread overview]
Message-ID: <20170330014238.30032-2-sbeller@google.com> (raw)
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
next prev parent reply other threads:[~2017-03-30 1:42 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-30 1:42 [PATCH 0/3] Respect column.ui in commented status in git-commit Stefan Beller
2017-03-30 1:42 ` Stefan Beller [this message]
2017-03-30 1:42 ` [PATCH 2/3] column: allow for custom printf Stefan Beller
2017-03-30 3:12 ` Jeff King
2017-04-10 11:13 ` Duy Nguyen
2017-03-30 1:42 ` [PATCH 3/3] WIP - Allow custom printf function for column printing Stefan Beller
2017-03-30 3:22 ` Jeff King
2017-03-30 18:53 ` Stefan Beller
2017-04-10 11:35 ` Duy Nguyen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170330014238.30032-2-sbeller@google.com \
--to=sbeller@google.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).