strbuf_release(&buf);
}
+static int check_exec_cmd(const char *cmd)
+{
+ if (strchr(cmd, '\n'))
+ return error(_("exec commands cannot contain newlines"));
+
+ /* Does the command consist purely of whitespace? */
+ if (!cmd[strspn(cmd, " \t\r\f\v")])
+ return error(_("empty exec command"));
+
+ return 0;
+}
+
+
int cmd_rebase(int argc, const char **argv, const char *prefix)
{
struct rebase_options options = {
}
}
+ for (i = 0; i < exec.nr; i++)
+ if (check_exec_cmd(exec.items[i].string))
+ exit(1);
+
if (!(options.flags & REBASE_NO_QUIET))
argv_array_push(&options.git_am_opts, "-q");
git rebase --continue
'
+test_expect_success 'rebase -x with empty command fails' '
+ test_when_finished "git rebase --abort ||:" &&
+ test_must_fail git rebase -x "" @ 2>actual &&
+ test_write_lines "error: empty exec command" >expected &&
+ test_i18ncmp expected actual &&
+ test_must_fail git rebase -x " " @ 2>actual &&
+ test_i18ncmp expected actual
+'
+
+LF='
+'
+test_expect_success 'rebase -x with newline in command fails' '
+ test_when_finished "git rebase --abort ||:" &&
+ test_must_fail git rebase -x "a${LF}b" @ 2>actual &&
+ test_write_lines "error: exec commands cannot contain newlines" \
+ >expected &&
+ test_i18ncmp expected actual
+'
+
test_expect_success 'rebase -i with exec of inexistent command' '
git checkout master &&
test_when_finished "git rebase --abort" &&