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

Re: [PATCH] remote: align columns on -v

From
Kirill Kolyshkin <kolyshkin@gmail.com>
Date
Feb 9, 2023, 01:02 UTC
Message-ID
<CAGmPdrzpEvjCh8u4-FjsaE3tmqfiE3xyytO-++56JrjcMEgP=A@mail.gmail.com>
In-Reply-To
<20230208161222.guqqwlceqiy3jq7e@tb-raspi4>
On Wed, Feb 8, 2023 at 8:12 AM Torsten Bögershausen <tboegi@web.de> wrote:
Show 46 quoted lines
>
> On Tue, Feb 07, 2023 at 03:52:38PM -0800, Kir Kolyshkin wrote:
> > Currently, git remote -v produces a misaligned output when a remote name
> > is more than 8 characters long (i.e. longer than a tab step). Here's how
> > it looks like:
> >
> > giuseppe      https://github.com/giuseppe/runc (fetch)
> > giuseppe      https://github.com/giuseppe/runc (push)
> > kir   git@github.com:kolyshkin/runc.git (fetch)
> > kir   git@github.com:kolyshkin/runc.git (push)
> > lifubang      https://github.com/lifubang/runc (fetch)
> > lifubang      https://github.com/lifubang/runc (push)
> > marquiz       https://github.com/marquiz/runc (fetch)
> > marquiz       https://github.com/marquiz/runc (push)
> >
> > Let's find the maximum width and use it for alignment.
> >
> > While at it, let's keep the \t in case some tools depend on it
> > for parsing (there will still be trailing spaces in the remote name).
> >
> > With this change, the output is like this now:
> >
> > giuseppe      https://github.com/giuseppe/runc (fetch)
> > giuseppe      https://github.com/giuseppe/runc (push)
> > kir           git@github.com:kolyshkin/runc.git (fetch)
> > kir           git@github.com:kolyshkin/runc.git (push)
> > lifubang      https://github.com/lifubang/runc (fetch)
> > lifubang      https://github.com/lifubang/runc (push)
> > marquiz       https://github.com/marquiz/runc (fetch)
> > marquiz       https://github.com/marquiz/runc (push)
> >
>
> Thanks for working on that  - I had the same wish as well.
> However, I am tempted to comment on some details here.
> Especially, what happens if a remote is named with a non-ASCII
> character (unicode code point would be a better term) ?
> To determine the width on screen for aligment, strlen()
> does the wrong thing here.
> This has been done at other place (being UTF-8 aware),
> you may want to have a look at this change:
>
>   commit 12fc4ad89e23af642a8614371ff80bc67cb3315d
>   Author: Torsten Bögershausen <tboegi@web.de>
>   Date:   Wed Sep 14 17:13:33 2022 +0200
>
>       diff.c: use utf8_strwidth() to count display width

Yes, I have seen now that neither strlen nor printf with the specified width do a good job with unicode. Thank you for pointing this out, I'll send v2 soon.

Previous: Junio C HamanoNext: Junio C Hamano
Message 4 of 7 in “remote: align columns on -v”
  1. remote: align columns on -vKir Kolyshkin, Feb 7, 2023
  2. Torsten BögershausenFeb 8, 2023
  3. Junio C HamanoFeb 8, 2023
  4. Kirill KolyshkinFeb 9, 2023
  5. Junio C HamanoFeb 8, 2023
  6. Kirill KolyshkinFeb 9, 2023
  7. remote: align columns on -vKir Kolyshkin, Feb 9, 2023

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.