summaryrefslogtreecommitdiff
path: root/sequencer.c
diff options
context:
space:
mode:
authorJonathan Nieder <jrnieder@gmail.com>2013-02-12 10:17:28 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-02-12 19:07:53 (GMT)
commitfa1727fb210bd8d0079af124222420d46fb70f81 (patch)
treeb27e3d12d46cd2c13754cfe9f25985f3db06df12 /sequencer.c
parente8a1f5a2ae53805986b1b965e036450bdfc0c460 (diff)
downloadgit-fa1727fb210bd8d0079af124222420d46fb70f81.zip
git-fa1727fb210bd8d0079af124222420d46fb70f81.tar.gz
git-fa1727fb210bd8d0079af124222420d46fb70f81.tar.bz2
sequencer.c: rework search for start of footer to improve clarity
This code sequence is somewhat difficult to read. Let's rewrite it and add some comments to improve clarity. Signed-off-by: Brandon Casey <drafnel@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sequencer.c')
-rw-r--r--sequencer.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/sequencer.c b/sequencer.c
index 2260490..776ddb1 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -1019,19 +1019,21 @@ int sequencer_pick_revisions(struct replay_opts *opts)
static int ends_rfc2822_footer(struct strbuf *sb, int ignore_footer)
{
- int ch;
- int hit = 0;
+ char ch, prev;
int i, j, k;
int len = sb->len - ignore_footer;
int first = 1;
const char *buf = sb->buf;
+ prev = '\0';
for (i = len - 1; i > 0; i--) {
- if (hit && buf[i] == '\n')
+ ch = buf[i];
+ if (prev == '\n' && ch == '\n') /* paragraph break */
break;
- hit = (buf[i] == '\n');
+ prev = ch;
}
+ /* advance to start of last paragraph */
while (i < len - 1 && buf[i] == '\n')
i++;