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

Re: [PATCH 6/6] format-patch --notes: show notes after three-dashes

From
Philip Oakley <philipoakley@iee.org>
Date
Oct 18, 2012, 21:35 UTC
Message-ID
<C2D3CE0879B345FFAC2A6487760B5378@PhilipOakley>
In-Reply-To
<1350539128-21577-7-git-send-email-gitster@pobox.com>
From: "Junio C Hamano" <gitster@pobox.com>
Show 6 quoted lines
> When inserting the note after the commit log message to format-patch
> output, add three dashes before the note.  Record the fact that we
> did so in the rev_info and omit showing duplicated three dashes in
> the usual codepath that is used when notes are not being shown.
>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Should this also include a documentation update to make this substantive benefit visible, whether that be in the format-patch man pages, the SubmittingPatches guide, in the git-notes description of 'A typical use...', or even in the user-manual?

Do you have a preference?
Show 94 quoted lines
> ---
> log-tree.c              | 15 +++++++++++----
> revision.h              |  1 +
> t/t4014-format-patch.sh |  7 +++++--
> 3 files changed, 17 insertions(+), 6 deletions(-)
>
> diff --git a/log-tree.c b/log-tree.c
> index 4390b11..712a22b 100644
> --- a/log-tree.c
> +++ b/log-tree.c
> @@ -677,8 +677,13 @@ void show_log(struct rev_info *opt)
>  append_signoff(&msgbuf, opt->add_signoff);
>
>  if ((ctx.fmt != CMIT_FMT_USERFORMAT) &&
> -     ctx.notes_message && *ctx.notes_message)
> +     ctx.notes_message && *ctx.notes_message) {
> + if (ctx.fmt == CMIT_FMT_EMAIL) {
> + strbuf_addstr(&msgbuf, "---\n");
> + opt->shown_dashes = 1;
> + }
>  strbuf_addstr(&msgbuf, ctx.notes_message);
> + }
>
>  if (opt->show_log_size) {
>  printf("log size %i\n", (int)msgbuf.len);
> @@ -710,6 +715,7 @@ void show_log(struct rev_info *opt)
>
> int log_tree_diff_flush(struct rev_info *opt)
> {
> + opt->shown_dashes = 0;
>  diffcore_std(&opt->diffopt);
>
>  if (diff_queue_is_empty()) {
> @@ -737,10 +743,11 @@ int log_tree_diff_flush(struct rev_info *opt)
>  opt->diffopt.output_prefix_data);
>  fwrite(msg->buf, msg->len, 1, stdout);
>  }
> - if ((pch & opt->diffopt.output_format) == pch) {
> - printf("---");
> + if (!opt->shown_dashes) {
> + if ((pch & opt->diffopt.output_format) == pch)
> + printf("---");
> + putchar('\n');
>  }
> - putchar('\n');
>  }
>  }
>  diff_flush(&opt->diffopt);
> diff --git a/revision.h b/revision.h
> index a95bd0b..059bfff 100644
> --- a/revision.h
> +++ b/revision.h
> @@ -111,6 +111,7 @@ struct rev_info {
>
>  /* Format info */
>  unsigned int shown_one:1,
> + shown_dashes:1,
>  show_merge:1,
>  show_notes:1,
>  show_notes_given:1,
> diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
> index bea6381..9750ba6 100755
> --- a/t/t4014-format-patch.sh
> +++ b/t/t4014-format-patch.sh
> @@ -623,9 +623,12 @@ test_expect_success 'format-patch --signoff' '
> test_expect_success 'format-patch --notes --signoff' '
>  git notes --ref test add -m "test message" HEAD &&
>  git format-patch -1 --signoff --stdout --notes=test >out &&
> - # Notes message must come after S-o-b
> + # Three dashes must come after S-o-b
>  ! sed "/^Signed-off-by: /q" out | grep "test message" &&
> - sed "1,/^Signed-off-by: /d" out | grep "test message"
> + sed "1,/^Signed-off-by: /d" out | grep "test message" &&
> + # Notes message must come after three dashes
> + ! sed "/^---$/q" out | grep "test message" &&
> + sed "1,/^---$/d" out | grep "test message"
> '
>
> echo "fatal: --name-only does not make sense" > expect.name-only
> -- 
> 1.8.0.rc3.112.gdb88a5e
>
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
>
> -----
> No virus found in this message.
> Checked by AVG - www.avg.com
> Version: 2013.0.2741 / Virus Database: 2614/5837 - Release Date: 
> 10/17/12
> 
Previous: Junio C HamanoNext: Junio C Hamano
Message 12 of 19 in “Bring "format-patch --notes" closer to a real feature”
  1. 0/6 Bring "format-patch --notes" closer to a real featureJunio C Hamano, Oct 18, 2012
  2. 1/6 pretty: remove reencode_commit_message()Junio C Hamano, Oct 18, 2012
  3. 2/6 format_note(): simplify APIJunio C Hamano, Oct 18, 2012
  4. 3/6 pretty: prepare notes message at a centralized placeJunio C Hamano, Oct 18, 2012
  5. Jeff KingOct 18, 2012
  6. Junio C HamanoOct 18, 2012
  7. Jeff KingOct 18, 2012
  8. strbuf: always return a non-NULL value from strbuf_detachJeff King, Oct 18, 2012
  9. 4/6 pretty_print_commit(): do not append notes messageJunio C Hamano, Oct 18, 2012
  10. 5/6 format-patch: append --signature after notesJunio C Hamano, Oct 18, 2012
  11. 6/6 format-patch --notes: show notes after three-dashesJunio C Hamano, Oct 18, 2012
  12. Philip OakleyOct 18, 2012
  13. Junio C HamanoOct 18, 2012
  14. Junio C HamanoOct 19, 2012
  15. Philip OakleyOct 21, 2012
  16. Jeff KingOct 18, 2012
  17. Nguyen Thai Ngoc DuyOct 18, 2012
  18. Michael J GruberOct 18, 2012
  19. Junio C HamanoOct 18, 2012

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.