From 145e05ac44b4c574fc22e6d3af7c5a14ad9b7335 Mon Sep 17 00:00:00 2001 From: Alban Gruin Date: Fri, 10 Aug 2018 18:51:29 +0200 Subject: rebase -i: rewrite append_todo_help() in C This rewrites append_todo_help() from shell to C. It also incorporates some parts of initiate_action() and complete_action() that also write help texts to the todo file. This also introduces the source file rebase-interactive.c. This file will contain functions necessary for interactive rebase that are too specific for the sequencer, and is part of libgit.a. Two flags are added to rebase--helper.c: one to call append_todo_help() (`--append-todo-help`), and another one to tell append_todo_help() to write the help text suited for the edit-todo mode (`--write-edit-todo`). Finally, append_todo_help() is removed from git-rebase--interactive.sh to use `rebase--helper --append-todo-help` instead. Signed-off-by: Alban Gruin Signed-off-by: Junio C Hamano --- rebase-interactive.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 rebase-interactive.c (limited to 'rebase-interactive.c') diff --git a/rebase-interactive.c b/rebase-interactive.c new file mode 100644 index 0000000000..d7996bc8d9 --- /dev/null +++ b/rebase-interactive.c @@ -0,0 +1,68 @@ +#include "cache.h" +#include "commit.h" +#include "rebase-interactive.h" +#include "sequencer.h" +#include "strbuf.h" + +int append_todo_help(unsigned edit_todo, unsigned keep_empty) +{ + struct strbuf buf = STRBUF_INIT; + FILE *todo; + int ret; + const char *msg = _("\nCommands:\n" +"p, pick = use commit\n" +"r, reword = use commit, but edit the commit message\n" +"e, edit = use commit, but stop for amending\n" +"s, squash = use commit, but meld into previous commit\n" +"f, fixup = like \"squash\", but discard this commit's log message\n" +"x, exec = run command (the rest of the line) using shell\n" +"d, drop = remove commit\n" +"l, label