git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* git notes question
@ 2022-03-08 13:08 Nuno Sá
  2022-03-09  8:54 ` Erik Cervin Edin
  0 siblings, 1 reply; 9+ messages in thread
From: Nuno Sá @ 2022-03-08 13:08 UTC (permalink / raw)
  To: git

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á

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: git notes question
  2022-03-08 13:08 git notes question Nuno Sá
@ 2022-03-09  8:54 ` Erik Cervin Edin
  2022-03-09  9:11   ` Nuno Sá
  0 siblings, 1 reply; 9+ messages in thread
From: Erik Cervin Edin @ 2022-03-09  8:54 UTC (permalink / raw)
  To: Nuno Sá; +Cc: git

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 :/

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: git notes question
  2022-03-09  8:54 ` Erik Cervin Edin
@ 2022-03-09  9:11   ` Nuno Sá
  2022-03-09 18:02     ` Junio C Hamano
  0 siblings, 1 reply; 9+ messages in thread
From: Nuno Sá @ 2022-03-09  9:11 UTC (permalink / raw)
  To: Erik Cervin Edin; +Cc: git

Hi Erik,

On Wed, 2022-03-09 at 09:54 +0100, Erik Cervin Edin wrote:
> 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á

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: git notes question
  2022-03-09  9:11   ` Nuno Sá
@ 2022-03-09 18:02     ` Junio C Hamano
  2022-03-10  8:37       ` Nuno Sá
  0 siblings, 1 reply; 9+ messages in thread
From: Junio C Hamano @ 2022-03-09 18:02 UTC (permalink / raw)
  To: Nuno Sá; +Cc: Erik Cervin Edin, git

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.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: git notes question
  2022-03-09 18:02     ` Junio C Hamano
@ 2022-03-10  8:37       ` Nuno Sá
  2022-03-10 13:11         ` Erik Cervin Edin
  2022-03-10 17:52         ` Junio C Hamano
  0 siblings, 2 replies; 9+ messages in thread
From: Nuno Sá @ 2022-03-10  8:37 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Erik Cervin Edin, git

On Wed, 2022-03-09 at 10:02 -0800, Junio C Hamano wrote:
> 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...

> 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á


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: git notes question
  2022-03-10  8:37       ` Nuno Sá
@ 2022-03-10 13:11         ` Erik Cervin Edin
  2022-03-10 13:26           ` Nuno Sá
  2022-03-10 17:52         ` Junio C Hamano
  1 sibling, 1 reply; 9+ messages in thread
From: Erik Cervin Edin @ 2022-03-10 13:11 UTC (permalink / raw)
  To: Nuno Sá; +Cc: Junio C Hamano, git

> 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:@}'

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: git notes question
  2022-03-10 13:11         ` Erik Cervin Edin
@ 2022-03-10 13:26           ` Nuno Sá
  0 siblings, 0 replies; 9+ messages in thread
From: Nuno Sá @ 2022-03-10 13:26 UTC (permalink / raw)
  To: Erik Cervin Edin; +Cc: Junio C Hamano, git

On Thu, 2022-03-10 at 14:11 +0100, Erik Cervin Edin wrote:
> > 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á




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: git notes question
  2022-03-10  8:37       ` Nuno Sá
  2022-03-10 13:11         ` Erik Cervin Edin
@ 2022-03-10 17:52         ` Junio C Hamano
  2022-03-11  9:02           ` Nuno Sá
  1 sibling, 1 reply; 9+ messages in thread
From: Junio C Hamano @ 2022-03-10 17:52 UTC (permalink / raw)
  To: Nuno Sá; +Cc: Erik Cervin Edin, git

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".

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".

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: git notes question
  2022-03-10 17:52         ` Junio C Hamano
@ 2022-03-11  9:02           ` Nuno Sá
  0 siblings, 0 replies; 9+ messages in thread
From: Nuno Sá @ 2022-03-11  9:02 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Erik Cervin Edin, git

On Thu, 2022-03-10 at 09:52 -0800, Junio C Hamano wrote:
> 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á
> 


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-03-11  9:01 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-08 13:08 git notes question Nuno Sá
2022-03-09  8:54 ` Erik Cervin Edin
2022-03-09  9:11   ` Nuno Sá
2022-03-09 18:02     ` Junio C Hamano
2022-03-10  8:37       ` Nuno Sá
2022-03-10 13:11         ` Erik Cervin Edin
2022-03-10 13:26           ` Nuno Sá
2022-03-10 17:52         ` Junio C Hamano
2022-03-11  9:02           ` Nuno Sá

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).