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

[PATCH v2 00/10] unify appending of sob

From
Brandon Casey <drafnel@gmail.com>
Date
Jan 21, 2013, 08:40 UTC
Message-ID
<1358757627-16682-1-git-send-email-drafnel@gmail.com>

Here's version 2 of the unify-appending-of-sob series. Hopefully this addresses the comments made on the first series:

   http://thread.gmane.org/gmane.comp.version-control.git/210390

The main difference is that the detection of the "(cherry picked from ...)" line has been relaxed, and the modifications to log-tree.c have been dropped.

Here's the inter-diff of this series against the original series, both built on top of 2d242fb3fc19fc9ba046accdd9210be8b9913f64 (the actual series in the following emails is of course built on top of master).

diff --git a/revision.h b/revision.h
index 435a60b..d20defa 100644
--- a/revision.h
+++ b/revision.h
@@ -137,7 +137,7 @@ struct rev_info {
 	int		numbered_files;
 	char		*message_id;
 	struct string_list *ref_message_ids;
-	int              add_signoff;
+	int		add_signoff;
 	const char	*extra_headers;
 	const char	*log_reencode;
 	const char	*subject_prefix;
diff --git a/sequencer.c b/sequencer.c
index eb93dd6..54b3cb9 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -36,13 +36,18 @@ static int is_rfc2822_line(const char *buf, int len)
 	return 1;
 }
 
-static int is_cherry_pick_from_line(const char *buf, int len)
+static int is_cherry_picked_from_line(const char *buf, int len)
 {
-	return (strlen(cherry_picked_prefix) + 41) <= len &&
-		!prefixcmp(buf, cherry_picked_prefix);
+	/*
+	 * We only care that it looks roughly like (cherry picked from ...)
+	 */
+	return !prefixcmp(buf, cherry_picked_prefix) &&
+		(buf[len - 1] == ')' ||
+		 (buf[len - 1] == '\n' && buf[len - 2] == ')'));
 }
 
-/* Returns 0 for non-conforming footer
+/*
+ * Returns 0 for non-conforming footer
  * Returns 1 for conforming footer
  * Returns 2 when sob exists within conforming footer
  * Returns 3 when sob exists within conforming footer as last entry
@@ -51,7 +56,7 @@ static int has_conforming_footer(struct strbuf *sb, struct strbuf *sob,
 	int ignore_footer)
 {
 	int hit = 0;
-	int i, k = 0;
+	int i, k;
 	int len = sb->len - ignore_footer;
 	const char *buf = sb->buf;
 	int found_sob = 0;
@@ -76,12 +81,13 @@ static int has_conforming_footer(struct strbuf *sb, struct strbuf *sob,
 			; /* do nothing */
 		k++;
 
-		found_rfc2822 = is_rfc2822_line(buf+i, k-i);
+		found_rfc2822 = is_rfc2822_line(buf + i, k - i);
 		if (found_rfc2822 && sob &&
-			!strncasecmp(buf+i, sob->buf, sob->len))
+			!strncmp(buf + i, sob->buf, sob->len))
 			found_sob = k;
 
-		if (!(found_rfc2822 || is_cherry_pick_from_line(buf+i, k-i)))
+		if (!(found_rfc2822 ||
+			is_cherry_picked_from_line(buf + i, k - i)))
 			return 0;
 	}
 	if (found_sob == i)
@@ -1103,11 +1109,20 @@ 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 (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 (msgbuf->buf[i] != '\n') {
+		if (i)
+			has_footer = has_conforming_footer(msgbuf, &sob,
+					ignore_footer);
+
+		if (!has_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,
 				sob.buf, sob.len);
+
 	strbuf_release(&sob);
 }
diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
index c53dc4b..6d00e43 100755
--- a/t/t4014-format-patch.sh
+++ b/t/t4014-format-patch.sh
@@ -1211,16 +1211,17 @@ subject
 
 body
 
+Reviewed-id: Noone
 Tested-by: my@house
 Change-id: Ideadbeef
 Signed-off-by: C O Mitter <committer@example.com>
-BUG: 1234
+Bug: 1234
 EOF
 	cat >expected <<\EOF &&
 4:Subject: [PATCH] subject
 8:
 10:
-13:Signed-off-by: C O Mitter <committer@example.com>
+14:Signed-off-by: C O Mitter <committer@example.com>
 EOF
 	test_cmp expected actual
 '

Brandon Casey (8):
  sequencer.c: remove broken support for rfc2822 continuation in footer
  t/test-lib-functions.sh: allow to specify the tag name to test_commit
  t/t3511: add some tests of 'cherry-pick -s' functionality
  sequencer.c: recognize "(cherry picked from ..." as part of s-o-b
    footer
  sequencer.c: always separate "(cherry picked from" from commit body
  sequencer.c: teach append_signoff how to detect duplicate s-o-b
  sequencer.c: teach append_signoff to avoid adding a duplicate newline
  Unify appending signoff in format-patch, commit and sequencer

Nguyễn Thái Ngọc Duy (2):
  t4014: more tests about appending s-o-b lines
  format-patch: update append_signoff prototype

 builtin/commit.c         |   2 +-
 builtin/log.c            |  13 +--
 log-tree.c               |  92 ++---------------
 revision.h               |   2 +-
 sequencer.c              | 146 +++++++++++++++++---------
 sequencer.h              |   2 +-
 t/t3511-cherry-pick-x.sh | 219 +++++++++++++++++++++++++++++++++++++++
 t/t4014-format-patch.sh  | 263 +++++++++++++++++++++++++++++++++++++++++++++++
 t/test-lib-functions.sh  |   9 +-
 9 files changed, 595 insertions(+), 153 deletions(-)
 create mode 100755 t/t3511-cherry-pick-x.sh
-- 
1.8.1.1.252.gdb33759
Next: Brandon Casey
Message 1 of 31 in “unify appending of sob”
  1. 00/10 unify appending of sobBrandon Casey, Jan 21, 2013
  2. 01/10 sequencer.c: remove broken support for rfc2822 continuation in footerBrandon Casey, Jan 21, 2013
  3. Jonathan NiederJan 22, 2013
  4. Brandon CaseyJan 22, 2013
  5. Jonathan NiederJan 22, 2013
  6. Jonathan NiederJan 22, 2013
  7. Brandon CaseyJan 22, 2013
  8. Jonathan NiederJan 22, 2013
  9. Jonathan NiederJan 22, 2013
  10. 02/10 t/test-lib-functions.sh: allow to specify the tag name to test_commitBrandon Casey, Jan 21, 2013
  11. Jonathan NiederJan 22, 2013
  12. Brandon CaseyJan 22, 2013
  13. 03/10 t/t3511: add some tests of 'cherry-pick -s' functionalityBrandon Casey, Jan 21, 2013
  14. Jonathan NiederJan 22, 2013
  15. Brandon CaseyJan 27, 2013
  16. Jonathan NiederJan 27, 2013
  17. 04/10 sequencer.c: recognize "(cherry picked from ..." as part of s-o-b footerBrandon Casey, Jan 21, 2013
  18. Jonathan NiederJan 22, 2013
  19. Jonathan NiederJan 28, 2013
  20. 05/10 sequencer.c: always separate "(cherry picked from" from commit bodyBrandon Casey, Jan 21, 2013
  21. Jonathan NiederJan 22, 2013
  22. 06/10 sequencer.c: teach append_signoff how to detect duplicate s-o-bBrandon Casey, Jan 21, 2013
  23. Jonathan NiederJan 22, 2013
  24. Brandon CaseyJan 28, 2013
  25. Junio C HamanoJan 28, 2013
  26. Junio C HamanoFeb 9, 2013
  27. Brandon CaseyFeb 9, 2013
  28. 07/10 sequencer.c: teach append_signoff to avoid adding a duplicate newlineBrandon Casey, Jan 21, 2013
  29. 08/10 t4014: more tests about appending s-o-b linesBrandon Casey, Jan 21, 2013
  30. 09/10 format-patch: update append_signoff prototypeBrandon Casey, Jan 21, 2013
  31. 10/10 Unify appending signoff in format-patch, commit and sequencerBrandon Casey, Jan 21, 2013

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.