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

Re: [PATCH/WIP 0/9] for-each-ref format improvements

From
Duy Nguyen <pclouds@gmail.com>
Date
May 19, 2013, 11:54 UTC
Message-ID
<CACsJy8DMF3NzvMRUO56H+EwpXSjmY9qzdNdv9cGJ9XxUO=ekJA@mail.gmail.com>
In-Reply-To
<CALkWK0=7z91A54jSzc2yZU3g50u8H_f8su1Y+i=D+KxYtqor5g@mail.gmail.com>

On Sun, May 19, 2013 at 6:11 PM, Ramkumar Ramachandra <artagnon@gmail.com> wrote:

Show 7 quoted lines
> Nguyễn Thái Ngọc Duy wrote:
>> The purpose of this series is to make "for-each-ref --format" powerful
>> enough to display what "branch -v" and "branch -vv" do so that we
>> could get rid of those display code and use for-each-ref code instead.
>
> Damn, you beat me to it.  I just introduced color, and was working on
> alignment.  See $gmane/224692.

Hmm.. I missed that mail (or I wouldn't have worked on this already). Do you want to take over?

Show 7 quoted lines
>>  - %(tracking[:upstream]) gives us the exact output that branch -v[v]
>>    does. %(upstream) does not include []. We can't change its
>>    semantics.
>
> There's already an atom called "upstream", and "upstream:short" works.
>  Why not introduce "upstream:diff" for "[ahead x, behind y]" and
> "upstream:shortdiff" for "<>" (like in the prompt)?

"branch -vv" shows [upstream: ahead x, behind y]. We need a syntax to cover that too.

Show 6 quoted lines
>>  - %(color:...) is pretty much the same as %C family in pretty code.
>>    I haven't added code for %(color:foo) == %C(foo) yet. There's a
>>    potential ambiguity here: %C(red) == %Cred or %C(red)??
>
> I'd vote for dropping %C<name> altogether and just go with %C(<name>).
>  Why do we need %(color:<name>) at all?

pretty and for-each-ref format seem to be on the opposite: one is terse, one verbose. Unless you are going to introduce a lot of new specifiers (and in the worst case, bring all pretty specifiers over, unify underlying code), I think we should stick with %(xx) convention.

Show 8 quoted lines
>>  - %(...:aligned) to do left aligning. I'm not entirely sure about
>>    this. We might be able to share code with %>, %< and %>< from
>>    pretty.c. But we need improvements there too because in
>>    for-each-ref case, we could calculate column width but %< would
>>    require the user to specify the width.
>
> Yeah, I think we should go with the %> and %< you introduced in
> pretty.c.  Yes, I want to be able to specify width.

I still think we should follow %(...), e.g. %(left:N), %(right:N) as equivalent of %< and %>...

Show 5 quoted lines
>>    Do people expect fancy layout with for-each-ref (and branch)? If so
>>    we might need to have %(align) or something instead of the simple
>>    left alignment case in %(...:aligned)
>
> Why should we deviate from the pretty case?  What is different here?
Laziness plays a big factor :) So again, you want to take over? ;)
Show 11 quoted lines
>>  - We may need an equivalent of the space following % in pretty
>>    format. If the specifier produces something, then prepend a space,
>>    otherwise produce nothing. Do it like %C( tracking) vs
>>    %C(tracking)??
>
> Yeah, sounds good.
>
>> You can try this after applying the series, which should give you the
>> about close to 'branch -v'. %(tracking) coloring does not work though.
>
> Why doesn't %(tracking) coloring work?

it uses builtin/branch.c:branch_use_color. Eventually fill_tracking_info() should be moved to for-each-ref.c and pass branch_use_color in as an argument. But for now, I just leave it broken. -- Duy

Previous: Felipe ContrerasNext: Ramkumar Ramachandra
Message 26 of 31 in “for-each-ref format improvements”
  1. 0/9 for-each-ref format improvementsNguyễn Thái Ngọc Duy, May 19, 2013
  2. 1/9 quote.c: make sq_quote_print a slight wrapper of sq_quote_bufNguyễn Thái Ngọc Duy, May 19, 2013
  3. Felipe ContrerasMay 19, 2013
  4. 2/9 for-each-ref: convert to use *_quote_buf instead of _quote_printNguyễn Thái Ngọc Duy, May 19, 2013
  5. Felipe ContrerasMay 19, 2013
  6. 3/9 for-each-ref: avoid printing each element directly to stdoutNguyễn Thái Ngọc Duy, May 19, 2013
  7. Ramkumar RamachandraMay 19, 2013
  8. Duy NguyenMay 19, 2013
  9. 4/9 for-each-ref: add %(current) for current branch markerNguyễn Thái Ngọc Duy, May 19, 2013
  10. Ramkumar RamachandraMay 19, 2013
  11. 5/9 for-each-ref: add %(tracking[:upstream]) for tracking infoNguyễn Thái Ngọc Duy, May 19, 2013
  12. Ramkumar RamachandraMay 19, 2013
  13. Felipe ContrerasMay 19, 2013
  14. Duy NguyenMay 19, 2013
  15. Ramkumar RamachandraMay 19, 2013
  16. Felipe ContrerasMay 19, 2013
  17. 6/9 for-each-ref: add %(color:...)Nguyễn Thái Ngọc Duy, May 19, 2013
  18. Ramkumar RamachandraMay 19, 2013
  19. 7/9 for-each-ref: prepoplulate all atoms before show_ref()Nguyễn Thái Ngọc Duy, May 19, 2013
  20. 8/9 for-each-ref: merge show_ref into show_refsNguyễn Thái Ngọc Duy, May 19, 2013
  21. 9/9 for-each-ref: support %(...:aligned) for left alignmentNguyễn Thái Ngọc Duy, May 19, 2013
  22. Ramkumar RamachandraMay 19, 2013
  23. Duy NguyenMay 19, 2013
  24. Ramkumar RamachandraMay 19, 2013
  25. Felipe ContrerasMay 19, 2013
  26. Duy NguyenMay 19, 2013
  27. Ramkumar RamachandraMay 19, 2013
  28. Duy NguyenMay 19, 2013
  29. Ramkumar RamachandraMay 19, 2013
  30. Junio C HamanoMay 20, 2013
  31. Junio C HamanoMay 21, 2013

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.