* [PATCH/RFC 1/2] notes/pretty: allow callers to set the notes format from struct rev_info
@ 2011-04-26 8:54 Michael J Gruber
2011-04-26 8:54 ` [PATCH/RFC 2/2] format-patch: show notes as message after the --- Michael J Gruber
0 siblings, 1 reply; 6+ messages in thread
From: Michael J Gruber @ 2011-04-26 8:54 UTC (permalink / raw)
To: git
The notes display format is customisable, but this possibility is hidden
from callers which go through struct rev_info's show_notes member and the
pretty-machinery.
Change the show_notes member to an int which determines the format, and
set it to NOTES_DEFAULT (which is NOTES_SHOW_HEADER | NOTES_INDENT)
where we set it to 1 before. This allows callers to choose a different
form.
The only form which cannot be chosen that way is "bare" (no indent, no
header) because "0" means "do not show notes" for this code path. But
current callers which need that (e.g. "%N" processing) call the notes
formatters directly instead. And for future callers which need to
request "bare" through rev_info's show_notes we can always introduce
another notes format flag NOTES_BARE when we need it.
No functional change with this commit.
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
builtin/log.c | 2 +-
notes.h | 1 +
pretty.c | 2 +-
revision.c | 4 ++--
revision.h | 2 +-
5 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/builtin/log.c b/builtin/log.c
index 9db43ed..5e71caa 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -81,7 +81,7 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,
userformat_find_requirements(NULL, &w);
if (!rev->show_notes_given && (!rev->pretty_given || w.notes))
- rev->show_notes = 1;
+ rev->show_notes = NOTES_DEFAULT;
if (rev->show_notes)
init_display_notes(&rev->notes_opt);
diff --git a/notes.h b/notes.h
index 83bd6e0..81d16e3 100644
--- a/notes.h
+++ b/notes.h
@@ -238,6 +238,7 @@ void free_notes(struct notes_tree *t);
/* Flags controlling how notes are formatted */
#define NOTES_SHOW_HEADER 1
#define NOTES_INDENT 2
+#define NOTES_DEFAULT (NOTES_SHOW_HEADER | NOTES_INDENT)
/*
* Fill the given strbuf with the notes associated with the given object.
diff --git a/pretty.c b/pretty.c
index e1d8a8f..dc371a4 100644
--- a/pretty.c
+++ b/pretty.c
@@ -1271,7 +1271,7 @@ void pretty_print_commit(enum cmit_fmt fmt, const struct commit *commit,
if (context->show_notes)
format_display_notes(commit->object.sha1, sb, encoding,
- NOTES_SHOW_HEADER | NOTES_INDENT);
+ context->show_notes);
free(reencoded);
}
diff --git a/revision.c b/revision.c
index 0f38364..f24ffb8 100644
--- a/revision.c
+++ b/revision.c
@@ -1366,11 +1366,11 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
revs->pretty_given = 1;
get_commit_format(arg+9, revs);
} else if (!strcmp(arg, "--show-notes")) {
- revs->show_notes = 1;
+ revs->show_notes = NOTES_DEFAULT;
revs->show_notes_given = 1;
} else if (!prefixcmp(arg, "--show-notes=")) {
struct strbuf buf = STRBUF_INIT;
- revs->show_notes = 1;
+ revs->show_notes = NOTES_DEFAULT;
revs->show_notes_given = 1;
if (!revs->notes_opt.extra_notes_refs)
revs->notes_opt.extra_notes_refs = xcalloc(1, sizeof(struct string_list));
diff --git a/revision.h b/revision.h
index 9fd8f30..e50eb49 100644
--- a/revision.h
+++ b/revision.h
@@ -84,9 +84,9 @@ struct rev_info {
always_show_header:1;
/* Format info */
+ unsigned int show_notes;
unsigned int shown_one:1,
show_merge:1,
- show_notes:1,
show_notes_given:1,
pretty_given:1,
abbrev_commit:1,
--
1.7.5.270.gafca7
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH/RFC 2/2] format-patch: show notes as message after the ---
2011-04-26 8:54 [PATCH/RFC 1/2] notes/pretty: allow callers to set the notes format from struct rev_info Michael J Gruber
@ 2011-04-26 8:54 ` Michael J Gruber
2011-04-26 9:28 ` Johan Herland
2011-04-26 17:39 ` Junio C Hamano
0 siblings, 2 replies; 6+ messages in thread
From: Michael J Gruber @ 2011-04-26 8:54 UTC (permalink / raw)
To: git
When requesting notes with "--notes", "format-patch" produces notes
within the commit message which "am" misunderstands as being part of the
message.
Change this so that notes are displayed after an additional "---". Any
"am" (old or new) will ignore that, so that it is a safe place for
additional comments:
Log message
"---"
notes
"---"
diffstat
patch
(The first "---" appears only when there is a note, of course.)
Later on (say with "--format-notes") the output format can be changed
easily to accomodate a future "am" which knows how to create notes from
such patches.
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
Reducing the output format to one "---" only is not only complicated (the notes
separator is generated in a quite different place from the patch separator)
but also unnecessary (am reads the patch anyways) and not even preferable (to
give a clear separation of the parts).
---
builtin/log.c | 4 +++-
notes.c | 2 ++
notes.h | 3 +++
3 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/builtin/log.c b/builtin/log.c
index 5e71caa..67aed94 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -1159,8 +1159,10 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
if (!DIFF_OPT_TST(&rev.diffopt, TEXT) && !no_binary_diff)
DIFF_OPT_SET(&rev.diffopt, BINARY);
- if (rev.show_notes)
+ if (rev.show_notes) {
init_display_notes(&rev.notes_opt);
+ rev.show_notes = NOTES_DASH;
+ }
if (!use_stdout)
output_directory = set_outdir(prefix, output_directory);
diff --git a/notes.c b/notes.c
index a013c1b..b8b737e 100644
--- a/notes.c
+++ b/notes.c
@@ -1233,6 +1233,8 @@ void format_note(struct notes_tree *t, const unsigned char *object_sha1,
if (msglen && msg[msglen - 1] == '\n')
msglen--;
+ if (flags & NOTES_DASH)
+ strbuf_addstr(sb, "---\n");
if (flags & NOTES_SHOW_HEADER) {
const char *ref = t->ref;
if (!ref || !strcmp(ref, GIT_NOTES_DEFAULT_REF)) {
diff --git a/notes.h b/notes.h
index 81d16e3..17150d5 100644
--- a/notes.h
+++ b/notes.h
@@ -238,6 +238,7 @@ void free_notes(struct notes_tree *t);
/* Flags controlling how notes are formatted */
#define NOTES_SHOW_HEADER 1
#define NOTES_INDENT 2
+#define NOTES_DASH 4
#define NOTES_DEFAULT (NOTES_SHOW_HEADER | NOTES_INDENT)
/*
@@ -284,6 +285,8 @@ void init_display_notes(struct display_notes_opt *opt);
*
* - NOTES_INDENT: indent the notes by 4 places
*
+ * - NOTES_DASH: prepend a "---" line
+ *
* You *must* call init_display_notes() before using this function.
*/
void format_display_notes(const unsigned char *object_sha1,
--
1.7.5.270.gafca7
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH/RFC 2/2] format-patch: show notes as message after the ---
2011-04-26 8:54 ` [PATCH/RFC 2/2] format-patch: show notes as message after the --- Michael J Gruber
@ 2011-04-26 9:28 ` Johan Herland
2011-04-26 9:44 ` Michael J Gruber
2011-04-26 17:39 ` Junio C Hamano
1 sibling, 1 reply; 6+ messages in thread
From: Johan Herland @ 2011-04-26 9:28 UTC (permalink / raw)
To: Michael J Gruber; +Cc: git
On Tuesday 26 April 2011, Michael J Gruber wrote:
> When requesting notes with "--notes", "format-patch" produces notes
> within the commit message which "am" misunderstands as being part of
> the message.
>
> Change this so that notes are displayed after an additional "---".
> Any "am" (old or new) will ignore that, so that it is a safe place
> for additional comments:
>
> Log message
> "---"
> notes
> "---"
> diffstat
> patch
>
> (The first "---" appears only when there is a note, of course.)
>
> Later on (say with "--format-notes") the output format can be changed
> easily to accomodate a future "am" which knows how to create notes
> from such patches.
>
> Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Acked-by: Johan Herland <johan@herland.net>
(goes for 1/2 as well)
/me likes :)
...Johan
--
Johan Herland, <johan@herland.net>
www.herland.net
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH/RFC 2/2] format-patch: show notes as message after the ---
2011-04-26 9:28 ` Johan Herland
@ 2011-04-26 9:44 ` Michael J Gruber
0 siblings, 0 replies; 6+ messages in thread
From: Michael J Gruber @ 2011-04-26 9:44 UTC (permalink / raw)
To: Johan Herland; +Cc: git
Johan Herland venit, vidit, dixit 26.04.2011 11:28:
> On Tuesday 26 April 2011, Michael J Gruber wrote:
>> When requesting notes with "--notes", "format-patch" produces notes
>> within the commit message which "am" misunderstands as being part of
>> the message.
>>
>> Change this so that notes are displayed after an additional "---".
>> Any "am" (old or new) will ignore that, so that it is a safe place
>> for additional comments:
>>
>> Log message
>> "---"
>> notes
>> "---"
>> diffstat
>> patch
>>
>> (The first "---" appears only when there is a note, of course.)
>>
>> Later on (say with "--format-notes") the output format can be changed
>> easily to accomodate a future "am" which knows how to create notes
>> from such patches.
>>
>> Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
>
> Acked-by: Johan Herland <johan@herland.net>
>
> (goes for 1/2 as well)
>
>
> /me likes :)
Thanks :)
BTW: Just before hitting "send-mail", I thought of quoting the "---" in
my commit message where I describe the format. I wonder what would have
happened else when am-ing that message...
Michael
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH/RFC 2/2] format-patch: show notes as message after the ---
2011-04-26 8:54 ` [PATCH/RFC 2/2] format-patch: show notes as message after the --- Michael J Gruber
2011-04-26 9:28 ` Johan Herland
@ 2011-04-26 17:39 ` Junio C Hamano
2011-04-27 6:37 ` Michael J Gruber
1 sibling, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2011-04-26 17:39 UTC (permalink / raw)
To: Michael J Gruber; +Cc: git
Michael J Gruber <git@drmicha.warpmail.net> writes:
> When requesting notes with "--notes", "format-patch" produces notes
> within the commit message which "am" misunderstands as being part of the
> message.
>
> Change this so that notes are displayed after an additional "---". Any
> "am" (old or new) will ignore that, so that it is a safe place for
> additional comments:
>
> Log message
> "---"
> notes
> "---"
> diffstat
> patch
>
> (The first "---" appears only when there is a note, of course.)
>
> Later on (say with "--format-notes") the output format can be changed
> easily to accomodate a future "am" which knows how to create notes from
> such patches.
>
> Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
> ---
> Reducing the output format to one "---" only is not only complicated (the notes
> separator is generated in a quite different place from the patch separator)
> but also unnecessary (am reads the patch anyways) and not even preferable (to
> give a clear separation of the parts).
> ---
If you show more than one note, separating them with "---" in between
would be a good idea so that reader can tell where each note ends, but I'd
rather not to see the "---" after the last note. Put just a blank line
here instead.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH/RFC 2/2] format-patch: show notes as message after the ---
2011-04-26 17:39 ` Junio C Hamano
@ 2011-04-27 6:37 ` Michael J Gruber
0 siblings, 0 replies; 6+ messages in thread
From: Michael J Gruber @ 2011-04-27 6:37 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
Junio C Hamano venit, vidit, dixit 26.04.2011 19:39:
> Michael J Gruber <git@drmicha.warpmail.net> writes:
>
>> When requesting notes with "--notes", "format-patch" produces notes
>> within the commit message which "am" misunderstands as being part of the
>> message.
>>
>> Change this so that notes are displayed after an additional "---". Any
>> "am" (old or new) will ignore that, so that it is a safe place for
>> additional comments:
>>
>> Log message
>> "---"
>> notes
>> "---"
>> diffstat
>> patch
>>
>> (The first "---" appears only when there is a note, of course.)
>>
>> Later on (say with "--format-notes") the output format can be changed
>> easily to accomodate a future "am" which knows how to create notes from
>> such patches.
>>
>> Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
>> ---
>> Reducing the output format to one "---" only is not only complicated (the notes
>> separator is generated in a quite different place from the patch separator)
>> but also unnecessary (am reads the patch anyways) and not even preferable (to
>> give a clear separation of the parts).
>> ---
>
> If you show more than one note, separating them with "---" in between
> would be a good idea so that reader can tell where each note ends, but I'd
It does that already. More precisely, each note is preceded by a "---\n".
> rather not to see the "---" after the last note. Put just a blank line
> here instead.
Well, in the note which you snipped, I tried to explain that that is
complicated (the note code would need to set a flag "dash_output" which
the log-tree code would need to look at) and may not even be preferable,
because the "---" gives a clear separation between the note and the
diffstat. I'll check whether there's an easy way (and provide a test).
Michael
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-04-27 6:38 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-26 8:54 [PATCH/RFC 1/2] notes/pretty: allow callers to set the notes format from struct rev_info Michael J Gruber
2011-04-26 8:54 ` [PATCH/RFC 2/2] format-patch: show notes as message after the --- Michael J Gruber
2011-04-26 9:28 ` Johan Herland
2011-04-26 9:44 ` Michael J Gruber
2011-04-26 17:39 ` Junio C Hamano
2011-04-27 6:37 ` Michael J Gruber
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).