Skip to content

Commit d859dca

Browse files
dschogitster
authored andcommitted
parse_insn_line(): improve error message when parsing failed
In the case that a `get_oid()` call failed, we showed some rather bogus part of the line instead of the precise string we sent to said function. That makes it rather hard for users to understand what is going wrong, so let's fix that. While at it, return a negative value from `parse_insn_line()` in case of an error, as per our convention. This function's only caller, `todo_list_parse_insn_buffer()`, cares only whether that return value is non-zero or not, i.e. does not need to be changed. Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d0654dc commit d859dca

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

sequencer.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2118,18 +2118,19 @@ static int parse_insn_line(struct repository *r, struct todo_item *item,
21182118
saved = *end_of_object_name;
21192119
*end_of_object_name = '\0';
21202120
status = get_oid(bol, &commit_oid);
2121+
if (status < 0)
2122+
error(_("could not parse '%s'"), bol); /* return later */
21212123
*end_of_object_name = saved;
21222124

21232125
bol = end_of_object_name + strspn(end_of_object_name, " \t");
21242126
item->arg_offset = bol - buf;
21252127
item->arg_len = (int)(eol - bol);
21262128

21272129
if (status < 0)
2128-
return error(_("could not parse '%.*s'"),
2129-
(int)(end_of_object_name - bol), bol);
2130+
return status;
21302131

21312132
item->commit = lookup_commit_reference(r, &commit_oid);
2132-
return !item->commit;
2133+
return item->commit ? 0 : -1;
21332134
}
21342135

21352136
int sequencer_get_last_command(struct repository *r, enum replay_action *action)

0 commit comments

Comments
 (0)