-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A couple of commands learn --column option to produce columnar output. By Nguyễn Thái Ngọc Duy (9) and Zbigniew Jędrzejewski-Szmek (1) * nd/columns: tag: add --column column: support piping stdout to external git-column process status: add --column branch: add --column help: reuse print_columns() for help -a column: add dense layout support t9002: work around shells that are unable to set COLUMNS to 1 column: add columnar layout Stop starting pager recursively Add column layout skeleton and git-column
- Loading branch information
Showing
27 changed files
with
1,105 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ | |
/git-cherry-pick | ||
/git-clean | ||
/git-clone | ||
/git-column | ||
/git-commit | ||
/git-commit-tree | ||
/git-config | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
git-column(1) | ||
============= | ||
|
||
NAME | ||
---- | ||
git-column - Display data in columns | ||
|
||
SYNOPSIS | ||
-------- | ||
[verse] | ||
'git column' [--command=<name>] [--[raw-]mode=<mode>] [--width=<width>] | ||
[--indent=<string>] [--nl=<string>] [--pading=<n>] | ||
|
||
DESCRIPTION | ||
----------- | ||
This command formats its input into multiple columns. | ||
|
||
OPTIONS | ||
------- | ||
--command=<name>:: | ||
Look up layout mode using configuration variable column.<name> and | ||
column.ui. | ||
|
||
--mode=<mode>:: | ||
Specify layout mode. See configuration variable column.ui for option | ||
syntax. | ||
|
||
--raw-mode=<n>:: | ||
Same as --mode but take mode encoded as a number. This is mainly used | ||
by other commands that have already parsed layout mode. | ||
|
||
--width=<width>:: | ||
Specify the terminal width. By default 'git column' will detect the | ||
terminal width, or fall back to 80 if it is unable to do so. | ||
|
||
--indent=<string>:: | ||
String to be printed at the beginning of each line. | ||
|
||
--nl=<N>:: | ||
String to be printed at the end of each line, | ||
including newline character. | ||
|
||
--padding=<N>:: | ||
The number of spaces between columns. One space by default. | ||
|
||
|
||
Author | ||
------ | ||
Written by Nguyen Thai Ngoc Duy <pclouds@gmail.com> | ||
|
||
GIT | ||
--- | ||
Part of the linkgit:git[1] suite |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#include "builtin.h" | ||
#include "cache.h" | ||
#include "strbuf.h" | ||
#include "parse-options.h" | ||
#include "string-list.h" | ||
#include "column.h" | ||
|
||
static const char * const builtin_column_usage[] = { | ||
"git column [options]", | ||
NULL | ||
}; | ||
static unsigned int colopts; | ||
|
||
static int column_config(const char *var, const char *value, void *cb) | ||
{ | ||
return git_column_config(var, value, cb, &colopts); | ||
} | ||
|
||
int cmd_column(int argc, const char **argv, const char *prefix) | ||
{ | ||
struct string_list list = STRING_LIST_INIT_DUP; | ||
struct strbuf sb = STRBUF_INIT; | ||
struct column_options copts; | ||
const char *command = NULL, *real_command = NULL; | ||
struct option options[] = { | ||
OPT_STRING(0, "command", &real_command, "name", "lookup config vars"), | ||
OPT_COLUMN(0, "mode", &colopts, "layout to use"), | ||
OPT_INTEGER(0, "raw-mode", &colopts, "layout to use"), | ||
OPT_INTEGER(0, "width", &copts.width, "Maximum width"), | ||
OPT_STRING(0, "indent", &copts.indent, "string", "Padding space on left border"), | ||
OPT_INTEGER(0, "nl", &copts.nl, "Padding space on right border"), | ||
OPT_INTEGER(0, "padding", &copts.padding, "Padding space between columns"), | ||
OPT_END() | ||
}; | ||
|
||
/* This one is special and must be the first one */ | ||
if (argc > 1 && !prefixcmp(argv[1], "--command=")) { | ||
command = argv[1] + 10; | ||
git_config(column_config, (void *)command); | ||
} else | ||
git_config(column_config, NULL); | ||
|
||
memset(&copts, 0, sizeof(copts)); | ||
copts.width = term_columns(); | ||
copts.padding = 1; | ||
argc = parse_options(argc, argv, "", options, builtin_column_usage, 0); | ||
if (argc) | ||
usage_with_options(builtin_column_usage, options); | ||
if (real_command || command) { | ||
if (!real_command || !command || strcmp(real_command, command)) | ||
die(_("--command must be the first argument")); | ||
} | ||
finalize_colopts(&colopts, -1); | ||
while (!strbuf_getline(&sb, stdin, '\n')) | ||
string_list_append(&list, sb.buf); | ||
|
||
print_columns(&list, colopts, &copts); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.