| 2711 | } |
| 2712 | |
| 2713 | static int parse_insn_line(struct repository *r, struct replay_opts *opts, |
| 2714 | struct todo_item *item, const char *buf, |
| 2715 | const char *bol, char *eol) |
| 2716 | { |
| 2717 | struct object_id commit_oid; |
| 2718 | char *end_of_object_name; |
| 2719 | int i, saved, status, padding; |
| 2720 | |
| 2721 | item->flags = 0; |
| 2722 | |
| 2723 | /* left-trim */ |
| 2724 | bol += strspn(bol, " \t"); |
| 2725 | |
| 2726 | if (bol == eol || *bol == '\r' || starts_with_mem(bol, eol - bol, comment_line_str)) { |
| 2727 | item->command = TODO_COMMENT; |
| 2728 | item->commit = NULL; |
| 2729 | item->arg_offset = bol - buf; |
| 2730 | item->arg_len = eol - bol; |
| 2731 | return 0; |
| 2732 | } |
| 2733 | |
| 2734 | for (i = 0; i < TODO_COMMENT; i++) |
| 2735 | if (is_command(i, &bol)) { |
| 2736 | item->command = i; |
| 2737 | break; |
| 2738 | } |
| 2739 | if (i >= TODO_COMMENT) |
| 2740 | return error(_("invalid command '%.*s'"), |
| 2741 | (int)strcspn(bol, " \t\r\n"), bol); |
| 2742 | |
| 2743 | /* Eat up extra spaces/ tabs before object name */ |
| 2744 | padding = strspn(bol, " \t"); |
| 2745 | bol += padding; |
| 2746 | |
| 2747 | if (item->command == TODO_NOOP || item->command == TODO_BREAK) { |
| 2748 | if (bol != eol) |
| 2749 | return error(_("%s does not accept arguments: '%s'"), |
| 2750 | command_to_string(item->command), bol); |
| 2751 | item->commit = NULL; |
| 2752 | item->arg_offset = bol - buf; |
| 2753 | item->arg_len = eol - bol; |
| 2754 | return 0; |
| 2755 | } |
| 2756 | |
| 2757 | if (!padding) |
| 2758 | return error(_("missing arguments for %s"), |
| 2759 | command_to_string(item->command)); |
| 2760 | |
| 2761 | if (item->command == TODO_EXEC || item->command == TODO_LABEL || |
| 2762 | item->command == TODO_RESET || item->command == TODO_UPDATE_REF) { |
| 2763 | int ret = 0; |
| 2764 | |
| 2765 | item->commit = NULL; |
| 2766 | item->arg_offset = bol - buf; |
| 2767 | item->arg_len = (int)(eol - bol); |
| 2768 | if (item->command == TODO_LABEL || |
| 2769 | item->command == TODO_UPDATE_REF) { |
| 2770 | saved = *eol; |
no test coverage detected