summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ea77e67)
raw | patch | inline | side by side (parent: ea77e67)
author | Linus Torvalds <torvalds@osdl.org> | |
Sun, 18 Dec 2005 20:41:10 +0000 (12:41 -0800) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Sun, 18 Dec 2005 21:53:40 +0000 (13:53 -0800) |
This changes "pretty_print_string_list()" to show the git commands
alphabetically in column order, which is the normal one.
Ie instead of doing
git commands available in '/home/torvalds/bin'
----------------------------------------------
add am ...
applypatch archimport ...
cat-file check-ref-format ...
...
it does
git commands available in '/home/torvalds/bin'
----------------------------------------------
add diff-tree ...
am fetch ...
apply fetch-pack ...
...
where each column is sorted.
This is how "ls" sorts things too, and since visually the columns are much
more distinct than the rows, so it _looks_ more sorted.
The "ls" command has a "-x" option that lists entries by lines (the way
git.c used to): if somebody wants to do that, the new print-out logic
could be easily accomodated to that too. Matter of taste and preference, I
guess.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
alphabetically in column order, which is the normal one.
Ie instead of doing
git commands available in '/home/torvalds/bin'
----------------------------------------------
add am ...
applypatch archimport ...
cat-file check-ref-format ...
...
it does
git commands available in '/home/torvalds/bin'
----------------------------------------------
add diff-tree ...
am fetch ...
apply fetch-pack ...
...
where each column is sorted.
This is how "ls" sorts things too, and since visually the columns are much
more distinct than the rows, so it _looks_ more sorted.
The "ls" command has a "-x" option that lists entries by lines (the way
git.c used to): if somebody wants to do that, the new print-out logic
could be easily accomodated to that too. Matter of taste and preference, I
guess.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
git.c | patch | blob | history |
index 157c54914422b197209e24223916f2ba501385ac..0fd95bf751cd5abfeb8a95f3b828adde4537dfde 100644 (file)
--- a/git.c
+++ b/git.c
static void pretty_print_string_list(struct cmdname **cmdname, int longest)
{
- int cols = 1;
+ int cols = 1, rows;
int space = longest + 1; /* min 1 SP between words */
int max_cols = term_columns() - 1; /* don't print *on* the edge */
- int i;
+ int i, j;
if (space < max_cols)
cols = max_cols / space;
+ rows = (cmdname_cnt + cols - 1) / cols;
qsort(cmdname, cmdname_cnt, sizeof(*cmdname), cmdname_compare);
- for (i = 0; i < cmdname_cnt; ) {
- int c;
+ for (i = 0; i < rows; i++) {
printf(" ");
- for (c = cols; c && i < cmdname_cnt; i++) {
- printf("%s", cmdname[i]->name);
-
- if (--c)
- mput_char(' ', space - cmdname[i]->len);
+ for (j = 0; j < cols; j++) {
+ int n = j * rows + i;
+ int size = space;
+ if (n >= cmdname_cnt)
+ break;
+ if (j == cols-1 || n + rows >= cmdname_cnt)
+ size = 1;
+ printf("%-*s", size, cmdname[n]->name);
}
putchar('\n');
}