From: Brandon Casey <drafnel@gmail.com>
To: gitster@pobox.com
Cc: pclouds@gmail.com, git@vger.kernel.org,
Brandon Casey <drafnel@gmail.com>
Subject: [PATCH v2 00/10] unify appending of sob
Date: Mon, 21 Jan 2013 00:40:17 -0800 [thread overview]
Message-ID: <1358757627-16682-1-git-send-email-drafnel@gmail.com> (raw)
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 reply other threads:[~2013-01-21 8:41 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-21 8:40 Brandon Casey [this message]
2013-01-21 8:40 ` [PATCH v2 01/10] sequencer.c: remove broken support for rfc2822 continuation in footer Brandon Casey
2013-01-22 7:54 ` Jonathan Nieder
2013-01-22 9:35 ` Brandon Casey
2013-01-22 9:47 ` Jonathan Nieder
2013-01-22 9:49 ` Jonathan Nieder
2013-01-22 11:08 ` Brandon Casey
2013-01-22 10:12 ` Jonathan Nieder
2013-01-22 10:21 ` Jonathan Nieder
2013-01-21 8:40 ` [PATCH v2 02/10] t/test-lib-functions.sh: allow to specify the tag name to test_commit Brandon Casey
2013-01-22 8:02 ` Jonathan Nieder
2013-01-22 9:43 ` Brandon Casey
2013-01-21 8:40 ` [PATCH v2 03/10] t/t3511: add some tests of 'cherry-pick -s' functionality Brandon Casey
2013-01-22 8:17 ` Jonathan Nieder
2013-01-27 23:33 ` Brandon Casey
2013-01-27 23:40 ` Jonathan Nieder
2013-01-21 8:40 ` [PATCH v2 04/10] sequencer.c: recognize "(cherry picked from ..." as part of s-o-b footer Brandon Casey
2013-01-22 8:27 ` Jonathan Nieder
2013-01-28 1:24 ` Jonathan Nieder
2013-01-21 8:40 ` [PATCH v2 05/10] sequencer.c: always separate "(cherry picked from" from commit body Brandon Casey
2013-01-22 8:32 ` Jonathan Nieder
2013-01-21 8:40 ` [PATCH v2 06/10] sequencer.c: teach append_signoff how to detect duplicate s-o-b Brandon Casey
2013-01-22 8:38 ` Jonathan Nieder
2013-01-28 0:36 ` Brandon Casey
2013-01-28 2:06 ` Junio C Hamano
2013-02-09 23:06 ` Junio C Hamano
2013-02-09 23:49 ` Brandon Casey
2013-01-21 8:40 ` [PATCH v2 07/10] sequencer.c: teach append_signoff to avoid adding a duplicate newline Brandon Casey
2013-01-21 8:40 ` [PATCH v2 08/10] t4014: more tests about appending s-o-b lines Brandon Casey
2013-01-21 8:40 ` [PATCH v2 09/10] format-patch: update append_signoff prototype Brandon Casey
2013-01-21 8:40 ` [PATCH v2 10/10] Unify appending signoff in format-patch, commit and sequencer Brandon Casey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1358757627-16682-1-git-send-email-drafnel@gmail.com \
--to=drafnel@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=pclouds@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).