threads / discuss / 57521

git notes question

Subject: git notes question

## tl;dr

9 messages between Mar 8, 2022 and Mar 11, 2022.

replies: 8people: 3as markdown or json

Nuno Sá· Mar 8, 2022, 13:08 UTC · lore
Hi all,
Sorry if this is something already asked before...

Is there any way to remove the default "Notes:" line on git-notes? I don't really mind to have it in git log but when generating patches for instance, I would like my notes to be something like:

commit title
message

tags... ---

v3:
  notes on v3
v2:
  notes on v2
instead of having it like:

... ---

Notes:
    ...

I did some code inspection and I guess that using a USER format would be a way but I'm hopping there's a more direct way.

Thanks!
- Nuno Sá
Erik Cervin Edin· Mar 9, 2022, 08:54 UTC · re: Nuno Sá · lore

Re: git notes question

Hi Nuno!
> Is there any way to remove the default "Notes:" line on git-notes? I
> don't really mind to have it in git log but when generating patches for
> instance, I would like my notes to be something like:
Just to be clear, in relation to which command are we talking about?

For git-format-patch there's --notes which I assume doesn't support customization.

For git-log it's possible to customize how notes appear in git-log
using the standard way of formatting log messages, pretty format.
%N
is for the commit notes
https://git-scm.com/docs/pretty-formats#Documentation/pretty-formats.txt-emNem
For example
  git log --pretty=format:%h%n%N
displays each short hash and it's corresponding note.

It's also possible to use it when generating todos for git-rebase, however, they are written with a prepended new-line which breaks the todo script :/

Nuno Sá· Mar 9, 2022, 09:11 UTC · re: Erik Cervin Edin · lore

Re: git notes question

Hi Erik,
On Wed, 2022-03-09 at 09:54 +0100, Erik Cervin Edin wrote:
Show 14 quoted lines
> Hi Nuno!
> 
> > Is there any way to remove the default "Notes:" line on git-notes?
> > I
> > don't really mind to have it in git log but when generating patches
> > for
> > instance, I would like my notes to be something like:
> 
> Just to be clear, in relation to which command are we talking about?
> 
> For git-format-patch there's
> --notes
> which I assume doesn't support customization.
> 

Well, this is the one I would like (hoped) that we could do something about. When I do '--notes' in git-format-patch, I will always see:

``` (Typical git commit) ...

---
(I just wanted "Notes:" to be removed and my notes to start at the
beginning of the line).
Notes: 
	(my notes go here)
...

AFAICT, git-format-patch looks to be using --pretty=email and I think we can use --pretty in git-format-patch but having to mimic the email format "by hand" is just painful and I was hoping a better way could exist.

```
> For git-log it's possible to customize how notes appear in git-log
> using the standard way of formatting log messages, pretty format.
> %N
> is for the commit notes

I'm aware of this and by briefly looking into the source code this seemed the only way to actually remove those predefined strings from notes (I was just hoping I was wrong).

> 
Thanks for the feedback!
- Nuno Sá
Junio C Hamano· Mar 9, 2022, 18:02 UTC · re: Nuno Sá · lore

Re: git notes question

Nuno Sá <noname.nuno@gmail.com> writes:
> AFAICT, git-format-patch looks to be using --pretty=email and I think
> we can use --pretty in git-format-patch but having to mimic the email
> format "by hand" is just painful and I was hoping a better way could
> exist.

Well, this time it was "Notes:" label, but the next person who wants to see a deviation from the canned "email" format would want a deviation different from yours. Perhaps they want a different way to format the author name? Perhaps they want a different way to separate the title (to be on the "Subject:" line) out of the commit message? Perhaps they want to see the log message be indented? Perhaps they want to see the message from the notes be line-wrapped? Perhaps they want to see the message from the notes not to be indented? Perhaps they want to see the "Notes (amlog):" label to format the name of the notes tree differently?

Where would that end?  We have to draw the line somewhere.

The customizability via --format=<template> is given for these people who want to futz with that line. One thing that may be a good little project to help them is to make sure that the vanilla "--pretty=email" can be reimplemented as "--format=<template>" (I doubt it is), design a way to fill the gaps (if there are) to get there. Once that is done, write down the "--format=<template>" that is equivalent to "--pretty=email" somewhere in the doc, to give those who want to derive from the canned format some reasonable starting point.

Nuno Sá· Mar 10, 2022, 08:37 UTC · re: Junio C Hamano · lore

Re: git notes question

On Wed, 2022-03-09 at 10:02 -0800, Junio C Hamano wrote:
Show 13 quoted lines
> Nuno Sá <noname.nuno@gmail.com> writes:
> 
> > AFAICT, git-format-patch looks to be using --pretty=email and I
> > think
> > we can use --pretty in git-format-patch but having to mimic the
> > email
> > format "by hand" is just painful and I was hoping a better way
> > could
> > exist.
> 
> Well, this time it was "Notes:" label, but the next person who
> wants to see a deviation from the canned "email" format would want a
> deviation different from yours.  Perhaps they want a different way

I'm surely missing something but I'm not sure this is specific to the email format? It's just that git-notes by default will always either append the "Notes:" or "Notes (<refname>):" independent of the predefined format you use. The only way to stop it from doing that is, apparently, by using your own --format=<template>...

What I was asking was just if there was a way to not use these default strings. I don't think this would open all kind of deviations... Either you use these default strings or don't. But I think these strings are probably used/important for git log? So we can know what is commit message and what are notes...

Show 19 quoted lines
> to format the author name?  Perhaps they want a different way to
> separate the title (to be on the "Subject:" line) out of the commit
> message?  Perhaps they want to see the log message be indented?
> Perhaps they want to see the message from the notes be line-wrapped?
> Perhaps they want to see the message from the notes not to be
> indented?  Perhaps they want to see the "Notes (amlog):" label to
> format the name of the notes tree differently?
> 
> Where would that end?  We have to draw the line somewhere.
> 
> The customizability via --format=<template> is given for these
> people who want to futz with that line.  One thing that may be a
> good little project to help them is to make sure that the vanilla
> "--pretty=email" can be reimplemented as "--format=<template>" (I
> doubt it is), design a way to fill the gaps (if there are) to get
> there.  Once that is done, write down the "--format=<template>" that
> is equivalent to "--pretty=email" somewhere in the doc, to give
> those who want to derive from the canned format some reasonable
> starting point.

Well, this would be surely nice. For now, I will just remove it by hand or script something to do it before calling git-send-email.

Thanks for the feedback!
- Nuno Sá
Erik Cervin Edin· Mar 10, 2022, 13:11 UTC · re: Nuno Sá · lore

Re: git notes question

> What I was asking was just if there was a way to not use these default
> strings.

Forgive me but I'm somewhat perplexed as to why you want to change it. Is there a specific use-case where this is a problem or is it a personal preference? Maybe you have a good reason and my imagination isn't stretching that far.

> Well, this would be surely nice. For now, I will just remove it by hand
> or script something to do it before calling git-send-email.
Here's a simples sed that changes Notes: to setoN:
  sed '/^---$/{N;N;/^---\n\nNotes:$/s@Notes:@setoN:@}'
Nuno Sá· Mar 10, 2022, 13:26 UTC · re: Erik Cervin Edin · lore

Re: git notes question

On Thu, 2022-03-10 at 14:11 +0100, Erik Cervin Edin wrote:
Show 10 quoted lines
> > What I was asking was just if there was a way to not use these
> > default
> > strings.
> 
> Forgive me but I'm somewhat perplexed as to why you want to change
> it.
> Is there a specific use-case where this is a problem or is it a
> personal preference? Maybe you have a good reason and my imagination
> isn't stretching that far.
> 

I think there are some misunderstanding here :). I'm not requesting to change it. I was just asking if there was a way (already implemented and other than custom --format to get rid of it). And yes, this boils down to personal preference and on how git-notes are typically written in linux kernel mailing lists in patch series. I was actually writing them by hand when I realized I could use git-notes and create patches with them (and that these notes could "survive" to rebases so that it would be easier to have them placed across versions of the series).

- Nuno Sá
Junio C Hamano· Mar 10, 2022, 17:52 UTC · re: Nuno Sá · lore

Re: git notes question

Nuno Sá <noname.nuno@gmail.com> writes:
Show 12 quoted lines
>> Well, this time it was "Notes:" label, but the next person who
>> wants to see a deviation from the canned "email" format would want a
>> deviation different from yours.  Perhaps they want a different way
>
> I'm surely missing something but I'm not sure this is specific to the
> email format? It's just that git-notes by default will always either
> append the "Notes:" or "Notes (<refname>):" independent of the
> predefined format you use. The only way to stop it from doing that is,
> apparently, by using your own --format=<template>...
> ...
> What I was asking was just if there was a way to not use these default
> strings. I don't think this would open all kind of deviations.

Not limited to the email format. "git log" will always prefix "Author: " before the commit author name, "Date: " date with extra paddingbefore the author, indents the log message by 4 spaces, adds "Notes (refname):" before notes, and indentation is given before the contents of the notes. There are many things, other than the presence of the "Notes" label, that people may want to customize in the output from the commands in the "git log" family, including "git format-patch".

I think you were too focused on "Notes" tree to lose the view of the forest. A line is drawn not to special case "Notes" prefix, because there is no reason to do so without allowing all other things to also be tweaked, and it will "open all kind of deviations".

Nuno Sá· Mar 11, 2022, 09:02 UTC · re: Junio C Hamano · lore

Re: git notes question

On Thu, 2022-03-10 at 09:52 -0800, Junio C Hamano wrote:
Show 30 quoted lines
> Nuno Sá <noname.nuno@gmail.com> writes:
> 
> > > Well, this time it was "Notes:" label, but the next person who
> > > wants to see a deviation from the canned "email" format would
> > > want a
> > > deviation different from yours.  Perhaps they want a different
> > > way
> > 
> > I'm surely missing something but I'm not sure this is specific to
> > the
> > email format? It's just that git-notes by default will always
> > either
> > append the "Notes:" or "Notes (<refname>):" independent of the
> > predefined format you use. The only way to stop it from doing that
> > is,
> > apparently, by using your own --format=<template>...
> > ...
> > What I was asking was just if there was a way to not use these
> > default
> > strings. I don't think this would open all kind of deviations.
> 
> Not limited to the email format.  "git log" will always prefix
> "Author: " before the commit author name, "Date: " date with extra
> paddingbefore the author, indents the log message by 4 spaces, adds
> "Notes (refname):" before notes, and indentation is given before the
> contents of the notes.  There are many things, other than the
> presence of the "Notes" label, that people may want to customize in
> the output from the commands in the "git log" family, including "git
> format-patch".
> 

Alright... Now I got it. There's already lot of things that 'git log' and friends print by default that there's no reason to give special treatment to "Notes:". That would indeed open the box for all kind of request.

Having a way to mimic email (or others) template in --format would indeed be nice though :).

- Nuno Sá
> 

← back to recent threads