| 2852 | } |
| 2853 | |
| 2854 | int todo_list_parse_insn_buffer(struct repository *r, struct replay_opts *opts, |
| 2855 | char *buf, struct todo_list *todo_list) |
| 2856 | { |
| 2857 | struct todo_item *item; |
| 2858 | char *p = buf, *next_p; |
| 2859 | int i, res = 0, fixup_okay = file_exists(rebase_path_done()); |
| 2860 | |
| 2861 | todo_list->current = todo_list->nr = todo_list->total_nr = 0; |
| 2862 | |
| 2863 | for (i = 1; *p; i++, p = next_p) { |
| 2864 | char *eol = strchrnul(p, '\n'); |
| 2865 | |
| 2866 | next_p = *eol ? eol + 1 /* skip LF */ : eol; |
| 2867 | |
| 2868 | if (p != eol && eol[-1] == '\r') |
| 2869 | eol--; /* strip Carriage Return */ |
| 2870 | |
| 2871 | item = append_new_todo(todo_list); |
| 2872 | item->offset_in_buf = p - todo_list->buf.buf; |
| 2873 | if (parse_insn_line(r, opts, item, buf, p, eol)) { |
| 2874 | res = error(_("invalid line %d: %.*s"), |
| 2875 | i, (int)(eol - p), p); |
| 2876 | item->command = TODO_COMMENT + 1; |
| 2877 | item->arg_offset = p - buf; |
| 2878 | item->arg_len = (int)(eol - p); |
| 2879 | item->commit = NULL; |
| 2880 | } |
| 2881 | |
| 2882 | if (item->command != TODO_COMMENT) |
| 2883 | todo_list->total_nr++; |
| 2884 | |
| 2885 | if (fixup_okay) |
| 2886 | ; /* do nothing */ |
| 2887 | else if (is_fixup(item->command)) |
| 2888 | res = error(_("cannot '%s' without a previous commit"), |
| 2889 | command_to_string(item->command)); |
| 2890 | else if (!is_noop(item->command)) |
| 2891 | fixup_okay = 1; |
| 2892 | } |
| 2893 | |
| 2894 | return res; |
| 2895 | } |
| 2896 | |
| 2897 | static int count_commands(struct todo_list *todo_list) |
| 2898 | { |
no test coverage detected