diff options
author | Junio C Hamano <gitster@pobox.com> | 2023-02-28 16:38:47 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2023-02-28 16:38:47 -0800 |
commit | a2d2b5229e55742f56fbbde4f7bb013171f7a6ca (patch) | |
tree | 579eec5b1c2d5a4a3472650371efe82c91a1ec13 /sequencer.c | |
parent | b2893ea403562f94a11edf5c3cc6beb44685d991 (diff) | |
parent | 666b6e1135c12925efe608c4d5f03234c54e2d0c (diff) | |
download | git-a2d2b5229e55742f56fbbde4f7bb013171f7a6ca.tar.gz |
Merge branch 'pw/rebase-i-parse-fix'
Fixes to code that parses the todo file used in "rebase -i".
* pw/rebase-i-parse-fix:
rebase -i: fix parsing of "fixup -C<commit>"
rebase -i: match whole word in is_command()
Diffstat (limited to 'sequencer.c')
-rw-r--r-- | sequencer.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/sequencer.c b/sequencer.c index a7e6db4f78..1c96a75b1e 100644 --- a/sequencer.c +++ b/sequencer.c @@ -2479,12 +2479,11 @@ static int is_command(enum todo_command command, const char **bol) { const char *str = todo_command_info[command].str; const char nick = todo_command_info[command].c; - const char *p = *bol + 1; + const char *p = *bol; - return skip_prefix(*bol, str, bol) || - ((nick && **bol == nick) && - (*p == ' ' || *p == '\t' || *p == '\n' || *p == '\r' || !*p) && - (*bol = p)); + return (skip_prefix(p, str, &p) || (nick && *p++ == nick)) && + (*p == ' ' || *p == '\t' || *p == '\n' || *p == '\r' || !*p) && + (*bol = p); } static int check_label_or_ref_arg(enum todo_command command, const char *arg) @@ -2541,7 +2540,8 @@ static int parse_insn_line(struct repository *r, struct todo_item *item, break; } if (i >= TODO_COMMENT) - return -1; + return error(_("invalid command '%.*s'"), + (int)strcspn(bol, " \t\r\n"), bol); /* Eat up extra spaces/ tabs before object name */ padding = strspn(bol, " \t"); @@ -2579,12 +2579,10 @@ static int parse_insn_line(struct repository *r, struct todo_item *item, } if (item->command == TODO_FIXUP) { - if (skip_prefix(bol, "-C", &bol) && - (*bol == ' ' || *bol == '\t')) { + if (skip_prefix(bol, "-C", &bol)) { bol += strspn(bol, " \t"); item->flags |= TODO_REPLACE_FIXUP_MSG; - } else if (skip_prefix(bol, "-c", &bol) && - (*bol == ' ' || *bol == '\t')) { + } else if (skip_prefix(bol, "-c", &bol)) { bol += strspn(bol, " \t"); item->flags |= TODO_EDIT_FIXUP_MSG; } |