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

Re: git notes: notes

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 20, 2010, 21:59 UTC
Message-ID
<7v3a201lpz.fsf@alter.siamese.dyndns.org>
In-Reply-To
<7veilk1o3s.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 15 quoted lines
> Michael J Gruber <git@drmicha.warpmail.net> writes:
>
>> No, but outputting the note as part of the log is the standard. So for
>> example, when you do a format-patch | apply cycle, format-patch will
>> insert the note as part of the commit message, and apply will *store*
>> the note text (including Note:\n) as part of the commit message of the
>> new commit.
>
> Thanks; that was the kind of breakage report I was looking for (and wished
> to have heard a lot earlier).  Personally I find it is unexcusable that
> format-patch defaults to giving notes.
>
>> So, I would say the notes feature is not that well integrated right now,
>
> No question about it.
How about solving it this way?

It _could_ break some tests, if the set of tests were carefully written to cover not only the positive ("I am showing off my shiny new toy") cases but also the negative ("These commands share the same codepath touched by the series, but I don't intend to change their behaviour, and here is to make sure the new toy does not affect them") cases and the latter set assumed it is ok to sprinkle notes in commit log messages without being asked, but I haven't tried running the test suite yet.

---
Subject: Fix "log" family not to be too agressive about showing notes

Giving "Notes" information in the default output format of "log" and "show" is a sensible progress (the user has asked for it by having the notes), but for some commands (e.g. "format-patch") spewing notes into the formatted commit log message without being asked is too aggressive.

Enable notes output only for "log", "show", "whatchanged" by default; other users can ask for it by setting show_notes field to true.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 builtin-log.c |    2 ++
 commit.h      |    1 +
 log-tree.c    |    1 +
 pretty.c      |    2 +-
 revision.c    |    4 ++++
 revision.h    |    1 +
 6 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/builtin-log.c b/builtin-log.c
index 41b6df4..da0ba1d 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -41,6 +41,8 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,
 	rev->commit_format = CMIT_FMT_DEFAULT;
 	if (fmt_pretty)
 		get_commit_format(fmt_pretty, rev);
+	else
+		rev->show_notes = 1;
 	rev->verbose_header = 1;
 	DIFF_OPT_SET(&rev->diffopt, RECURSIVE);
 	rev->show_root_diff = default_show_root;
diff --git a/commit.h b/commit.h
index e5332ef..2c0742b 100644
--- a/commit.h
+++ b/commit.h
@@ -70,6 +70,7 @@ struct pretty_print_context
 	const char *after_subject;
 	enum date_mode date_mode;
 	int need_8bit_cte;
+	int show_notes;
 	struct reflog_walk_info *reflog_info;
 };
 
diff --git a/log-tree.c b/log-tree.c
index 0fdf159..27afcf6 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -284,6 +284,7 @@ void show_log(struct rev_info *opt)
 	struct pretty_print_context ctx = {0};
 
 	opt->loginfo = NULL;
+	ctx.show_notes = opt->show_notes;
 	if (!opt->verbose_header) {
 		graph_show_commit(opt->graph);
 
diff --git a/pretty.c b/pretty.c
index 8f5bd1a..b2ee7fe 100644
--- a/pretty.c
+++ b/pretty.c
@@ -1094,7 +1094,7 @@ void pretty_print_commit(enum cmit_fmt fmt, const struct commit *commit,
 	if (fmt == CMIT_FMT_EMAIL && sb->len <= beginning_of_body)
 		strbuf_addch(sb, '\n');
 
-	if (fmt != CMIT_FMT_ONELINE)
+	if (context->show_notes)
 		get_commit_notes(commit, sb, encoding,
 				 NOTES_SHOW_HEADER | NOTES_INDENT);
 
diff --git a/revision.c b/revision.c
index 25fa14d..03c280f 100644
--- a/revision.c
+++ b/revision.c
@@ -1165,6 +1165,10 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
 	} else if (!prefixcmp(arg, "--pretty=") || !prefixcmp(arg, "--format=")) {
 		revs->verbose_header = 1;
 		get_commit_format(arg+9, revs);
+	} else if (!strcmp(arg, "--show-notes")) {
+		revs->show_notes = 1;
+	} else if (!strcmp(arg, "--no-notes")) {
+		revs->show_notes = 0;
 	} else if (!strcmp(arg, "--oneline")) {
 		revs->verbose_header = 1;
 		get_commit_format("oneline", revs);
diff --git a/revision.h b/revision.h
index d368003..4167c1e 100644
--- a/revision.h
+++ b/revision.h
@@ -80,6 +80,7 @@ struct rev_info {
 	/* Format info */
 	unsigned int	shown_one:1,
 			show_merge:1,
+			show_notes:1,
 			abbrev_commit:1,
 			use_terminator:1,
 			missing_newline:1,
Previous: Jeff KingNext: Jeff King
Message 19 of 36 in “git notes: notes”
  1. Joey HessJan 20, 2010
  2. Thomas RastJan 20, 2010
  3. Joey HessJan 20, 2010
  4. Johan HerlandJan 20, 2010
  5. Joey HessJan 20, 2010
  6. Junio C HamanoJan 20, 2010
  7. Joey HessJan 20, 2010
  8. Junio C HamanoJan 20, 2010
  9. Joey HessJan 20, 2010
  10. Jeff KingJan 20, 2010
  11. Junio C HamanoJan 20, 2010
  12. Jeff KingJan 20, 2010
  13. Jeff KingJan 20, 2010
  14. Junio C HamanoJan 20, 2010
  15. Jeff KingJan 20, 2010
  16. Michael J GruberJan 20, 2010
  17. Junio C HamanoJan 20, 2010
  18. Jeff KingJan 20, 2010
  19. Junio C HamanoJan 20, 2010
  20. Jeff KingJan 20, 2010
  21. Junio C HamanoJan 20, 2010
  22. Johannes SchindelinJan 20, 2010
  23. Jeff KingJan 20, 2010
  24. Junio C HamanoJan 20, 2010
  25. Johan HerlandJan 21, 2010
  26. Junio C HamanoJan 21, 2010
  27. Junio C HamanoJan 21, 2010
  28. Michael J GruberJan 21, 2010
  29. Matthieu MoyJan 24, 2010
  30. Sverre RabbelierJan 24, 2010
  31. Johan HerlandJan 21, 2010
  32. Johannes SchindelinJan 21, 2010
  33. Joey HessJan 21, 2010
  34. Johan HerlandJan 27, 2010
  35. John KoleszarJan 25, 2010
  36. Christian CouderJan 27, 2010

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.