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

Re: [PATCH 1/3] pretty: Pass graph width to pretty formatting for use in '%>|(N)'

From
Duy Nguyen <pclouds@gmail.com>
Date
Dec 22, 2015, 17:03 UTC
Message-ID
<CACsJy8C8DCi_pZDd=m1hE70t7Z+MX3j6WcMe-Hp-u0y5VvwKqg@mail.gmail.com>
In-Reply-To
<xmqqa8sfa7di.fsf@gitster.mtv.corp.google.com>

(I'm joining the newer thread [1] back to this one, thanks for reminding me about this)

[1] http://thread.gmane.org/gmane.comp.version-control.git/282771
On Tue, Sep 22, 2015 at 2:40 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 57 quoted lines
> Josef Kufner <josef@kufner.cz> writes:
>
>> Pass graph width to pretty formatting, so N in '%>|(N)' includes columns
>> consumed by graph rendered when --graph option is in use.
>>
>> Example:
>>   git log --all --graph --pretty='format: [%>|(20)%h] %ar%d'
>>
>>   All commit hashes should be aligned at 20th column from edge of the
>>   terminal, not from the edge of the graph.
>>
>> Signed-off-by: Josef Kufner <josef@kufner.cz>
>> ---
>
> [CC'ed Duy for ideas, as the "%>|(ALIGN)" thing is his invention]
>
> If you imagine an entry for a commit in the "git log" output as a
> rectangle that has its commit log message, "--graph" draws a bunch
> of lines on the left hand side and place these rectangles on the
> right of these lines.  Space allocated to each of these rectangles
> may and do begin at a different column.  For example, here is an
> output from
>
>  $ git log -12 --graph --oneline
>
>  *   7d211c9 Merge branch 'jk/graph-format-padding' into pu
>  |\
>  | * ead86db pretty: pass graph width to pretty formatting
>  * |   5be4874 Merge branch 'ld/p4-detached-head' into pu
>  |\ \
>  | * | 4086903 git-p4: work with a detached head
>  | * | 6d2be82 git-p4: add failing test for submit from detached
>  head
>  * | |   7cec6a3 Merge branch 'ls/p4-lfs' into pu
>  |\ \ \
>  | * | | 5fac7db git-p4: add Git LFS backend for large file system
>  | * | | 53b938f git-p4: add support for large file systems
>  | * | | 760e31c git-p4: return an empty list if a list config has
>  no values
>  | * | | c1e88b8 git-p4: add gitConfigInt reader
>  | * | | 465af7a git-p4: add optional type specifier to gitConfig
>  reader
>  * | | |   5197bd3 Merge branch 'nd/clone-linked-checkout' into pu
>
> I can understand why you would want to include the varying width of
> the river on the left hand side in the "space allocated for the
> commit", and under that mental model, the patch makes sense, but at
> the same time, it is also a perfectly good specification to make
> "%>|(20)%h" pad "%h" to 20 columns from the left edge of the space
> given to the commit.
>
> I have a suspicion that 50% of the users would appreciate this
> change, and the remainder of the users see this break their
> expectation.  To avoid such a regression, we may be better off if we
> introduced a new alignment operator that is different from '%>|(N)'
> so that this new behaviour is available to those who want to use it,
> without negatively affecting existing uses.

I tend to agree with Josef. >|(N) is about columns relative to the left edge of the screen. You can already use >(N) to be relative to the left edge of the space given to the commit.

-- 
Duy
Previous: Junio C HamanoNext: Junio C Hamano
Message 5 of 6 in “pretty: Pass graph width to pretty formatting for use in '%>|(N)'”
  1. 1/3 pretty: Pass graph width to pretty formatting for use in '%>|(N)'Josef Kufner, Sep 11, 2015
  2. 2/3 Add tests for "pretty: Pass graph width to pretty formatting for use in '%>|(N)'"Josef Kufner, Sep 11, 2015
  3. 3/3 t4205: remove unnecessary use of qz_to_tab_spaceJosef Kufner, Sep 11, 2015
  4. Junio C HamanoSep 21, 2015
  5. Duy NguyenDec 22, 2015
  6. Junio C HamanoDec 22, 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.