From 9336281c692c0f3b3e1f91ac226fc2a3e0574359 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sat, 23 Dec 2017 00:55:38 +0100 Subject: rebase: do not continue when the todo list generation failed This is a *really* long-standing bug. As a matter of fact, this bug has been with us from the very beginning of `rebase -i`: 1b1dce4bae7 (Teach rebase an interactive mode, 2007-06-25), where the output of `rev-list` was piped to `sed` (and any failure of the `rev-list` process would go completely undetected). Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- git-rebase--interactive.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh index e3f5a0abf3..b7f95672bd 100644 --- a/git-rebase--interactive.sh +++ b/git-rebase--interactive.sh @@ -893,7 +893,8 @@ fi if test t != "$preserve_merges" then git rebase--helper --make-script ${keep_empty:+--keep-empty} \ - $revisions ${restrict_revision+^$restrict_revision} >"$todo" + $revisions ${restrict_revision+^$restrict_revision} >"$todo" || + die "$(gettext "Could not generate todo list")" else format=$(git config --get rebase.instructionFormat) # the 'rev-list .. | sed' requires %m to parse; the instruction requires %H to parse -- cgit v1.2.1 From aee42e1f35ac85ef25ba81eb28e72d002f0649db Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sat, 23 Dec 2017 00:55:43 +0100 Subject: sequencer: strip bogus LF at end of error messages Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- sequencer.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sequencer.c b/sequencer.c index 894d12ad72..5ca9e93888 100644 --- a/sequencer.c +++ b/sequencer.c @@ -493,7 +493,7 @@ static int is_index_unchanged(void) struct commit *head_commit; if (!resolve_ref_unsafe("HEAD", RESOLVE_REF_READING, &head_oid, NULL)) - return error(_("could not resolve HEAD commit\n")); + return error(_("could not resolve HEAD commit")); head_commit = lookup_commit(&head_oid); @@ -513,7 +513,7 @@ static int is_index_unchanged(void) if (!cache_tree_fully_valid(active_cache_tree)) if (cache_tree_update(&the_index, 0)) - return error(_("unable to update cache tree\n")); + return error(_("unable to update cache tree")); return !oidcmp(&active_cache_tree->oid, &head_commit->tree->object.oid); @@ -699,12 +699,12 @@ static int is_original_commit_empty(struct commit *commit) const struct object_id *ptree_oid; if (parse_commit(commit)) - return error(_("could not parse commit %s\n"), + return error(_("could not parse commit %s"), oid_to_hex(&commit->object.oid)); if (commit->parents) { struct commit *parent = commit->parents->item; if (parse_commit(parent)) - return error(_("could not parse parent commit %s\n"), + return error(_("could not parse parent commit %s"), oid_to_hex(&parent->object.oid)); ptree_oid = &parent->tree->object.oid; } else { -- cgit v1.2.1 From 5f8f927710a039ce3068ac55ca87354477a199b9 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sat, 23 Dec 2017 00:55:53 +0100 Subject: sequencer: remove superfluous conditional In a conditional block that is only reached when handling a TODO_REWORD (as seen even from a 3-line context), there is absolutely no need to nest another block under the identical condition. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- sequencer.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sequencer.c b/sequencer.c index 5ca9e93888..e9fef58ba0 100644 --- a/sequencer.c +++ b/sequencer.c @@ -1013,9 +1013,7 @@ static int do_pick_commit(enum todo_command command, struct commit *commit, opts); if (res || command != TODO_REWORD) goto leave; - flags |= EDIT_MSG | AMEND_MSG; - if (command == TODO_REWORD) - flags |= VERIFY_MSG; + flags |= EDIT_MSG | AMEND_MSG | VERIFY_MSG; msg_file = NULL; goto fast_forward_edit; } -- cgit v1.2.1 From 66afa24fb36f15c49aed76be2f04bd23dd0e55c8 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sat, 23 Dec 2017 00:55:57 +0100 Subject: sequencer: report when noop has an argument The noop command cannot accept any argument, but we never told the user about any bogus argument. Fix that. while at it, mention clearly when an argument is required but missing (for commands *other* than noop). Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- sequencer.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/sequencer.c b/sequencer.c index e9fef58ba0..b005e412a5 100644 --- a/sequencer.c +++ b/sequencer.c @@ -1261,18 +1261,23 @@ static int parse_insn_line(struct todo_item *item, const char *bol, char *eol) if (i >= TODO_COMMENT) return -1; + /* Eat up extra spaces/ tabs before object name */ + padding = strspn(bol, " \t"); + bol += padding; + if (item->command == TODO_NOOP) { + if (bol != eol) + return error(_("%s does not accept arguments: '%s'"), + command_to_string(item->command), bol); item->commit = NULL; item->arg = bol; item->arg_len = eol - bol; return 0; } - /* Eat up extra spaces/ tabs before object name */ - padding = strspn(bol, " \t"); if (!padding) - return -1; - bol += padding; + return error(_("missing arguments for %s"), + command_to_string(item->command)); if (item->command == TODO_EXEC) { item->commit = NULL; -- cgit v1.2.1 From c7b4d79c7dd1a20feb88c2e2ed1fd86bd2ea0570 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sat, 23 Dec 2017 00:56:00 +0100 Subject: sequencer: do not invent whitespace when transforming OIDs For commands that do not have an argument, there is no need to append a trailing space at the end of the line. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- sequencer.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sequencer.c b/sequencer.c index b005e412a5..4d3f60594c 100644 --- a/sequencer.c +++ b/sequencer.c @@ -2586,7 +2586,10 @@ int transform_todos(unsigned flags) strbuf_addf(&buf, " %s", oid); } /* add all the rest */ - strbuf_addf(&buf, " %.*s\n", item->arg_len, item->arg); + if (!item->arg_len) + strbuf_addch(&buf, '\n'); + else + strbuf_addf(&buf, " %.*s\n", item->arg_len, item->arg); } i = write_message(buf.buf, buf.len, todo_file, 0); -- cgit v1.2.1