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

Re: [RFC/PATCH 1/9] ref-filter: add %(refname:lalignX) option

From
Karthik Nayak <karthik.188@gmail.com>
Date
Jun 28, 2015, 09:13 UTC
Message-ID
<CAOLa=ZTkq9NWSu-Bd1iwxYD1yj9+URuQSopc_qjgxSbBv2t2uA@mail.gmail.com>
In-Reply-To
<xmqqsi9ce0xj.fsf@gitster.dls.corp.google.com>
On Sun, Jun 28, 2015 at 1:09 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 21 quoted lines
> Karthik Nayak <karthik.188@gmail.com> writes:
>
>> Add support for %(refname:lalignX) where X is a number.
>> This will print a shortened refname aligned to the left
>> followed by spaces for a total length of X characters.
>> If X is less than the shortened refname size, the entire
>> shortened refname is printed.
>
> Why would we even want this kind of thing in the first place?  Is
> this to make it possible to re-implement some option that exists
> already in 'git branch' or 'git tag' as a thin wrapper on top of
> this underlying feature?
> As a low-level plumbing, I'd rather not to see such an elaborate
> formatting option added to for-each-ref; after all, the design of
> the command to allow its output properly script-quoted is so that we
> can offload such non-essential (meaning: does not need anything only
> Git knows; computing the display width of a string and filling the
> output space is an example.  As opposed to something like --merged
> that needs help from Git, which has the ultimate knowledge on the
> topology) processing to Porcelain that uses the command as plumbing.
>

Well this is to support the printing of tag in `git tag -l`, if you see the current implementation we print refs using "printf("%-15s ", refname);" whenever the "-n[<n>]" option is given, hence this patch to support printing of refs using a required spacing.

I couldn't find a way to do with the current options available in for-each-ref/ref-filter. Is there a better way to go about this?

-- 
Regards,
Karthik Nayak
Previous: Junio C HamanoNext: Junio C Hamano
Message 22 of 23 in “port tag.c to use ref-filter library”
  1. 0/9 port tag.c to use ref-filter libraryKarthik Nayak, Jun 25, 2015
  2. 1/9 ref-filter: add %(refname:lalignX) optionKarthik Nayak, Jun 25, 2015
  3. 2/9 ref-filter: add option to filter only tagsKarthik Nayak, Jun 25, 2015
  4. 3/9 ref-filter: support printing N lines from tag annotationKarthik Nayak, Jun 25, 2015
  5. 4/9 ref-filter: add support to sort by versionKarthik Nayak, Jun 25, 2015
  6. Duy NguyenJul 12, 2015
  7. Karthik NayakJul 12, 2015
  8. 5/9 ref-filter: add option to match literal patternKarthik Nayak, Jun 25, 2015
  9. Karthik NayakJun 26, 2015
  10. Junio C HamanoJun 29, 2015
  11. Karthik NayakJun 30, 2015
  12. 6/9 tag.c: use 'ref-filter' data structuresKarthik Nayak, Jun 25, 2015
  13. 7/9 tag.c: use 'ref-filter' APIsKarthik Nayak, Jun 25, 2015
  14. 8/9 tag.c: implement '--format' optionKarthik Nayak, Jun 25, 2015
  15. 8/9 tag.c: implement '--format' optionKarthik Nayak, Jun 25, 2015
  16. 9/9 tag.c: implement '--merged' and '--no-merged' optionsKarthik Nayak, Jun 25, 2015
  17. Christian CouderJun 27, 2015
  18. Christian CouderJun 28, 2015
  19. Karthik NayakJun 28, 2015
  20. Duy NguyenJun 27, 2015
  21. Junio C HamanoJun 28, 2015
  22. Karthik NayakJun 28, 2015
  23. Junio C HamanoJun 29, 2015

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.