Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlban Gruin <alban.gruin@gmail.com>2018-08-10 19:51:31 +0300
committerJunio C Hamano <gitster@pobox.com>2018-08-10 21:56:22 +0300
commit64a43cbd5da23718dee242d6ad4d5823128bf564 (patch)
tree7b5c399b5497773b519a7609f19c45321e8c1b7e /rebase-interactive.c
parent2aed01811daee2f412b795ea539a4eb5abb69510 (diff)
rebase -i: rewrite the edit-todo functionality in C
This rewrites the edit-todo functionality from shell to C. To achieve that, a new command mode, `edit-todo`, is added, and the `write-edit-todo` flag is removed, as the shell script does not need to write the edit todo help message to the todo list anymore. The shell version is then stripped in favour of a call to the helper. Signed-off-by: Alban Gruin <alban.gruin@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'rebase-interactive.c')
-rw-r--r--rebase-interactive.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/rebase-interactive.c b/rebase-interactive.c
index d7996bc8d9..3f9468fc69 100644
--- a/rebase-interactive.c
+++ b/rebase-interactive.c
@@ -66,3 +66,30 @@ int append_todo_help(unsigned edit_todo, unsigned keep_empty)
return ret;
}
+
+int edit_todo_list(unsigned flags)
+{
+ struct strbuf buf = STRBUF_INIT;
+ const char *todo_file = rebase_path_todo();
+
+ if (strbuf_read_file(&buf, todo_file, 0) < 0)
+ return error_errno(_("could not read '%s'."), todo_file);
+
+ strbuf_stripspace(&buf, 1);
+ if (write_message(buf.buf, buf.len, todo_file, 0)) {
+ strbuf_release(&buf);
+ return -1;
+ }
+
+ strbuf_release(&buf);
+
+ transform_todos(flags | TODO_LIST_SHORTEN_IDS);
+ append_todo_help(1, 0);
+
+ if (launch_sequence_editor(todo_file, NULL, NULL))
+ return -1;
+
+ transform_todos(flags & ~(TODO_LIST_SHORTEN_IDS));
+
+ return 0;
+}