Skip to content

Commit

Permalink
sequencer.c: rework search for start of footer to improve clarity
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jonathan Nieder authored and Junio C Hamano committed Feb 12, 2013
1 parent e8a1f5a commit fa1727f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions sequencer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++;

Expand Down

0 comments on commit fa1727f

Please sign in to comment.