for-each-ref format improvements
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest9 patches 21 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/9 | quote.c: make sq_quote_print a slight wrapper of sq_quote_bufquote.c | +4 | 1 reply | |
| 2/9 | for-each-ref: convert to use *_quote_buf instead of _quote_printbuiltin/ quote.c quote.h | +35 | 1 reply | |
| 3/9 | for-each-ref: avoid printing each element directly to stdoutbuiltin/ | +29 | 2 replies | |
| 4/9 | for-each-ref: add %(current) for current branch markerbuiltin/ | +13 | 1 reply | |
| 5/9 | for-each-ref: add %(tracking[:upstream]) for tracking infobuiltin/ builtin/ | +20 | 5 replies | |
| 6/9 | for-each-ref: add %(color:...)branch.h builtin/ builtin/ | +46 | 1 reply | |
| 7/9 | for-each-ref: prepoplulate all atoms before show_ref()builtin/ | +14 | 0 replies | |
| 8/9 | for-each-ref: merge show_ref into show_refsbuiltin/ | +19 | 0 replies | |
| 9/9 | for-each-ref: support %(...:aligned) for left alignmentbuiltin/ | +22 | 2 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH/WIP 0/9] for-each-ref format improvements
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.
The benefits are clear: share more code, branch can also borrow --sort and --format from for-each-ref, which should satisty users who are not happy with what -v and -vv provides.
This version has not gotten there yet. I just want to post quick and dirty changes and try to address some design issues.
Originally I wanted to introduce --pretty with git-log's pretty syntax to for-each-ref, deprecating --format. But because --format has to be there forever, we cannot remove its code, and the code change to make pretty code ready for displaying refs may not be small. So I went with enhancing --format syntax instead.
This series introduces:
- %(current), which either shows "*" if the ref is pointed by HEAD or a space. Junio called it %(headness). I don't like that. I don't like %(current) either but we have to start somewhere. Name suggestion? %(marker)??
- %(tracking[:upstream]) gives us the exact output that branch -v[v] does. %(upstream) does not include []. We can't change its semantics.
- %(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)??
- %(...: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.
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)
- 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)??
You can try this after applying the series, which should give you the about close to 'branch -v'. %(tracking) coloring does not work though.
git for-each-ref --format='%(current) %(color:auto)%(refname:short:aligned)%(color:reset) %%(objectname:short) %(tracking) %(subject)' 'refs/heads/*'
Nguyễn Thái Ngọc Duy (9):
quote.c: make sq_quote_print a slight wrapper of sq_quote_buf
for-each-ref: convert to use *_quote_buf instead of _quote_print
for-each-ref: avoid printing each element directly to stdout
for-each-ref: add %(current) for current branch marker
for-each-ref: add %(tracking[:upstream]) for tracking info
for-each-ref: add %(color:...)
for-each-ref: prepoplulate all atoms before show_ref()
for-each-ref: merge show_ref into show_refs
for-each-ref: support %(...:aligned) for left alignment
branch.h | 11 ++++ builtin/branch.c | 16 ++---- builtin/for-each-ref.c | 146 ++++++++++++++++++++++++++++++++++++++++++------- quote.c | 61 +++++++++------------ quote.h | 6 +- 5 files changed, 170 insertions(+), 70 deletions(-)
Signature · 1 line
1.8.2.83.gc99314b