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

Re: [PATCH 0/4] Flag to add a newline after decorations for --oneline log output

From
John Cai <jcai@gitlab.com>
Date
Nov 21, 2021, 01:19 UTC
Message-ID
<20211121011928.srxogmaswqdmfd2c@Johns-MacBook-Pro-3.local>
In-Reply-To
<CAP8UFD3Uh7AJTFaVv25f7gGQkTxgMQTCO=NMHCWoSm9sjmw26g@mail.gmail.com>
On Fri, Nov 12, 2021 at 05:27:45PM +0100, Christian Couder wrote:
Show 48 quoted lines
> On Fri, Oct 29, 2021 at 11:17 PM John Cai via GitGitGadget
> <gitgitgadget@gmail.com> wrote:
> >
> > Add a flag --newlineafter to be able to pass in "decorations" to enable a
> > nicer format for the --oneline output so the commit subjects are aligned
> > when decorations are printed.
> 
> I wonder if --newlinebefore or --newlinefor rather than --newlineafter
> would be better. It seems to me that it would be easier for users to
> guess what the result will look like with --newlinefor.
> 
> Another possibly more generic solution would be something like
> --format-field=<field>:<format> where, in the output, the field
> <field> (which corresponds to the "%(<field>)" format) would be
> replaced by <format> which should contain "%(<field>)". For example
> `--format-field=decorations:'[[%(decorations)]]\n'` would enclose the
> decorations using [[...]] and would add a newline after them.
> 
> Also it would be nice if this could be extended to other fields and to
> formats other than "oneline". You might want to discuss a bit about
> how it could be done with generic code.
> 
> > 0b96396ef5ff7a3a01e137b3735893c970759dfa (HEAD -> jc/two-line-pretty-decoration, john-cai/jc/two-line-pretty-decoration)
> >                                          Improve UX for oneline with decorations
> > e9e5ba39a78c8f5057262d49e261b42a8660d5b9 (origin/master, origin/HEAD, master)
> >                                          The fifteenth batch
> > c6fc44e9bf85dc02f6d33b11d9b5d1e10711d125 Merge branch 'ab/test-lib-diff-cleanup'
> > 63ec2297d26155adb0e38745bf2284cd663add8e Merge branch 'ab/fix-make-lint-docs'
> 
> Not sure why the above lines are included in your cover letter.
> 
> > original thread in
> > https://lore.kernel.org/git/CA+55aFwT2HUBzZO8Gpt9tHoJtdRxv9oe3TDoSH5jcEOixRNBXg@mail.gmail.com/T/#t
> 
> It would be nice if you could summarize the threads a bit in this
> cover letter, and tell a bit about how your design evolved from what
> was discussed.
> 
> > John Cai (4):
> >   oneline: parse --newlineafter flag
> >   oneline: print newline after decorations if flag provided
> >   oneline: test for --newlineafter feature
> >   doc: add docs for newlineafter flag
> 
> The 2 last patches look very small and might want to be squashed into
> the patch that introduces the --newlineafter flag.
> 
> Thanks!
There was a discussion in https://lore.kernel.org/git/CA+55aFwT2HUBzZO8Gpt9tHoJtdRxv9oe3TDoSH5jcEOixRNBXg@mail.gmail.com/T/#t

about improving the --oneline output with decorations. To summarize, currently, when decorations are printed with --oneline the subject message ends up misaligned like so:

``` 7140c4988f t/lib-git.sh: fix ACL-related permissions failure 88d915a634 (jc-test-peff-revlist-patch) A few fixes before -rc2 9cc14a5b5d Sync with maint 5fbd2fc599 (origin/maint) Merge branch 'vd/pthread-setspecific-g11-fix' into maint 494cb27e57 Merge branch 'ma/doc-git-version' into maint ```

It would improve the user experience of this format if we could allow a newline after the decorations so that the logs are formatted in the following manner:

```
7140c4988f t/lib-git.sh: fix ACL-related permissions failure
88d915a634 (jc-test-peff-revlist-patch)
           A few fixes before -rc2
9cc14a5b5d Sync with maint
5fbd2fc599 (origin/maint)
           Merge branch 'vd/pthread-setspecific-g11-fix' into maint
494cb27e57 Merge branch 'ma/doc-git-version' into maint
```

In order to accomplish this, we can add a new flag called --format-field=<format>. <format> is similar to what is passed into --format.

For example, if --format-field=[[%d]]%n is used, the --oneline format will print decorations enclosed with [[ ]] and a newline after it.

This would be convenient when one wants to modify just one field of the log output.

cc: Christian Couder <christian.couder@gmail.com>
Previous: Christian Couder
Message 7 of 7 in “Flag to add a newline after decorations for --oneline log output”
  1. 0/4 Flag to add a newline after decorations for --oneline log outputJohn Cai via GitGitGadget, Oct 29, 2021
  2. 1/4 oneline: parse --newlineafter flagJohn Cai via GitGitGadget, Oct 29, 2021
  3. 2/4 oneline: print newline after decorations if flag providedJohn Cai via GitGitGadget, Oct 29, 2021
  4. 3/4 oneline: test for --newlineafter featureJohn Cai via GitGitGadget, Oct 29, 2021
  5. 4/4 doc: add docs for newlineafter flagJohn Cai via GitGitGadget, Oct 29, 2021
  6. Christian CouderNov 12, 2021
  7. John CaiNov 21, 2021

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.