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

Re: [PATCH 00/12] Support columinized output in tag/branch/ls-files/grep

From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
Date
Mar 12, 2010, 04:22 UTC
Message-ID
<fcaeb9bf1003112022md32ababv3e4ace04752f8f56@mail.gmail.com>
In-Reply-To
<4B995D0C.2090000@lsrfire.ath.cx>

On Fri, Mar 12, 2010 at 4:13 AM, René Scharfe <rene.scharfe@lsrfire.ath.cx> wrote:

Show 29 quoted lines
> Am 10.03.2010 01:27, schrieb Nguyen Thai Ngoc Duy:
>> On 3/9/10, René Scharfe <rene.scharfe@lsrfire.ath.cx> wrote:
>>>  With "more complicated", do you perhaps mean what GNU ls does, namely
>>>  having non-uniform column widths?  I never consciously noticed that it
>>>  actually goes out of its way to cram as may columns on the screen as
>>>  possible, it just feels so natural. :)
>>
>> That. And aligned grep output like this
>>
>> pclouds@do ~/w/git/builtin $ git grep -n 38
>> count-objects.c  |  35 |                if (cp - ent->d_name != 38)
>> count-objects.c  |  39 |                        memcpy(path + len + 3,
>> ent->d_name, 38);
>> count-objects.c  |  59 |                memcpy(hex+2, ent->d_name, 38);
>> fsck.c           | 405 |                if (strlen(de->d_name) == 38) {
>> gc.c             | 112 |                if (strspn(ent->d_name,
>> "0123456789abcdef") != 38 ||
>> gc.c             | 113 |                    ent->d_name[38] != '\0')
>> prune-packed.c   |  24 |                if (strlen(de->d_name) != 38)
>> prune-packed.c   |  26 |                memcpy(hex+2, de->d_name, 38);
>> prune-packed.c   |  31 |                memcpy(pathname + len, de->d_name, 38);
>> prune.c          |  64 |                if (strlen(de->d_name) == 38) {
>> receive-pack.c   | 588 |        char hdr_arg[38];
>> upload-archive.c |  86 |        char buf[16384];
>
> Hmm, I'm not sure that this columnizing is very useful in this instance.
>  You can more easily compare the line numbers and the indent level of
> the hits, but both pieces of information are only useful in the context
> of the file, so this easier comparison doesn't buy you much.

It's useful when I need to look at the beginning of matched lines. With current output, all lines are not aligned, so it's hard too see where lines begin.

> Another possible use might be the list of untracked files shown by
> status and commit, by the way.
Thanks.
Show 16 quoted lines
>>> I don't see any benefit of an environment variable over config options.
>>
>> Currently we may pass --column=<foo> from a porcelain to "git column
>> --mode=<foo>", <foo> could be column first, or row first, or either
>> with non-uniform columns (not implemented yet). We can also pass other
>> things to "git column". Putting everything in "<foo>" is OK, although
>> looks ugly. In my private tree, I also have "git column
>> --min-rows/--max-items" that forces the columnizer to one column mode
>> if:
>>  - there will be only one or two rows after columnized, too wide
>> screen for example (--min-rows)
>
> Well, I can't imagine when I would want to use this option.  If I'm OK
> with n + 100 items being displayed in x columns, I'd certainly be OK
> with n items being displayed the same way, even if they only take up a
> single row.

It's probably just me. With 279 character-wide terminal, I find it much easier to look vertically than 16 items on a single row.

Show 12 quoted lines
>>  - too many lines and the layout has not been fixed, so nothing gets
>> printed (--max-items). Forcing back to one column mode to stop wait
>> time.
>
> Interesting idea, but I'm not sure if I'd want to use it, too.  Best
> effort pretty-printing combines fast output and optimized display at
> first glance.  However, if there are lots of items then the user would
> benefit the most from having them columnized.
>
> If it takes too long to show the first line of output (since the
> columnizer needs to wait for all items to be generated) then the command
> should only columnize on request.

Yeah. That's the idea of "core.columns = auto". If you specify --[no-]columns on command line, then it must do as you wish. However, if you set "core.columns = auto" without additional command line arguments, then it only shows column layout when it's good to do.

-- 
Duy
Previous: René ScharfeNext: Junio C Hamano
Message 21 of 24 in “Support columinized output in tag/branch/ls-files/grep”
  1. 00/12 Support columinized output in tag/branch/ls-files/grepNguyễn Thái Ngọc Duy, Mar 7, 2010
  2. 01/12 Move term_columns() to pager.cNguyễn Thái Ngọc Duy, Mar 7, 2010
  3. 02/12 setup_pager(): save terminal width before redirecting stdoutNguyễn Thái Ngọc Duy, Mar 7, 2010
  4. 03/12 Add columnizerNguyễn Thái Ngọc Duy, Mar 7, 2010
  5. 04/12 help: use columnizerNguyễn Thái Ngọc Duy, Mar 7, 2010
  6. 05/12 Add builtin command "column"Nguyễn Thái Ngọc Duy, Mar 7, 2010
  7. 06/12 Add helpers to redirect stdout to "git column"Nguyễn Thái Ngọc Duy, Mar 7, 2010
  8. 07/12 add core.columnsNguyễn Thái Ngọc Duy, Mar 7, 2010
  9. 08/12 tag: support column output with --columnsNguyễn Thái Ngọc Duy, Mar 7, 2010
  10. 09/12 branch: support column output with --columnsNguyễn Thái Ngọc Duy, Mar 7, 2010
  11. 10/12 ls-files: support column output with --columnsNguyễn Thái Ngọc Duy, Mar 7, 2010
  12. 11/12 grep: do not return early in cmd_grep() if there is no errorNguyễn Thái Ngọc Duy, Mar 7, 2010
  13. 12/12 grep: support column output with --columnsNguyễn Thái Ngọc Duy, Mar 7, 2010
  14. René ScharfeMar 8, 2010
  15. Nguyen Thai Ngoc DuyMar 8, 2010
  16. René ScharfeMar 9, 2010
  17. Nguyen Thai Ngoc DuyMar 10, 2010
  18. Johannes SixtMar 10, 2010
  19. Nguyen Thai Ngoc DuyMar 10, 2010
  20. René ScharfeMar 11, 2010
  21. Nguyen Thai Ngoc DuyMar 12, 2010
  22. Junio C HamanoMar 8, 2010
  23. Nguyen Thai Ngoc DuyMar 9, 2010
  24. Junio C HamanoMar 9, 2010

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.