Re: [PATCH v15 05/13] ref-filter: implement an `align` atom
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Sep 3, 2015, 14:12 UTC
- Message-ID
- <CAPig+cRfYow-wBvorX44E4ROH=nvQdS=3zBaEVVbQZf86JFELw@mail.gmail.com>
- In-Reply-To
- <1441131994-13508-6-git-send-email-Karthik.188@gmail.com>
On Tue, Sep 1, 2015 at 2:26 PM, Karthik Nayak <karthik.188@gmail.com> wrote:
> Implement an `align` atom which left-, middle-, or right-aligns the > content between %(align:..) and %(end).
Spell this either %(align:) or %(align:...) with three dots, not two. I, personally, think %(align:) is sufficient.
Show 14 quoted lines
> It is followed by `:<width>,<position>`, where the `<position>` is > either left, right or middle and `<width>` is the size of the area > into which the content will be placed. If the content between > %(align:) and %(end) is more than the width then no alignment is > performed. e.g. to align a refname atom to the middle with a total > width of 40 we can do: --format="%(align:middle,40)%(refname)%(end)". > > We have an `at_end` function for each element of the stack which is to > be called when the `end` atom is encountered. Using this we implement > the aling_handler() for the `align` atom, this aligns the final strbuf > by calling `strbuf_utf8_align()` from utf8.c. > > Ensure that quote formatting is performed on the whole of > %(align)...%(end) rather than individual atoms inside. We skip quote
Add colon: %(align:)
> formatting for individual atoms when the current stack element is > handling an %(align) atom and perform quote formatting at the end when
%(align:)
Show 16 quoted lines
> we encounter the %(end) atom. > > Add documentation and tests for the same. > > Signed-off-by: Karthik Nayak <karthik.188@gmail.com> > --- > diff --git a/Documentation/git-for-each-ref.txt b/Documentation/git-for-each-ref.txt > index e49d578..cac3128 100644 > --- a/Documentation/git-for-each-ref.txt > +++ b/Documentation/git-for-each-ref.txt > @@ -127,6 +127,15 @@ color:: > Change output color. Followed by `:<colorname>`, where names > are described in `color.branch.*`. > > +align:: > + Left-, middle-, or right-align the content between %(align:..)
%(align:)
Show 6 quoted lines
> + and %(end). Followed by `:<width>,<position>`, where the > + `<position>` is either left, right or middle and `<width>` is > + the total length of the content with alignment. If the > + contents length is more than the width then no alignment is > + performed. If used with '--quote' everything in between > + %(align:..) and %(end) is quoted.
%(align:) Also drop the extra space before "and": s/\s+and/ and/
> In addition to the above, for commit and tag objects, the header > field names (`tree`, `parent`, `object`, `type`, and `tag`) can > be used to specify the value in the header field.