Subject: [PATCH 6/9] column: add column.ui for default column output settings

From: Nguyễn Thái Ngọc Duy <[email-masked]>
Date: Sun, 20 Mar 2011 19:57:50 +0700

Signed-off-by: Nguyễn Thái Ngọc Duy <[email-masked]>
---
 Documentation/config.txt |   24 ++++++++++++++++++++++++
 column.c                 |   11 +++++++++++
 column.h                 |    3 +++
 3 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index c5e1835..7183712 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -805,6 +805,30 @@ color.ui::
 	terminal. When more specific variables of color.* are set, they always
 	take precedence over this setting. Defaults to false.
 
+column.ui::
+	Specify whether supported commands should output in columns.
+	This variable consists of a list of tokens separated by spaces
+	or commas:
++
+--
+`always`;;
+	always show in columns
+`never`;;
+	never show in columns
+`auto`;;
+	show in columns if the output is to the terminal
+`column`;;
+	fill columns before rows (default)
+`row`;;
+	fill rows before columns
+`dense`;;
+	make unequal size columns to utilize more space
+`nodense`;;
+	make equal size columns
+--
++
+	This option defaults to 'never'.
+
 commit.status::
 	A boolean to enable/disable inclusion of status information in the
 	commit message template when using an editor to prepare the commit
diff --git a/column.c b/column.c
index 69d42f8..7c1a6f1 100644
--- a/column.c
+++ b/column.c
@@ -2,6 +2,7 @@
 #include "column.h"
 #include "string-list.h"
 #include "parse-options.h"
+#include "color.h"
 #include "utf8.h"
 
 #define MODE(mode) ((mode) & COL_MODE)
@@ -21,6 +22,8 @@ struct column_data {
 	int *width;			/* index to the longest row in column */
 };
 
+int git_core_column;
+
 /* return length of 's' in letters, ANSI escapes stripped */
 static int item_length(int mode, const char *s)
 {
@@ -350,6 +353,14 @@ static int parse_string(int *mode, const char *value,
 	return 0;
 }
 
+int git_column_default_config(const char *var, const char *value, void *cb)
+{
+	if (!strcmp(var, "column.ui"))
+		return parse_string(&git_core_column, value, -1);
+
+	return git_color_default_config(var, value, cb);
+}
+
 int parseopt_column_callback(const struct option *opt,
 			     const char *arg, int unset)
 {
diff --git a/column.h b/column.h
index 48c6345..0f4190d 100644
--- a/column.h
+++ b/column.h
@@ -9,9 +9,12 @@
 #define COL_ANSI         (1 << 6)  /* Remove ANSI escapes from string length */
 #define COL_DENSE        (1 << 7)  /* Shrink columns when possible, making space for more columns */
 
+extern int git_core_column;
+
 extern int term_columns(void);
 extern struct string_list_item *add_to_columns(struct string_list *list, int mode, const char *string);
 extern void display_columns(const struct string_list *list, int mode, int width, int padding, const char *indent);
+extern int git_column_default_config(const char *var, const char *value, void *cb);
 
 struct option;
 extern int parseopt_column_callback(const struct option *opt, const char *arg, int unset);
-- 
1.7.4.74.g639db