summaryrefslogtreecommitdiffstats
path: root/sequencer.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2024-05-23 20:04:26 +0200
committerJunio C Hamano <gitster@pobox.com>2024-05-23 20:04:27 +0200
commit7593d669284b16db4dc43f9b9bd8cd96ec862377 (patch)
tree49fb25188f5990878bd7dea16c818e2f6845a8d9 /sequencer.c
parentThe sixth batch (diff)
parenttrailer unit tests: inspect iterator contents (diff)
downloadgit-7593d669284b16db4dc43f9b9bd8cd96ec862377.tar.xz
git-7593d669284b16db4dc43f9b9bd8cd96ec862377.zip
Merge branch 'la/hide-trailer-info'
The trailer API has been reshuffled a bit. * la/hide-trailer-info: trailer unit tests: inspect iterator contents trailer: document parse_trailers() usage trailer: retire trailer_info_get() from API trailer: make trailer_info struct private trailer: make parse_trailers() return trailer_info pointer interpret-trailers: access trailer_info with new helpers sequencer: use the trailer iterator trailer: teach iterator about non-trailer lines trailer: add unit tests for trailer iterator Makefile: sort UNIT_TEST_PROGRAMS
Diffstat (limited to 'sequencer.c')
-rw-r--r--sequencer.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/sequencer.c b/sequencer.c
index dbd60d79b9..aa2a239835 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -359,35 +359,32 @@ static const char *get_todo_path(const struct replay_opts *opts)
static int has_conforming_footer(struct strbuf *sb, struct strbuf *sob,
size_t ignore_footer)
{
- struct process_trailer_options opts = PROCESS_TRAILER_OPTIONS_INIT;
- struct trailer_info info;
- size_t i;
+ struct trailer_iterator iter;
+ size_t i = 0;
int found_sob = 0, found_sob_last = 0;
char saved_char;
- opts.no_divider = 1;
-
if (ignore_footer) {
saved_char = sb->buf[sb->len - ignore_footer];
sb->buf[sb->len - ignore_footer] = '\0';
}
- trailer_info_get(&opts, sb->buf, &info);
+ trailer_iterator_init(&iter, sb->buf);
if (ignore_footer)
sb->buf[sb->len - ignore_footer] = saved_char;
- if (info.trailer_block_start == info.trailer_block_end)
- return 0;
+ while (trailer_iterator_advance(&iter)) {
+ i++;
+ if (sob && !strncmp(iter.raw, sob->buf, sob->len))
+ found_sob = i;
+ }
+ trailer_iterator_release(&iter);
- for (i = 0; i < info.trailer_nr; i++)
- if (sob && !strncmp(info.trailers[i], sob->buf, sob->len)) {
- found_sob = 1;
- if (i == info.trailer_nr - 1)
- found_sob_last = 1;
- }
+ if (!i)
+ return 0;
- trailer_info_release(&info);
+ found_sob_last = (int)i == found_sob;
if (found_sob_last)
return 3;