Skip to content

Conversation

@john-cai
Copy link

@john-cai john-cai commented Oct 21, 2021

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 --field-format= used in conjunction with --oneline. is similar to what is passed into --format.

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

This will allow for more flexible formatting of the --oneline format.

cc: Christian Couder christian.couder@gmail.com
cc: John Cai jcai@gitlab.com

@gitgitgadget
Copy link

gitgitgadget bot commented Oct 21, 2021

There is an issue in commit 194fff0:
Commit checks stopped - the message is too short

@gitgitgadget
Copy link

gitgitgadget bot commented Oct 21, 2021

There is an issue in commit 5058519:
Commit checks stopped - the message is too short

@dscho
Copy link
Member

dscho commented Oct 22, 2021

@john-cai please follow the guidance given in https://git-scm.com/docs/SubmittingPatches#describe-changes to craft commit messages in the style preferred by the Git project.

@john-cai
Copy link
Author

@dscho will do! please don't hesitate to call out any missteps as I'm starting to learn this process

@chriscool
Copy link

I think some users are likely to be happy with the current --oneline format, so this new format should likely has a different name.

Also it would be nice if you could show how the result looks like. And at one point you might want to update the docs.

@john-cai john-cai force-pushed the jc/two-line-pretty-decoration branch 3 times, most recently from eebd562 to 0b96396 Compare October 27, 2021 17:37
@john-cai
Copy link
Author

git log --pretty=oneline --newlinefor=decorations

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' 0 

git log --pretty=oneline

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' 06355d72dc610ec3806cda328ec9b347a5daed5b Merge branch 'ab/pkt-line-cleanup' 
@john-cai john-cai force-pushed the jc/two-line-pretty-decoration branch 3 times, most recently from 27e17fe to 3bcc1f0 Compare October 27, 2021 19:35
@john-cai john-cai force-pushed the jc/two-line-pretty-decoration branch from 3bcc1f0 to a461c81 Compare October 28, 2021 20:56
@gitgitgadget
Copy link

gitgitgadget bot commented Oct 28, 2021

There are issues in commit 6f8ddfd:
First line of commit message is too long (> 76 columns): object-name.c: refactor find_unique_abbrev_len into its own exported function
Commit not signed off

@gitgitgadget
Copy link

gitgitgadget bot commented Oct 28, 2021

There is an issue in commit 208db1c:
Commit not signed off

@gitgitgadget
Copy link

gitgitgadget bot commented Oct 28, 2021

There is an issue in commit a461c81:
Commit not signed off

@john-cai john-cai force-pushed the jc/two-line-pretty-decoration branch from a461c81 to d81b934 Compare October 28, 2021 21:17
@gitgitgadget
Copy link

gitgitgadget bot commented Oct 28, 2021

There is an issue in commit 781dbc1:
First line of commit message is too long (> 76 columns): object-name.c: refactor find_unique_abbrev_len into its own exported function

@john-cai john-cai force-pushed the jc/two-line-pretty-decoration branch 3 times, most recently from 5dc7023 to 3254fbc Compare October 29, 2021 01:27
@john-cai
Copy link
Author

@chriscool good point about not exposing new methods in cache.h. I refactored a bit and I was able to use existing methods 👍

@john-cai john-cai force-pushed the jc/two-line-pretty-decoration branch 3 times, most recently from eb42208 to ca73f61 Compare October 29, 2021 15:22
@gitgitgadget
Copy link

gitgitgadget bot commented Oct 29, 2021

There is an issue in commit d51b3f7:
Commit checks stopped - the message is too short

@john-cai john-cai force-pushed the jc/two-line-pretty-decoration branch from ca73f61 to ec76bf1 Compare October 29, 2021 16:07
@gitgitgadget
Copy link

gitgitgadget bot commented Oct 29, 2021

There is an issue in commit e7639bd:
Commit checks stopped - the message is too short

@john-cai john-cai force-pushed the jc/two-line-pretty-decoration branch 2 times, most recently from 3bdb611 to a184df1 Compare October 29, 2021 16:52
@gitgitgadget
Copy link

gitgitgadget bot commented Oct 29, 2021

There is an issue in commit d06184e:
Commit checks stopped - the message is too short

@gitgitgadget
Copy link

gitgitgadget bot commented Oct 29, 2021

There is an issue in commit b1c1403:
Commit checks stopped - the message is too short

@john-cai john-cai force-pushed the jc/two-line-pretty-decoration branch 2 times, most recently from 5ad2024 to 7684922 Compare October 29, 2021 20:20
@john-cai
Copy link
Author

/preview

@gitgitgadget
Copy link

gitgitgadget bot commented Oct 29, 2021

@john-cai
Copy link
Author

/preview

@gitgitgadget
Copy link

gitgitgadget bot commented Oct 29, 2021

@john-cai john-cai force-pushed the jc/two-line-pretty-decoration branch from 7684922 to c13f36f Compare October 29, 2021 21:05
@john-cai
Copy link
Author

/preview

@gitgitgadget
Copy link

gitgitgadget bot commented Oct 29, 2021

* revision.h: add newlineafter flag type * builtin/log.c: parse newlineafter flag with callback Signed-off-by: John Cai <johncai86@gmail.com>
* log-tree.c: pass in format, oneline, abbrev so format_decorations can print a newline with an indentation. * log-tree.h: adding parameters in header file * pretty.c: pass in arguments format, oneline to format_decorations call but these don't get used in this context Signed-off-by: John Cai <johncai86@gmail.com>
Signed-off-by: John Cai <johncai86@gmail.com>
Provide documentation for --newlineafter flag Signed-off-by: John Cai <johncai86@gmail.com>
@john-cai john-cai force-pushed the jc/two-line-pretty-decoration branch from c13f36f to 57b2079 Compare October 29, 2021 21:12
@john-cai
Copy link
Author

/submit

@gitgitgadget
Copy link

gitgitgadget bot commented Oct 29, 2021

Submitted as pull.1065.git.1635542128.gitgitgadget@gmail.com

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git pr-1065/john-cai/jc/two-line-pretty-decoration-v1 

To fetch this version to local tag pr-1065/john-cai/jc/two-line-pretty-decoration-v1:

git fetch --no-tags https://github.com/gitgitgadget/git tag pr-1065/john-cai/jc/two-line-pretty-decoration-v1 
@gitgitgadget
Copy link

gitgitgadget bot commented Nov 12, 2021

On the Git mailing list, Christian Couder wrote (reply to this):

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! 
@gitgitgadget
Copy link

gitgitgadget bot commented Nov 12, 2021

User Christian Couder <christian.couder@gmail.com> has been added to the cc: list.

@gitgitgadget
Copy link

gitgitgadget bot commented Nov 21, 2021

On the Git mailing list, John Cai wrote (reply to this):

On Fri, Nov 12, 2021 at 05:27:45PM +0100, Christian Couder wrote: > 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> 
@gitgitgadget
Copy link

gitgitgadget bot commented Nov 21, 2021

User John Cai <jcai@gitlab.com> has been added to the cc: list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants