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

[PATCH 07/11] sequencer.c: teach append_signoff to avoid adding a duplicate newline

From
Brandon Casey <drafnel@gmail.com>
Date
Nov 26, 2012, 01:45 UTC
Message-ID
<1353894359-6733-8-git-send-email-drafnel@gmail.com>
In-Reply-To
<1353894359-6733-1-git-send-email-drafnel@gmail.com>

Teach append_signoff to detect whether a blank line exists at the position that the signed-off-by line will be added, and avoid adding an additional one if one already exists. This is necessary to allow format-patch to add a s-o-b to a patch with no commit message without adding an extra newline. A following patch will make format-patch use this function rather than the append_signoff implementation inside log-tree.c.

Signed-off-by: Brandon Casey <bcasey@nvidia.com>
---
 sequencer.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sequencer.c b/sequencer.c
index 3062ad4..eb93dd6 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -1103,8 +1103,8 @@ void append_signoff(struct strbuf *msgbuf, int ignore_footer, int no_dup_sob)
 	strbuf_addch(&sob, '\n');
 	for (i = msgbuf->len - 1 - ignore_footer; i > 0 && msgbuf->buf[i - 1] != '\n'; i--)
 		; /* do nothing */
-	if (!i || !(has_footer =
-		has_conforming_footer(msgbuf, &sob, ignore_footer)))
+	if (msgbuf->buf[i] != '\n' && (!i || !(has_footer =
+		has_conforming_footer(msgbuf, &sob, ignore_footer))))
 		strbuf_splice(msgbuf, msgbuf->len - ignore_footer, 0, "\n", 1);
 	if (has_footer != 3 && (!no_dup_sob || has_footer != 2))
 		strbuf_splice(msgbuf, msgbuf->len - ignore_footer, 0,
-- 
1.8.0.284.g959048a
Previous: Junio C HamanoNext: Brandon Casey
Message 11 of 18 in “alternative unify appending of sob”
  1. 00/11 alternative unify appending of sobBrandon Casey, Nov 26, 2012
  2. 01/11 sequencer.c: remove broken support for rfc2822 continuation in footerBrandon Casey, Nov 26, 2012
  3. 02/11 t/test-lib-functions.sh: allow to specify the tag name to test_commitBrandon Casey, Nov 26, 2012
  4. 03/11 t/t3511: add some tests of 'cherry-pick -s' functionalityBrandon Casey, Nov 26, 2012
  5. 04/11 sequencer.c: recognize "(cherry picked from ..." as part of s-o-b footerBrandon Casey, Nov 26, 2012
  6. Junio C HamanoNov 29, 2012
  7. Brandon CaseyNov 29, 2012
  8. 05/11 sequencer.c: always separate "(cherry picked from" from commit bodyBrandon Casey, Nov 26, 2012
  9. 06/11 sequencer.c: teach append_signoff how to detect duplicate s-o-bBrandon Casey, Nov 26, 2012
  10. Junio C HamanoNov 29, 2012
  11. 07/11 sequencer.c: teach append_signoff to avoid adding a duplicate newlineBrandon Casey, Nov 26, 2012
  12. 08/11 t4014: more tests about appending s-o-b linesBrandon Casey, Nov 26, 2012
  13. 09/11 format-patch: stricter S-o-b detectionBrandon Casey, Nov 26, 2012
  14. 10/11 format-patch: update append_signoff prototypeBrandon Casey, Nov 26, 2012
  15. 11/11 Unify appending signoff in format-patch, commit and sequencerBrandon Casey, Nov 26, 2012
  16. Nguyen Thai Ngoc DuyNov 26, 2012
  17. Junio C HamanoNov 29, 2012
  18. Junio C HamanoNov 26, 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.