{"thread":{"id":"48613","subject":"[GSoC][PATCH 0/2] rebase -i: rewrite append_todo_help() in C","startedAt":"2018-05-31T11:03:22Z","lastAt":"2018-06-28T18:05:08Z","messageCount":27,"participants":["Alban Gruin","Phillip Wood","Stefan Beller","Johannes Schindelin","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"348886","messageId":"20180531110130.18839-1-alban.gruin@gmail.com","threadId":"48613","inReplyTo":null,"subject":"[GSoC][PATCH 0/2] rebase -i: rewrite append_todo_help() in C","fromName":"Alban Gruin","fromEmail":"alban.gruin@gmail.com","sentAt":"2018-05-31T11:01:28Z","receivedAt":"2018-05-31T11:03:22Z","isPatch":true,"sender":{"key":"alban.gruin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6310153?v=4"},"body":"This series rewrites append_todo_help() from shell to C. This is part\nof the effort to rewrite interactive rebase in C.\n\nThe first commit rewrites append_todo_help() in C (the C version\ncovers a bit more than the old shell version), adds some parameters to\nrebase--helper, etc.\n\nThe second one strips newlines from append_todo_help() messages, which\nrequire to update the translations. This change was advised to me by\nStefan Beller, but Johannes Schindelin voiced concerns. I don’t really\nhave a strong opinion about it, so feel free to give yours.\n\nAlban Gruin (2):\n  rebase--interactive: rewrite append_todo_help() in C\n  sequencer: remove newlines from append_todo_help() messages\n\n builtin/rebase--helper.c   | 10 ++++++--\n git-rebase--interactive.sh | 52 ++-----------------------------------\n sequencer.c                | 64 ++++++++++++++++++++++++++++++++++++++++++++++\n sequencer.h                |  1 +\n 4 files changed, 75 insertions(+), 52 deletions(-)\n\n-- \n2.16.4\n\n"},{"id":"348887","messageId":"20180531110130.18839-2-alban.gruin@gmail.com","threadId":"48613","inReplyTo":"20180531110130.18839-1-alban.gruin@gmail.com","subject":"[GSoC][PATCH 1/2] rebase--interactive: rewrite append_todo_help() in C","fromName":"Alban Gruin","fromEmail":"alban.gruin@gmail.com","sentAt":"2018-05-31T11:01:29Z","receivedAt":"2018-05-31T11:03:26Z","isPatch":true,"sender":{"key":"alban.gruin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6310153?v=4"},"body":"This rewrites append_todo_help() from shell to C. It also incorporates\nsome parts of initiate_action() and complete_action() that also write\nhelp texts to the todo file.\n\nTwo flags are added to rebase--helper.c: one to call\nappend_todo_help() (`--append-todo-help`), and another one to tell\nappend_todo_help() to write the help text suited for the edit-todo\nmode (`--edit-todo`).\n\nFinally, append_todo_help() is removed from git-rebase--interactive.sh\nto use `rebase--helper --append-todo-help` instead.\n\nSigned-off-by: Alban Gruin <alban.gruin@gmail.com>\n---\n builtin/rebase--helper.c   | 10 ++++++--\n git-rebase--interactive.sh | 52 ++--------------------------------------\n sequencer.c                | 60 ++++++++++++++++++++++++++++++++++++++++++++++\n sequencer.h                |  1 +\n 4 files changed, 71 insertions(+), 52 deletions(-)\n\ndiff --git a/builtin/rebase--helper.c b/builtin/rebase--helper.c\nindex f7c2a5fdc..ad3a3a7eb 100644\n--- a/builtin/rebase--helper.c\n+++ b/builtin/rebase--helper.c\n@@ -12,12 +12,12 @@ static const char * const builtin_rebase_helper_usage[] = {\n int cmd_rebase__helper(int argc, const char **argv, const char *prefix)\n {\n \tstruct replay_opts opts = REPLAY_OPTS_INIT;\n-\tunsigned flags = 0, keep_empty = 0, rebase_merges = 0;\n+\tunsigned flags = 0, keep_empty = 0, rebase_merges = 0, edit_todo = 0;\n \tint abbreviate_commands = 0, rebase_cousins = -1;\n \tenum {\n \t\tCONTINUE = 1, ABORT, MAKE_SCRIPT, SHORTEN_OIDS, EXPAND_OIDS,\n \t\tCHECK_TODO_LIST, SKIP_UNNECESSARY_PICKS, REARRANGE_SQUASH,\n-\t\tADD_EXEC\n+\t\tADD_EXEC, APPEND_TODO_HELP\n \t} command = 0;\n \tstruct option options[] = {\n \t\tOPT_BOOL(0, \"ff\", &opts.allow_ff, N_(\"allow fast-forward\")),\n@@ -27,6 +27,8 @@ int cmd_rebase__helper(int argc, const char **argv, const char *prefix)\n \t\tOPT_BOOL(0, \"rebase-merges\", &rebase_merges, N_(\"rebase merge commits\")),\n \t\tOPT_BOOL(0, \"rebase-cousins\", &rebase_cousins,\n \t\t\t N_(\"keep original branch points of cousins\")),\n+\t\tOPT_BOOL(0, \"edit-todo\", &edit_todo,\n+\t\t\t N_(\"edit the todo list during an interactive rebase\")),\n \t\tOPT_CMDMODE(0, \"continue\", &command, N_(\"continue rebase\"),\n \t\t\t\tCONTINUE),\n \t\tOPT_CMDMODE(0, \"abort\", &command, N_(\"abort rebase\"),\n@@ -45,6 +47,8 @@ int cmd_rebase__helper(int argc, const char **argv, const char *prefix)\n \t\t\tN_(\"rearrange fixup/squash lines\"), REARRANGE_SQUASH),\n \t\tOPT_CMDMODE(0, \"add-exec-commands\", &command,\n \t\t\tN_(\"insert exec commands in todo list\"), ADD_EXEC),\n+\t\tOPT_CMDMODE(0, \"append-todo-help\", &command,\n+\t\t\t    N_(\"insert the help in the todo list\"), APPEND_TODO_HELP),\n \t\tOPT_END()\n \t};\n \n@@ -84,5 +88,7 @@ int cmd_rebase__helper(int argc, const char **argv, const char *prefix)\n \t\treturn !!rearrange_squash();\n \tif (command == ADD_EXEC && argc == 2)\n \t\treturn !!sequencer_add_exec_commands(argv[1]);\n+\tif (command == APPEND_TODO_HELP && argc == 1)\n+\t\treturn !!append_todo_help(edit_todo, keep_empty);\n \tusage_with_options(builtin_rebase_helper_usage, options);\n }\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 9884ecd71..419c54068 100644\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -39,38 +39,6 @@ comment_for_reflog () {\n \tesac\n }\n \n-append_todo_help () {\n-\tgettext \"\n-Commands:\n-p, pick <commit> = use commit\n-r, reword <commit> = use commit, but edit the commit message\n-e, edit <commit> = use commit, but stop for amending\n-s, squash <commit> = use commit, but meld into previous commit\n-f, fixup <commit> = like \\\"squash\\\", but discard this commit's log message\n-x, exec <commit> = run command (the rest of the line) using shell\n-d, drop <commit> = remove commit\n-l, label <label> = label current HEAD with a name\n-t, reset <label> = reset HEAD to a label\n-m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]\n-.       create a merge commit using the original merge commit's\n-.       message (or the oneline, if no original merge commit was\n-.       specified). Use -c <commit> to reword the commit message.\n-\n-These lines can be re-ordered; they are executed from top to bottom.\n-\" | git stripspace --comment-lines >>\"$todo\"\n-\n-\tif test $(get_missing_commit_check_level) = error\n-\tthen\n-\t\tgettext \"\n-Do not remove any line. Use 'drop' explicitly to remove a commit.\n-\" | git stripspace --comment-lines >>\"$todo\"\n-\telse\n-\t\tgettext \"\n-If you remove a line here THAT COMMIT WILL BE LOST.\n-\" | git stripspace --comment-lines >>\"$todo\"\n-\tfi\n-}\n-\n die_abort () {\n \tapply_autostash\n \trm -rf \"$state_dir\"\n@@ -143,13 +111,7 @@ initiate_action () {\n \t\tgit stripspace --strip-comments <\"$todo\" >\"$todo\".new\n \t\tmv -f \"$todo\".new \"$todo\"\n \t\tcollapse_todo_ids\n-\t\tappend_todo_help\n-\t\tgettext \"\n-You are editing the todo file of an ongoing interactive rebase.\n-To continue rebase after editing, run:\n-    git rebase --continue\n-\n-\" | git stripspace --comment-lines >>\"$todo\"\n+\t\tgit rebase--helper --append-todo-help --edit-todo\n \n \t\tgit_sequence_editor \"$todo\" ||\n \t\t\tdie \"$(gettext \"Could not execute editor\")\"\n@@ -220,17 +182,7 @@ $comment_char $(eval_ngettext \\\n \t\"Rebase \\$shortrevisions onto \\$shortonto (\\$todocount commands)\" \\\n \t\"$todocount\")\n EOF\n-\tappend_todo_help\n-\tgettext \"\n-\tHowever, if you remove everything, the rebase will be aborted.\n-\n-\t\" | git stripspace --comment-lines >>\"$todo\"\n-\n-\tif test -z \"$keep_empty\"\n-\tthen\n-\t\tprintf '%s\\n' \"$comment_char $(gettext \"Note that empty commits are commented out\")\" >>\"$todo\"\n-\tfi\n-\n+\tgit rebase--helper --append-todo-help ${keep_empty:+--keep-empty}\n \n \thas_action \"$todo\" ||\n \t\treturn 2\ndiff --git a/sequencer.c b/sequencer.c\nindex 01e561bc2..9b291845e 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -4223,6 +4223,66 @@ int check_todo_list(void)\n \treturn res;\n }\n \n+int append_todo_help(unsigned edit_todo, unsigned keep_empty)\n+{\n+\tstruct strbuf buf = STRBUF_INIT;\n+\tFILE *todo;\n+\tint ret;\n+\tconst char *msg = _(\"\\nCommands:\\n\"\n+\"p, pick <commit> = use commit\\n\"\n+\"r, reword <commit> = use commit, but edit the commit message\\n\"\n+\"e, edit <commit> = use commit, but stop for amending\\n\"\n+\"s, squash <commit> = use commit, but meld into previous commit\\n\"\n+\"f, fixup <commit> = like \\\"squash\\\", but discard this commit's log message\\n\"\n+\"x, exec <command> = run command (the rest of the line) using shell\\n\"\n+\"d, drop <commit> = remove commit\\n\"\n+\"l, label <label> = label current HEAD with a name\\n\"\n+\"t, reset <label> = reset HEAD to a label\\n\"\n+\"m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]\\n\"\n+\".       create a merge commit using the original merge commit's\\n\"\n+\".       message (or the oneline, if no original merge commit was\\n\"\n+\".       specified). Use -c <commit> to reword the commit message.\\n\"\n+\"\\n\"\n+\"These lines can be re-ordered; they are executed from top to bottom.\\n\");\n+\n+\ttodo = fopen_or_warn(rebase_path_todo(), \"a\");\n+\tif (!todo)\n+\t\treturn 1;\n+\n+\tstrbuf_add_commented_lines(&buf, msg, strlen(msg));\n+\n+\tif (get_missing_commit_check_level() == CHECK_ERROR)\n+\t\tmsg = _(\"\\nDo not remove any line. Use 'drop' \"\n+\t\t\t \"explicitly to remove a commit.\\n\");\n+\telse\n+\t\tmsg = _(\"\\nIf you remove a line here \"\n+\t\t\t \"THAT COMMIT WILL BE LOST.\\n\");\n+\n+\tstrbuf_add_commented_lines(&buf, msg, strlen(msg));\n+\n+\tif (edit_todo)\n+\t\tmsg = _(\"\\nYou are editing the todo file \"\n+\t\t\t\"of an ongoing interactive rebase.\\n\"\n+\t\t\t\"To continue rebase after editing, run:\\n\"\n+\t\t\t\"    git rebase --continue\\n\\n\");\n+\telse\n+\t\tmsg = _(\"\\nHowever, if you remove everything, \"\n+\t\t\t\"the rebase will be aborted.\\n\\n\");\n+\n+\tstrbuf_add_commented_lines(&buf, msg, strlen(msg));\n+\n+\tif (!keep_empty) {\n+\t\tmsg = _(\"Note that empty commits are commented out\");\n+\t\tstrbuf_add_commented_lines(&buf, msg, strlen(msg));\n+\t}\n+\n+\tret = fputs(buf.buf, todo);\n+\tfclose(todo);\n+\tstrbuf_release(&buf);\n+\n+\treturn ret;\n+}\n+\n static int rewrite_file(const char *path, const char *buf, size_t len)\n {\n \tint rc = 0;\ndiff --git a/sequencer.h b/sequencer.h\nindex 4b2717881..c1cd01c50 100644\n--- a/sequencer.h\n+++ b/sequencer.h\n@@ -76,6 +76,7 @@ int sequencer_make_script(FILE *out, int argc, const char **argv,\n int sequencer_add_exec_commands(const char *command);\n int transform_todos(unsigned flags);\n int check_todo_list(void);\n+int append_todo_help(unsigned edit_todo, unsigned keep_empty);\n int skip_unnecessary_picks(void);\n int rearrange_squash(void);\n \n-- \n2.16.4\n\n"},{"id":"348888","messageId":"20180531110130.18839-3-alban.gruin@gmail.com","threadId":"48613","inReplyTo":"20180531110130.18839-1-alban.gruin@gmail.com","subject":"[GSoC][PATCH 2/2] sequencer: remove newlines from append_todo_help() messages","fromName":"Alban Gruin","fromEmail":"alban.gruin@gmail.com","sentAt":"2018-05-31T11:01:30Z","receivedAt":"2018-05-31T11:03:28Z","isPatch":true,"sender":{"key":"alban.gruin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6310153?v=4"},"body":"This removes newlines before and after the messages in\nappend_todo_help(). This is done to avoid confusions from\ntranslators.\n\nThese newlines are now inserted with\n`strbuf_add_commented_lines()`. Messages were ended by two newlines\ncharacters, but here we only insert one at a time. This is because\n`strbuf_add_commented_lines()` automatically inserts a newline at the\nend of the input, and ignore the last from the input.\n\nSigned-off-by: Alban Gruin <alban.gruin@gmail.com>\n---\n sequencer.c | 24 ++++++++++++++----------\n 1 file changed, 14 insertions(+), 10 deletions(-)\n\ndiff --git a/sequencer.c b/sequencer.c\nindex 9b291845e..9ab6c28d7 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -4228,7 +4228,7 @@ int append_todo_help(unsigned edit_todo, unsigned keep_empty)\n \tstruct strbuf buf = STRBUF_INIT;\n \tFILE *todo;\n \tint ret;\n-\tconst char *msg = _(\"\\nCommands:\\n\"\n+\tconst char *msg = _(\"Commands:\\n\"\n \"p, pick <commit> = use commit\\n\"\n \"r, reword <commit> = use commit, but edit the commit message\\n\"\n \"e, edit <commit> = use commit, but stop for amending\\n\"\n@@ -4243,33 +4243,37 @@ int append_todo_help(unsigned edit_todo, unsigned keep_empty)\n \".       message (or the oneline, if no original merge commit was\\n\"\n \".       specified). Use -c <commit> to reword the commit message.\\n\"\n \"\\n\"\n-\"These lines can be re-ordered; they are executed from top to bottom.\\n\");\n+\"These lines can be re-ordered; they are executed from top to bottom.\");\n \n \ttodo = fopen_or_warn(rebase_path_todo(), \"a\");\n \tif (!todo)\n \t\treturn 1;\n \n+\tstrbuf_add_commented_lines(&buf, \"\\n\", 1);\n \tstrbuf_add_commented_lines(&buf, msg, strlen(msg));\n \n \tif (get_missing_commit_check_level() == CHECK_ERROR)\n-\t\tmsg = _(\"\\nDo not remove any line. Use 'drop' \"\n-\t\t\t \"explicitly to remove a commit.\\n\");\n+\t\tmsg = _(\"Do not remove any line. Use 'drop' \"\n+\t\t\t \"explicitly to remove a commit.\");\n \telse\n-\t\tmsg = _(\"\\nIf you remove a line here \"\n-\t\t\t \"THAT COMMIT WILL BE LOST.\\n\");\n+\t\tmsg = _(\"If you remove a line here \"\n+\t\t\t \"THAT COMMIT WILL BE LOST.\");\n \n+\tstrbuf_add_commented_lines(&buf, \"\\n\", 1);\n \tstrbuf_add_commented_lines(&buf, msg, strlen(msg));\n \n \tif (edit_todo)\n-\t\tmsg = _(\"\\nYou are editing the todo file \"\n+\t\tmsg = _(\"You are editing the todo file \"\n \t\t\t\"of an ongoing interactive rebase.\\n\"\n \t\t\t\"To continue rebase after editing, run:\\n\"\n-\t\t\t\"    git rebase --continue\\n\\n\");\n+\t\t\t\"    git rebase --continue\");\n \telse\n-\t\tmsg = _(\"\\nHowever, if you remove everything, \"\n-\t\t\t\"the rebase will be aborted.\\n\\n\");\n+\t\tmsg = _(\"However, if you remove everything, \"\n+\t\t\t\"the rebase will be aborted.\");\n \n+\tstrbuf_add_commented_lines(&buf, \"\\n\", 1);\n \tstrbuf_add_commented_lines(&buf, msg, strlen(msg));\n+\tstrbuf_add_commented_lines(&buf, \"\\n\", 1);\n \n \tif (!keep_empty) {\n \t\tmsg = _(\"Note that empty commits are commented out\");\n-- \n2.16.4\n\n"},{"id":"348916","messageId":"a6d6e5c1-e7ea-1131-c798-9d5e44603d87@talktalk.net","threadId":"48613","inReplyTo":"20180531110130.18839-1-alban.gruin@gmail.com","subject":"Re: [GSoC][PATCH 0/2] rebase -i: rewrite append_todo_help() in C","fromName":"Phillip Wood","fromEmail":"phillip.wood@talktalk.net","sentAt":"2018-05-31T17:48:13Z","receivedAt":"2018-05-31T17:48:20Z","isPatch":true,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"Hi Alban, it's great to see you working on this\n\nOn 31/05/18 12:01, Alban Gruin wrote:\n> This series rewrites append_todo_help() from shell to C. This is part\n> of the effort to rewrite interactive rebase in C.\n> \n> The first commit rewrites append_todo_help() in C (the C version\n> covers a bit more than the old shell version), adds some parameters to\n> rebase--helper, etc.\n\nI've had a read of the first patch and I think it looks fine, my only\ncomment would be that the help for '--edit-todo' is a bit misleading at\nthe moment as currently it's just a flag to tell rebase-helper that the\ntodo list is being edited rather than actually implementing the\nfunctionality to edit the list (but hopefully that will follow in the\nfuture).\n\n> \n> The second one strips newlines from append_todo_help() messages, which\n> require to update the translations. This change was advised to me by\n> Stefan Beller, but Johannes Schindelin voiced concerns. I don’t really\n> have a strong opinion about it, so feel free to give yours.\n\nI'm not sure I understand what the point of this patch is, if the\nnewlines are unnecessary then I'd just omit them from the first patch -\nam I missing something?\n\nBest Wishes\n\nPhillip\n\n> Alban Gruin (2):\n>   rebase--interactive: rewrite append_todo_help() in C\n>   sequencer: remove newlines from append_todo_help() messages\n> \n>  builtin/rebase--helper.c   | 10 ++++++--\n>  git-rebase--interactive.sh | 52 ++-----------------------------------\n>  sequencer.c                | 64 ++++++++++++++++++++++++++++++++++++++++++++++\n>  sequencer.h                |  1 +\n>  4 files changed, 75 insertions(+), 52 deletions(-)\n> \n\n"},{"id":"348919","messageId":"CAGZ79kZ7HiyZTS40XPwpjN3PBbdW0ETN=dfzeE-90Rp+irXnSA@mail.gmail.com","threadId":"48613","inReplyTo":"a6d6e5c1-e7ea-1131-c798-9d5e44603d87@talktalk.net","subject":"Re: [GSoC][PATCH 0/2] rebase -i: rewrite append_todo_help() in C","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-31T18:44:04Z","receivedAt":"2018-05-31T18:44:08Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Thu, May 31, 2018 at 10:48 AM, Phillip Wood\n<phillip.wood@talktalk.net> wrote:\n> Hi Alban, it's great to see you working on this\n>\n> On 31/05/18 12:01, Alban Gruin wrote:\n>> This series rewrites append_todo_help() from shell to C. This is part\n>> of the effort to rewrite interactive rebase in C.\n>>\n>> The first commit rewrites append_todo_help() in C (the C version\n>> covers a bit more than the old shell version), adds some parameters to\n>> rebase--helper, etc.\n>\n> I've had a read of the first patch and I think it looks fine, my only\n> comment would be that the help for '--edit-todo' is a bit misleading at\n> the moment as currently it's just a flag to tell rebase-helper that the\n> todo list is being edited rather than actually implementing the\n> functionality to edit the list (but hopefully that will follow in the\n> future).\n\nWould you have better suggestions for the name of the flag?\nOf the top of my head:\n  --write-edit-todo\n  --hint-todo-edit\n  --include-todo-edit-hint\nnot sure I like these names, though they seem to reflect the\nnature of that flag a little bit better.\n\n>> The second one strips newlines from append_todo_help() messages, which\n>> require to update the translations. This change was advised to me by\n>> Stefan Beller, but Johannes Schindelin voiced concerns. I don’t really\n>> have a strong opinion about it, so feel free to give yours.\n>\n> I'm not sure I understand what the point of this patch is, if the\n> newlines are unnecessary then I'd just omit them from the first patch -\n> am I missing something?\n>\n\nThe new lines are part of the output and are currently in the part to\nbe translated:\nFor example from the German translation file:\n\n#: git-rebase--interactive.sh:171\nmsgid \"\"\n\"\\n\"\n\"Do not remove any line. Use 'drop' explicitly to remove a commit.\\n\"\nmsgstr \"\"\n\"\\n\"\n\"Keine Zeile entfernen. Benutzen Sie 'drop', um explizit einen Commit zu\\n\"\n\"entfernen.\\n\"\n\nAfter patch 2 is applied, the translators only see\n\"Do not remove any line. Use 'drop' explicitly to remove a commit.\"\nas a need to translate, and the two additional new lines (one in front\nand one after the string) are just put in place autormatically.\n\nUsually we do not want to play sentence lego, but this is a whole\nsentence for translation; it is rather about formatting the output for\nthe terminal, adding new lines to separate some messages.\n\nI thought this patch would just show goodwill towards translators\nthat do not need to replicate the formatting exactly.\n\nIf you feel strongly, I'd rather see Alban drop this second patch and\nmove on instead of waiting for our argument to settle. ( I do not feel\nstrongly about it, but put it out as a suggestion as that seemed like\nit would lead to a better end state for the project).\n\nThanks,\nStefan\n"},{"id":"348924","messageId":"edb744b1-f984-70fc-4639-f0414df8c669@gmail.com","threadId":"48613","inReplyTo":"a6d6e5c1-e7ea-1131-c798-9d5e44603d87@talktalk.net","subject":"Re: [GSoC][PATCH 0/2] rebase -i: rewrite append_todo_help() in C","fromName":"Alban Gruin","fromEmail":"alban.gruin@gmail.com","sentAt":"2018-05-31T19:25:04Z","receivedAt":"2018-05-31T19:25:14Z","isPatch":true,"sender":{"key":"alban.gruin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6310153?v=4"},"body":"Hi Phillip,\n\nLe 31/05/2018 à 19:48, Phillip Wood a écrit :\n> Hi Alban, it's great to see you working on this\n> \n> On 31/05/18 12:01, Alban Gruin wrote:\n>> This series rewrites append_todo_help() from shell to C. This is part\n>> of the effort to rewrite interactive rebase in C.\n>>\n>> The first commit rewrites append_todo_help() in C (the C version\n>> covers a bit more than the old shell version), adds some parameters to\n>> rebase--helper, etc.\n> \n> I've had a read of the first patch and I think it looks fine, my only\n> comment would be that the help for '--edit-todo' is a bit misleading at\n> the moment as currently it's just a flag to tell rebase-helper that the\n> todo list is being edited rather than actually implementing the\n> functionality to edit the list\n\nRight, what do you think about something like “appends the edit-todo\nmessage to the todo list”?\n\n> (but hopefully that will follow in the\n> future).\n> \n\nThis is the next step :)\n\nCheers,\nAlban\n\n"},{"id":"348926","messageId":"2bf2d178-d286-c566-f68e-79c70fe66dbf@gmail.com","threadId":"48613","inReplyTo":"CAGZ79kZ7HiyZTS40XPwpjN3PBbdW0ETN=dfzeE-90Rp+irXnSA@mail.gmail.com","subject":"Re: [GSoC][PATCH 0/2] rebase -i: rewrite append_todo_help() in C","fromName":"Alban Gruin","fromEmail":"alban.gruin@gmail.com","sentAt":"2018-05-31T19:33:18Z","receivedAt":"2018-05-31T19:33:30Z","isPatch":true,"sender":{"key":"alban.gruin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6310153?v=4"},"body":"Hi Stefan,\n\nLe 31/05/2018 à 20:44, Stefan Beller a écrit :\n> On Thu, May 31, 2018 at 10:48 AM, Phillip Wood\n> <phillip.wood@talktalk.net> wrote:\n>> Hi Alban, it's great to see you working on this\n>>\n>> On 31/05/18 12:01, Alban Gruin wrote:\n>>> This series rewrites append_todo_help() from shell to C. This is part\n>>> of the effort to rewrite interactive rebase in C.\n>>>\n>>> The first commit rewrites append_todo_help() in C (the C version\n>>> covers a bit more than the old shell version), adds some parameters to\n>>> rebase--helper, etc.\n>>\n>> I've had a read of the first patch and I think it looks fine, my only\n>> comment would be that the help for '--edit-todo' is a bit misleading at\n>> the moment as currently it's just a flag to tell rebase-helper that the\n>> todo list is being edited rather than actually implementing the\n>> functionality to edit the list (but hopefully that will follow in the\n>> future).\n> \n> Would you have better suggestions for the name of the flag?\n> Of the top of my head:\n>   --write-edit-todo\n>   --hint-todo-edit\n>   --include-todo-edit-hint\n> not sure I like these names, though they seem to reflect the\n> nature of that flag a little bit better.\n> \n\nAs my next patch series will probably be about rewriting edit-todo in C,\ndo you really think I should rename the flag?\n\n> If you feel strongly, I'd rather see Alban drop this second patch and\n> move on instead of waiting for our argument to settle. ( I do not feel\n> strongly about it, but put it out as a suggestion as that seemed like\n> it would lead to a better end state for the project).\n> \n\nOkay, so I drop this patch and reroll the other?\n\n\nCheers,\nAlban\n\n"},{"id":"348928","messageId":"CAGZ79kbj=6FPHYR==kwWyv8DaA5SkhO6jGffAXOi=8Wcn5pL5Q@mail.gmail.com","threadId":"48613","inReplyTo":"2bf2d178-d286-c566-f68e-79c70fe66dbf@gmail.com","subject":"Re: [GSoC][PATCH 0/2] rebase -i: rewrite append_todo_help() in C","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-31T19:41:30Z","receivedAt":"2018-05-31T19:41:35Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Thu, May 31, 2018 at 12:33 PM, Alban Gruin <alban.gruin@gmail.com> wrote:\n> Hi Stefan,\n>\n> Le 31/05/2018 à 20:44, Stefan Beller a écrit :\n>> On Thu, May 31, 2018 at 10:48 AM, Phillip Wood\n>> <phillip.wood@talktalk.net> wrote:\n>>> Hi Alban, it's great to see you working on this\n>>>\n>>> On 31/05/18 12:01, Alban Gruin wrote:\n>>>> This series rewrites append_todo_help() from shell to C. This is part\n>>>> of the effort to rewrite interactive rebase in C.\n>>>>\n>>>> The first commit rewrites append_todo_help() in C (the C version\n>>>> covers a bit more than the old shell version), adds some parameters to\n>>>> rebase--helper, etc.\n>>>\n>>> I've had a read of the first patch and I think it looks fine, my only\n>>> comment would be that the help for '--edit-todo' is a bit misleading at\n>>> the moment as currently it's just a flag to tell rebase-helper that the\n>>> todo list is being edited rather than actually implementing the\n>>> functionality to edit the list (but hopefully that will follow in the\n>>> future).\n>>\n>> Would you have better suggestions for the name of the flag?\n>> Of the top of my head:\n>>   --write-edit-todo\n>>   --hint-todo-edit\n>>   --include-todo-edit-hint\n>> not sure I like these names, though they seem to reflect the\n>> nature of that flag a little bit better.\n>>\n>\n> As my next patch series will probably be about rewriting edit-todo in C,\n> do you really think I should rename the flag?\n\nIf you reroll, you could think of doing that. If you have the next series\nprepared already that build on top, it may not be worth it.\n\n>> If you feel strongly, I'd rather see Alban drop this second patch and\n>> move on instead of waiting for our argument to settle. ( I do not feel\n>> strongly about it, but put it out as a suggestion as that seemed like\n>> it would lead to a better end state for the project).\n>>\n>\n> Okay, so I drop this patch and reroll the other?\n\nSure, but maybe give Philip some time to react?\n"},{"id":"348991","messageId":"db2bb0f9-b2ff-4482-a9bd-1cdd39a9ad08@talktalk.net","threadId":"48613","inReplyTo":"edb744b1-f984-70fc-4639-f0414df8c669@gmail.com","subject":"Re: [GSoC][PATCH 0/2] rebase -i: rewrite append_todo_help() in C","fromName":"Phillip Wood","fromEmail":"phillip.wood@talktalk.net","sentAt":"2018-06-01T09:38:57Z","receivedAt":"2018-06-01T09:39:05Z","isPatch":true,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"On 31/05/18 20:25, Alban Gruin wrote:\n> Hi Phillip,\n> \n> Le 31/05/2018 à 19:48, Phillip Wood a écrit :\n>> Hi Alban, it's great to see you working on this\n>>\n>> On 31/05/18 12:01, Alban Gruin wrote:\n>>> This series rewrites append_todo_help() from shell to C. This is part\n>>> of the effort to rewrite interactive rebase in C.\n>>>\n>>> The first commit rewrites append_todo_help() in C (the C version\n>>> covers a bit more than the old shell version), adds some parameters to\n>>> rebase--helper, etc.\n>>\n>> I've had a read of the first patch and I think it looks fine, my only\n>> comment would be that the help for '--edit-todo' is a bit misleading at\n>> the moment as currently it's just a flag to tell rebase-helper that the\n>> todo list is being edited rather than actually implementing the\n>> functionality to edit the list\n> \n> Right, what do you think about something like “appends the edit-todo\n> message to the todo list”?\n\nYes that sounds good, though if you're about to implement editing the \ntodo list with --edit-todo I wouldn't worry too much\n\nBest Wishes\n\nPhillip\n\n>> (but hopefully that will follow in the\n>> future).\n>>\n> \n> This is the next step :)\n> \n> Cheers,\n> Alban\n> \n\n"},{"id":"348992","messageId":"061ebcf7-f88e-4d4d-da73-f81e9251ee3b@talktalk.net","threadId":"48613","inReplyTo":"CAGZ79kZ7HiyZTS40XPwpjN3PBbdW0ETN=dfzeE-90Rp+irXnSA@mail.gmail.com","subject":"Re: [GSoC][PATCH 0/2] rebase -i: rewrite append_todo_help() in C","fromName":"Phillip Wood","fromEmail":"phillip.wood@talktalk.net","sentAt":"2018-06-01T09:44:04Z","receivedAt":"2018-06-01T09:44:10Z","isPatch":true,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"On 31/05/18 19:44, Stefan Beller wrote:\n> On Thu, May 31, 2018 at 10:48 AM, Phillip Wood\n> <phillip.wood@talktalk.net> wrote:\n>> Hi Alban, it's great to see you working on this\n>>\n>> On 31/05/18 12:01, Alban Gruin wrote:\n>>> This series rewrites append_todo_help() from shell to C. This is part\n>>> of the effort to rewrite interactive rebase in C.\n>>>\n>>> The first commit rewrites append_todo_help() in C (the C version\n>>> covers a bit more than the old shell version), adds some parameters to\n>>> rebase--helper, etc.\n>>\n>> I've had a read of the first patch and I think it looks fine, my only\n>> comment would be that the help for '--edit-todo' is a bit misleading at\n>> the moment as currently it's just a flag to tell rebase-helper that the\n>> todo list is being edited rather than actually implementing the\n>> functionality to edit the list (but hopefully that will follow in the\n>> future).\n> \n> Would you have better suggestions for the name of the flag?\n> Of the top of my head:\n>    --write-edit-todo\n>    --hint-todo-edit\n>    --include-todo-edit-hint\n> not sure I like these names, though they seem to reflect the\n> nature of that flag a little bit better.\n> \n>>> The second one strips newlines from append_todo_help() messages, which\n>>> require to update the translations. This change was advised to me by\n>>> Stefan Beller, but Johannes Schindelin voiced concerns. I don’t really\n>>> have a strong opinion about it, so feel free to give yours.\n>>\n>> I'm not sure I understand what the point of this patch is, if the\n>> newlines are unnecessary then I'd just omit them from the first patch -\n>> am I missing something?\n>>\n> \n> The new lines are part of the output and are currently in the part to\n> be translated:\n> For example from the German translation file:\n> \n> #: git-rebase--interactive.sh:171\n> msgid \"\"\n> \"\\n\"\n> \"Do not remove any line. Use 'drop' explicitly to remove a commit.\\n\"\n> msgstr \"\"\n> \"\\n\"\n> \"Keine Zeile entfernen. Benutzen Sie 'drop', um explizit einen Commit zu\\n\"\n> \"entfernen.\\n\"\n> \n> After patch 2 is applied, the translators only see\n> \"Do not remove any line. Use 'drop' explicitly to remove a commit.\"\n> as a need to translate, and the two additional new lines (one in front\n> and one after the string) are just put in place autormatically.\n> \n> Usually we do not want to play sentence lego, but this is a whole\n> sentence for translation; it is rather about formatting the output for\n> the terminal, adding new lines to separate some messages.\n> \n> I thought this patch would just show goodwill towards translators\n> that do not need to replicate the formatting exactly.\n> \n> If you feel strongly, I'd rather see Alban drop this second patch and\n> move on instead of waiting for our argument to settle. ( I do not feel\n> strongly about it, but put it out as a suggestion as that seemed like\n> it would lead to a better end state for the project).\n\nThanks for the explanation, I see what you're trying to do. I don't have \na strong feeling either way, I can see the potential advantage but as it \nchanges strings that are currently translated I'm not sure it is cost \nfree. Do you know how the translators feel about the change as they're \nthe ones it is aimed at?\n\nBest Wishes\n\nPhillip\n\n> \n> Thanks,\n> Stefan\n> \n\n"},{"id":"349014","messageId":"CAGZ79ka7SMLdiVJVNU9Dzpzv4yQSYeODFnBxpwTDEhNnNkj7eg@mail.gmail.com","threadId":"48613","inReplyTo":"061ebcf7-f88e-4d4d-da73-f81e9251ee3b@talktalk.net","subject":"Re: [GSoC][PATCH 0/2] rebase -i: rewrite append_todo_help() in C","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-06-01T19:46:42Z","receivedAt":"2018-06-01T19:46:50Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"> Thanks for the explanation, I see what you're trying to do. I don't have a\n> strong feeling either way, I can see the potential advantage but as it\n> changes strings that are currently translated I'm not sure it is cost free.\n> Do you know how the translators feel about the change as they're the ones it\n> is aimed at?\n\nNo, not at all.\n\nHence I am being vague on how much we desire it.\n"},{"id":"349338","messageId":"20180605125334.14082-1-alban.gruin@gmail.com","threadId":"48613","inReplyTo":"20180531110130.18839-1-alban.gruin@gmail.com","subject":"[GSoC][PATCH v2 0/1] rebase -i: rewrite append_todo_help() in C","fromName":"Alban Gruin","fromEmail":"alban.gruin@gmail.com","sentAt":"2018-06-05T12:53:33Z","receivedAt":"2018-06-05T12:53:50Z","isPatch":true,"sender":{"key":"alban.gruin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6310153?v=4"},"body":"This patch rewrites append_todo_help() from shell to C. The C version\ncovers a bit more than the old shell version. To achieve that, some\nparameters were added to rebase--helper.\n\nThis is part of the effort to rewrite interactive rebase in C.\n\nChanges since v1:\n\n - Renaming the parameter to insert the edit-todo message from\n   `edit-todo` to `write-edit-todo`.\n\n - Clarifying the `write-edit-todo` help message.\n\n - Dropping the commit that removed newlines in the messages.\n\nAlban Gruin (1):\n  rebase--interactive: rewrite append_todo_help() in C\n\n builtin/rebase--helper.c   | 10 ++++++--\n git-rebase--interactive.sh | 52 ++--------------------------------------\n sequencer.c                | 60 ++++++++++++++++++++++++++++++++++++++++++++++\n sequencer.h                |  1 +\n 4 files changed, 71 insertions(+), 52 deletions(-)\n\n-- \n2.16.4\n\n"},{"id":"349339","messageId":"20180605125334.14082-2-alban.gruin@gmail.com","threadId":"48613","inReplyTo":"20180605125334.14082-1-alban.gruin@gmail.com","subject":"[GSoC][PATCH v2 1/1] rebase--interactive: rewrite append_todo_help() in C","fromName":"Alban Gruin","fromEmail":"alban.gruin@gmail.com","sentAt":"2018-06-05T12:53:34Z","receivedAt":"2018-06-05T12:53:54Z","isPatch":true,"sender":{"key":"alban.gruin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6310153?v=4"},"body":"This rewrites append_todo_help() from shell to C. It also incorporates\nsome parts of initiate_action() and complete_action() that also write\nhelp texts to the todo file.\n\nTwo flags are added to rebase--helper.c: one to call\nappend_todo_help() (`--append-todo-help`), and another one to tell\nappend_todo_help() to write the help text suited for the edit-todo\nmode (`--write-edit-todo`).\n\nFinally, append_todo_help() is removed from git-rebase--interactive.sh\nto use `rebase--helper --append-todo-help` instead.\n\nSigned-off-by: Alban Gruin <alban.gruin@gmail.com>\n---\n builtin/rebase--helper.c   | 10 ++++++--\n git-rebase--interactive.sh | 52 ++--------------------------------------\n sequencer.c                | 60 ++++++++++++++++++++++++++++++++++++++++++++++\n sequencer.h                |  1 +\n 4 files changed, 71 insertions(+), 52 deletions(-)\n\ndiff --git a/builtin/rebase--helper.c b/builtin/rebase--helper.c\nindex f7c2a5fdc..7ef92fbb6 100644\n--- a/builtin/rebase--helper.c\n+++ b/builtin/rebase--helper.c\n@@ -12,12 +12,12 @@ static const char * const builtin_rebase_helper_usage[] = {\n int cmd_rebase__helper(int argc, const char **argv, const char *prefix)\n {\n \tstruct replay_opts opts = REPLAY_OPTS_INIT;\n-\tunsigned flags = 0, keep_empty = 0, rebase_merges = 0;\n+\tunsigned flags = 0, keep_empty = 0, rebase_merges = 0, edit_todo = 0;\n \tint abbreviate_commands = 0, rebase_cousins = -1;\n \tenum {\n \t\tCONTINUE = 1, ABORT, MAKE_SCRIPT, SHORTEN_OIDS, EXPAND_OIDS,\n \t\tCHECK_TODO_LIST, SKIP_UNNECESSARY_PICKS, REARRANGE_SQUASH,\n-\t\tADD_EXEC\n+\t\tADD_EXEC, APPEND_TODO_HELP\n \t} command = 0;\n \tstruct option options[] = {\n \t\tOPT_BOOL(0, \"ff\", &opts.allow_ff, N_(\"allow fast-forward\")),\n@@ -27,6 +27,8 @@ int cmd_rebase__helper(int argc, const char **argv, const char *prefix)\n \t\tOPT_BOOL(0, \"rebase-merges\", &rebase_merges, N_(\"rebase merge commits\")),\n \t\tOPT_BOOL(0, \"rebase-cousins\", &rebase_cousins,\n \t\t\t N_(\"keep original branch points of cousins\")),\n+\t\tOPT_BOOL(0, \"write-edit-todo\", &edit_todo,\n+\t\t\t N_(\"append the edit-todo message to the todo-list\")),\n \t\tOPT_CMDMODE(0, \"continue\", &command, N_(\"continue rebase\"),\n \t\t\t\tCONTINUE),\n \t\tOPT_CMDMODE(0, \"abort\", &command, N_(\"abort rebase\"),\n@@ -45,6 +47,8 @@ int cmd_rebase__helper(int argc, const char **argv, const char *prefix)\n \t\t\tN_(\"rearrange fixup/squash lines\"), REARRANGE_SQUASH),\n \t\tOPT_CMDMODE(0, \"add-exec-commands\", &command,\n \t\t\tN_(\"insert exec commands in todo list\"), ADD_EXEC),\n+\t\tOPT_CMDMODE(0, \"append-todo-help\", &command,\n+\t\t\t    N_(\"insert the help in the todo list\"), APPEND_TODO_HELP),\n \t\tOPT_END()\n \t};\n \n@@ -84,5 +88,7 @@ int cmd_rebase__helper(int argc, const char **argv, const char *prefix)\n \t\treturn !!rearrange_squash();\n \tif (command == ADD_EXEC && argc == 2)\n \t\treturn !!sequencer_add_exec_commands(argv[1]);\n+\tif (command == APPEND_TODO_HELP && argc == 1)\n+\t\treturn !!append_todo_help(edit_todo, keep_empty);\n \tusage_with_options(builtin_rebase_helper_usage, options);\n }\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 299ded213..94c23a7af 100644\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -39,38 +39,6 @@ comment_for_reflog () {\n \tesac\n }\n \n-append_todo_help () {\n-\tgettext \"\n-Commands:\n-p, pick <commit> = use commit\n-r, reword <commit> = use commit, but edit the commit message\n-e, edit <commit> = use commit, but stop for amending\n-s, squash <commit> = use commit, but meld into previous commit\n-f, fixup <commit> = like \\\"squash\\\", but discard this commit's log message\n-x, exec <command> = run command (the rest of the line) using shell\n-d, drop <commit> = remove commit\n-l, label <label> = label current HEAD with a name\n-t, reset <label> = reset HEAD to a label\n-m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]\n-.       create a merge commit using the original merge commit's\n-.       message (or the oneline, if no original merge commit was\n-.       specified). Use -c <commit> to reword the commit message.\n-\n-These lines can be re-ordered; they are executed from top to bottom.\n-\" | git stripspace --comment-lines >>\"$todo\"\n-\n-\tif test $(get_missing_commit_check_level) = error\n-\tthen\n-\t\tgettext \"\n-Do not remove any line. Use 'drop' explicitly to remove a commit.\n-\" | git stripspace --comment-lines >>\"$todo\"\n-\telse\n-\t\tgettext \"\n-If you remove a line here THAT COMMIT WILL BE LOST.\n-\" | git stripspace --comment-lines >>\"$todo\"\n-\tfi\n-}\n-\n die_abort () {\n \tapply_autostash\n \trm -rf \"$state_dir\"\n@@ -143,13 +111,7 @@ initiate_action () {\n \t\tgit stripspace --strip-comments <\"$todo\" >\"$todo\".new\n \t\tmv -f \"$todo\".new \"$todo\"\n \t\tcollapse_todo_ids\n-\t\tappend_todo_help\n-\t\tgettext \"\n-You are editing the todo file of an ongoing interactive rebase.\n-To continue rebase after editing, run:\n-    git rebase --continue\n-\n-\" | git stripspace --comment-lines >>\"$todo\"\n+\t\tgit rebase--helper --append-todo-help --write-edit-todo\n \n \t\tgit_sequence_editor \"$todo\" ||\n \t\t\tdie \"$(gettext \"Could not execute editor\")\"\n@@ -220,17 +182,7 @@ $comment_char $(eval_ngettext \\\n \t\"Rebase \\$shortrevisions onto \\$shortonto (\\$todocount commands)\" \\\n \t\"$todocount\")\n EOF\n-\tappend_todo_help\n-\tgettext \"\n-\tHowever, if you remove everything, the rebase will be aborted.\n-\n-\t\" | git stripspace --comment-lines >>\"$todo\"\n-\n-\tif test -z \"$keep_empty\"\n-\tthen\n-\t\tprintf '%s\\n' \"$comment_char $(gettext \"Note that empty commits are commented out\")\" >>\"$todo\"\n-\tfi\n-\n+\tgit rebase--helper --append-todo-help ${keep_empty:+--keep-empty}\n \n \thas_action \"$todo\" ||\n \t\treturn 2\ndiff --git a/sequencer.c b/sequencer.c\nindex b522523d4..c9d488b11 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -4336,6 +4336,66 @@ int check_todo_list(void)\n \treturn res;\n }\n \n+int append_todo_help(unsigned edit_todo, unsigned keep_empty)\n+{\n+\tstruct strbuf buf = STRBUF_INIT;\n+\tFILE *todo;\n+\tint ret;\n+\tconst char *msg = _(\"\\nCommands:\\n\"\n+\"p, pick <commit> = use commit\\n\"\n+\"r, reword <commit> = use commit, but edit the commit message\\n\"\n+\"e, edit <commit> = use commit, but stop for amending\\n\"\n+\"s, squash <commit> = use commit, but meld into previous commit\\n\"\n+\"f, fixup <commit> = like \\\"squash\\\", but discard this commit's log message\\n\"\n+\"x, exec <command> = run command (the rest of the line) using shell\\n\"\n+\"d, drop <commit> = remove commit\\n\"\n+\"l, label <label> = label current HEAD with a name\\n\"\n+\"t, reset <label> = reset HEAD to a label\\n\"\n+\"m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]\\n\"\n+\".       create a merge commit using the original merge commit's\\n\"\n+\".       message (or the oneline, if no original merge commit was\\n\"\n+\".       specified). Use -c <commit> to reword the commit message.\\n\"\n+\"\\n\"\n+\"These lines can be re-ordered; they are executed from top to bottom.\\n\");\n+\n+\ttodo = fopen_or_warn(rebase_path_todo(), \"a\");\n+\tif (!todo)\n+\t\treturn 1;\n+\n+\tstrbuf_add_commented_lines(&buf, msg, strlen(msg));\n+\n+\tif (get_missing_commit_check_level() == CHECK_ERROR)\n+\t\tmsg = _(\"\\nDo not remove any line. Use 'drop' \"\n+\t\t\t \"explicitly to remove a commit.\\n\");\n+\telse\n+\t\tmsg = _(\"\\nIf you remove a line here \"\n+\t\t\t \"THAT COMMIT WILL BE LOST.\\n\");\n+\n+\tstrbuf_add_commented_lines(&buf, msg, strlen(msg));\n+\n+\tif (edit_todo)\n+\t\tmsg = _(\"\\nYou are editing the todo file \"\n+\t\t\t\"of an ongoing interactive rebase.\\n\"\n+\t\t\t\"To continue rebase after editing, run:\\n\"\n+\t\t\t\"    git rebase --continue\\n\\n\");\n+\telse\n+\t\tmsg = _(\"\\nHowever, if you remove everything, \"\n+\t\t\t\"the rebase will be aborted.\\n\\n\");\n+\n+\tstrbuf_add_commented_lines(&buf, msg, strlen(msg));\n+\n+\tif (!keep_empty) {\n+\t\tmsg = _(\"Note that empty commits are commented out\");\n+\t\tstrbuf_add_commented_lines(&buf, msg, strlen(msg));\n+\t}\n+\n+\tret = fputs(buf.buf, todo);\n+\tfclose(todo);\n+\tstrbuf_release(&buf);\n+\n+\treturn ret;\n+}\n+\n static int rewrite_file(const char *path, const char *buf, size_t len)\n {\n \tint rc = 0;\ndiff --git a/sequencer.h b/sequencer.h\nindex c5787c6b5..e14f6590e 100644\n--- a/sequencer.h\n+++ b/sequencer.h\n@@ -80,6 +80,7 @@ int sequencer_make_script(FILE *out, int argc, const char **argv,\n int sequencer_add_exec_commands(const char *command);\n int transform_todos(unsigned flags);\n int check_todo_list(void);\n+int append_todo_help(unsigned edit_todo, unsigned keep_empty);\n int skip_unnecessary_picks(void);\n int rearrange_squash(void);\n \n-- \n2.16.4\n\n"},{"id":"349605","messageId":"20180607103012.22981-1-alban.gruin@gmail.com","threadId":"48613","inReplyTo":"20180605125334.14082-1-alban.gruin@gmail.com","subject":"[GSoC][PATCH v3 0/1] rebase -i: rewrite append_todo_help() in C","fromName":"Alban Gruin","fromEmail":"alban.gruin@gmail.com","sentAt":"2018-06-07T10:30:11Z","receivedAt":"2018-06-07T10:30:59Z","isPatch":true,"sender":{"key":"alban.gruin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6310153?v=4"},"body":"This patch rewrites append_todo_help() from shell to C. The C version\ncovers a bit more than the old shell version. To achieve that, some\nparameters were added to rebase--helper.\n\nThis is part of the effort to rewrite interactive rebase in C.\n\nChanges since v2:\n\n - Renaming the variable `edit_todo` to `write_edit_todo` to avoid\n   confusions, after a comment by Christian Couder[1].\n\n[1] https://github.com/git/git/pull/503#discussion_r193392270\n\nAlban Gruin (1):\n  rebase--interactive: rewrite append_todo_help() in C\n\n builtin/rebase--helper.c   | 10 ++++++--\n git-rebase--interactive.sh | 52 ++--------------------------------------\n sequencer.c                | 60 ++++++++++++++++++++++++++++++++++++++++++++++\n sequencer.h                |  1 +\n 4 files changed, 71 insertions(+), 52 deletions(-)\n\n-- \n2.16.4\n\n"},{"id":"349606","messageId":"20180607103012.22981-2-alban.gruin@gmail.com","threadId":"48613","inReplyTo":"20180607103012.22981-1-alban.gruin@gmail.com","subject":"[GSoC][PATCH v3 1/1] rebase--interactive: rewrite append_todo_help() in C","fromName":"Alban Gruin","fromEmail":"alban.gruin@gmail.com","sentAt":"2018-06-07T10:30:12Z","receivedAt":"2018-06-07T10:31:02Z","isPatch":true,"sender":{"key":"alban.gruin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6310153?v=4"},"body":"This rewrites append_todo_help() from shell to C. It also incorporates\nsome parts of initiate_action() and complete_action() that also write\nhelp texts to the todo file.\n\nTwo flags are added to rebase--helper.c: one to call\nappend_todo_help() (`--append-todo-help`), and another one to tell\nappend_todo_help() to write the help text suited for the edit-todo\nmode (`--write-edit-todo`).\n\nFinally, append_todo_help() is removed from git-rebase--interactive.sh\nto use `rebase--helper --append-todo-help` instead.\n\nSigned-off-by: Alban Gruin <alban.gruin@gmail.com>\n---\n builtin/rebase--helper.c   | 10 ++++++--\n git-rebase--interactive.sh | 52 ++--------------------------------------\n sequencer.c                | 60 ++++++++++++++++++++++++++++++++++++++++++++++\n sequencer.h                |  1 +\n 4 files changed, 71 insertions(+), 52 deletions(-)\n\ndiff --git a/builtin/rebase--helper.c b/builtin/rebase--helper.c\nindex f7c2a5fdc..ded5e291d 100644\n--- a/builtin/rebase--helper.c\n+++ b/builtin/rebase--helper.c\n@@ -12,12 +12,12 @@ static const char * const builtin_rebase_helper_usage[] = {\n int cmd_rebase__helper(int argc, const char **argv, const char *prefix)\n {\n \tstruct replay_opts opts = REPLAY_OPTS_INIT;\n-\tunsigned flags = 0, keep_empty = 0, rebase_merges = 0;\n+\tunsigned flags = 0, keep_empty = 0, rebase_merges = 0, write_edit_todo = 0;\n \tint abbreviate_commands = 0, rebase_cousins = -1;\n \tenum {\n \t\tCONTINUE = 1, ABORT, MAKE_SCRIPT, SHORTEN_OIDS, EXPAND_OIDS,\n \t\tCHECK_TODO_LIST, SKIP_UNNECESSARY_PICKS, REARRANGE_SQUASH,\n-\t\tADD_EXEC\n+\t\tADD_EXEC, APPEND_TODO_HELP\n \t} command = 0;\n \tstruct option options[] = {\n \t\tOPT_BOOL(0, \"ff\", &opts.allow_ff, N_(\"allow fast-forward\")),\n@@ -27,6 +27,8 @@ int cmd_rebase__helper(int argc, const char **argv, const char *prefix)\n \t\tOPT_BOOL(0, \"rebase-merges\", &rebase_merges, N_(\"rebase merge commits\")),\n \t\tOPT_BOOL(0, \"rebase-cousins\", &rebase_cousins,\n \t\t\t N_(\"keep original branch points of cousins\")),\n+\t\tOPT_BOOL(0, \"write-edit-todo\", &write_edit_todo,\n+\t\t\t N_(\"append the edit-todo message to the todo-list\")),\n \t\tOPT_CMDMODE(0, \"continue\", &command, N_(\"continue rebase\"),\n \t\t\t\tCONTINUE),\n \t\tOPT_CMDMODE(0, \"abort\", &command, N_(\"abort rebase\"),\n@@ -45,6 +47,8 @@ int cmd_rebase__helper(int argc, const char **argv, const char *prefix)\n \t\t\tN_(\"rearrange fixup/squash lines\"), REARRANGE_SQUASH),\n \t\tOPT_CMDMODE(0, \"add-exec-commands\", &command,\n \t\t\tN_(\"insert exec commands in todo list\"), ADD_EXEC),\n+\t\tOPT_CMDMODE(0, \"append-todo-help\", &command,\n+\t\t\t    N_(\"insert the help in the todo list\"), APPEND_TODO_HELP),\n \t\tOPT_END()\n \t};\n \n@@ -84,5 +88,7 @@ int cmd_rebase__helper(int argc, const char **argv, const char *prefix)\n \t\treturn !!rearrange_squash();\n \tif (command == ADD_EXEC && argc == 2)\n \t\treturn !!sequencer_add_exec_commands(argv[1]);\n+\tif (command == APPEND_TODO_HELP && argc == 1)\n+\t\treturn !!append_todo_help(write_edit_todo, keep_empty);\n \tusage_with_options(builtin_rebase_helper_usage, options);\n }\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 299ded213..94c23a7af 100644\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -39,38 +39,6 @@ comment_for_reflog () {\n \tesac\n }\n \n-append_todo_help () {\n-\tgettext \"\n-Commands:\n-p, pick <commit> = use commit\n-r, reword <commit> = use commit, but edit the commit message\n-e, edit <commit> = use commit, but stop for amending\n-s, squash <commit> = use commit, but meld into previous commit\n-f, fixup <commit> = like \\\"squash\\\", but discard this commit's log message\n-x, exec <command> = run command (the rest of the line) using shell\n-d, drop <commit> = remove commit\n-l, label <label> = label current HEAD with a name\n-t, reset <label> = reset HEAD to a label\n-m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]\n-.       create a merge commit using the original merge commit's\n-.       message (or the oneline, if no original merge commit was\n-.       specified). Use -c <commit> to reword the commit message.\n-\n-These lines can be re-ordered; they are executed from top to bottom.\n-\" | git stripspace --comment-lines >>\"$todo\"\n-\n-\tif test $(get_missing_commit_check_level) = error\n-\tthen\n-\t\tgettext \"\n-Do not remove any line. Use 'drop' explicitly to remove a commit.\n-\" | git stripspace --comment-lines >>\"$todo\"\n-\telse\n-\t\tgettext \"\n-If you remove a line here THAT COMMIT WILL BE LOST.\n-\" | git stripspace --comment-lines >>\"$todo\"\n-\tfi\n-}\n-\n die_abort () {\n \tapply_autostash\n \trm -rf \"$state_dir\"\n@@ -143,13 +111,7 @@ initiate_action () {\n \t\tgit stripspace --strip-comments <\"$todo\" >\"$todo\".new\n \t\tmv -f \"$todo\".new \"$todo\"\n \t\tcollapse_todo_ids\n-\t\tappend_todo_help\n-\t\tgettext \"\n-You are editing the todo file of an ongoing interactive rebase.\n-To continue rebase after editing, run:\n-    git rebase --continue\n-\n-\" | git stripspace --comment-lines >>\"$todo\"\n+\t\tgit rebase--helper --append-todo-help --write-edit-todo\n \n \t\tgit_sequence_editor \"$todo\" ||\n \t\t\tdie \"$(gettext \"Could not execute editor\")\"\n@@ -220,17 +182,7 @@ $comment_char $(eval_ngettext \\\n \t\"Rebase \\$shortrevisions onto \\$shortonto (\\$todocount commands)\" \\\n \t\"$todocount\")\n EOF\n-\tappend_todo_help\n-\tgettext \"\n-\tHowever, if you remove everything, the rebase will be aborted.\n-\n-\t\" | git stripspace --comment-lines >>\"$todo\"\n-\n-\tif test -z \"$keep_empty\"\n-\tthen\n-\t\tprintf '%s\\n' \"$comment_char $(gettext \"Note that empty commits are commented out\")\" >>\"$todo\"\n-\tfi\n-\n+\tgit rebase--helper --append-todo-help ${keep_empty:+--keep-empty}\n \n \thas_action \"$todo\" ||\n \t\treturn 2\ndiff --git a/sequencer.c b/sequencer.c\nindex cca968043..1ffd990f7 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -4326,6 +4326,66 @@ int check_todo_list(void)\n \treturn res;\n }\n \n+int append_todo_help(unsigned edit_todo, unsigned keep_empty)\n+{\n+\tstruct strbuf buf = STRBUF_INIT;\n+\tFILE *todo;\n+\tint ret;\n+\tconst char *msg = _(\"\\nCommands:\\n\"\n+\"p, pick <commit> = use commit\\n\"\n+\"r, reword <commit> = use commit, but edit the commit message\\n\"\n+\"e, edit <commit> = use commit, but stop for amending\\n\"\n+\"s, squash <commit> = use commit, but meld into previous commit\\n\"\n+\"f, fixup <commit> = like \\\"squash\\\", but discard this commit's log message\\n\"\n+\"x, exec <command> = run command (the rest of the line) using shell\\n\"\n+\"d, drop <commit> = remove commit\\n\"\n+\"l, label <label> = label current HEAD with a name\\n\"\n+\"t, reset <label> = reset HEAD to a label\\n\"\n+\"m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]\\n\"\n+\".       create a merge commit using the original merge commit's\\n\"\n+\".       message (or the oneline, if no original merge commit was\\n\"\n+\".       specified). Use -c <commit> to reword the commit message.\\n\"\n+\"\\n\"\n+\"These lines can be re-ordered; they are executed from top to bottom.\\n\");\n+\n+\ttodo = fopen_or_warn(rebase_path_todo(), \"a\");\n+\tif (!todo)\n+\t\treturn 1;\n+\n+\tstrbuf_add_commented_lines(&buf, msg, strlen(msg));\n+\n+\tif (get_missing_commit_check_level() == CHECK_ERROR)\n+\t\tmsg = _(\"\\nDo not remove any line. Use 'drop' \"\n+\t\t\t \"explicitly to remove a commit.\\n\");\n+\telse\n+\t\tmsg = _(\"\\nIf you remove a line here \"\n+\t\t\t \"THAT COMMIT WILL BE LOST.\\n\");\n+\n+\tstrbuf_add_commented_lines(&buf, msg, strlen(msg));\n+\n+\tif (edit_todo)\n+\t\tmsg = _(\"\\nYou are editing the todo file \"\n+\t\t\t\"of an ongoing interactive rebase.\\n\"\n+\t\t\t\"To continue rebase after editing, run:\\n\"\n+\t\t\t\"    git rebase --continue\\n\\n\");\n+\telse\n+\t\tmsg = _(\"\\nHowever, if you remove everything, \"\n+\t\t\t\"the rebase will be aborted.\\n\\n\");\n+\n+\tstrbuf_add_commented_lines(&buf, msg, strlen(msg));\n+\n+\tif (!keep_empty) {\n+\t\tmsg = _(\"Note that empty commits are commented out\");\n+\t\tstrbuf_add_commented_lines(&buf, msg, strlen(msg));\n+\t}\n+\n+\tret = fputs(buf.buf, todo);\n+\tfclose(todo);\n+\tstrbuf_release(&buf);\n+\n+\treturn ret;\n+}\n+\n static int rewrite_file(const char *path, const char *buf, size_t len)\n {\n \tint rc = 0;\ndiff --git a/sequencer.h b/sequencer.h\nindex c5787c6b5..e14f6590e 100644\n--- a/sequencer.h\n+++ b/sequencer.h\n@@ -80,6 +80,7 @@ int sequencer_make_script(FILE *out, int argc, const char **argv,\n int sequencer_add_exec_commands(const char *command);\n int transform_todos(unsigned flags);\n int check_todo_list(void);\n+int append_todo_help(unsigned edit_todo, unsigned keep_empty);\n int skip_unnecessary_picks(void);\n int rearrange_squash(void);\n \n-- \n2.16.4\n\n"},{"id":"350972","messageId":"20180626161643.31152-1-alban.gruin@gmail.com","threadId":"48613","inReplyTo":"20180607103012.22981-1-alban.gruin@gmail.com","subject":"[GSoC][PATCH v4 0/2] rebase -i: rewrite append_todo_help() in C","fromName":"Alban Gruin","fromEmail":"alban.gruin@gmail.com","sentAt":"2018-06-26T16:16:41Z","receivedAt":"2018-06-26T16:17:41Z","isPatch":true,"sender":{"key":"alban.gruin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6310153?v=4"},"body":"This patch rewrites append_todo_help() from shell to C. The C version\ncovers a bit more than the old shell version. To achieve that, some\nparameters were added to rebase--helper.\n\nThis also introduce a new source file, rebase-interactive.c.\n\nThis is part of the effort to rewrite interactive rebase in C.\n\nThis is based on next, as of 2018-06-26.\n\nChanges since v3:\n\n - Show an error message when append_todo_help() fails to edit the todo\n   list.\n\n - Introducing rebase-interactive.c to contain functions necessary for\n   interactive rebase.\n\nAlban Gruin (2):\n  sequencer: make two functions and an enum from sequencer.c public\n  rebase--interactive: rewrite append_todo_help() in C\n\n Makefile                   |  1 +\n builtin/rebase--helper.c   | 11 ++++--\n git-rebase--interactive.sh | 52 ++---------------------------\n rebase-interactive.c       | 68 ++++++++++++++++++++++++++++++++++++++\n rebase-interactive.h       |  6 ++++\n sequencer.c                |  8 ++---\n sequencer.h                |  6 ++++\n 7 files changed, 94 insertions(+), 58 deletions(-)\n create mode 100644 rebase-interactive.c\n create mode 100644 rebase-interactive.h\n\n-- \n2.18.0\n\n"},{"id":"350973","messageId":"20180626161643.31152-2-alban.gruin@gmail.com","threadId":"48613","inReplyTo":"20180626161643.31152-1-alban.gruin@gmail.com","subject":"[GSoC][PATCH v4 1/2] sequencer: make two functions and an enum from sequencer.c public","fromName":"Alban Gruin","fromEmail":"alban.gruin@gmail.com","sentAt":"2018-06-26T16:16:42Z","receivedAt":"2018-06-26T16:17:44Z","isPatch":true,"sender":{"key":"alban.gruin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6310153?v=4"},"body":"This makes rebase_path_todo(), get_missign_commit_check_level() and the\nenum check_level accessible outside sequencer.c.  This will be needed\nfor the rewrite of append_todo_help() from shell to C, as it will be in\na new library source file, rebase-interactive.c.\n\nSigned-off-by: Alban Gruin <alban.gruin@gmail.com>\n---\n sequencer.c | 8 ++------\n sequencer.h | 6 ++++++\n 2 files changed, 8 insertions(+), 6 deletions(-)\n\ndiff --git a/sequencer.c b/sequencer.c\nindex 0a291c91f..881a4f7f4 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -52,7 +52,7 @@ static GIT_PATH_FUNC(rebase_path, \"rebase-merge\")\n  * the lines are processed, they are removed from the front of this\n  * file and written to the tail of 'done'.\n  */\n-static GIT_PATH_FUNC(rebase_path_todo, \"rebase-merge/git-rebase-todo\")\n+GIT_PATH_FUNC(rebase_path_todo, \"rebase-merge/git-rebase-todo\")\n /*\n  * The rebase command lines that have already been processed. A line\n  * is moved here when it is first handled, before any associated user\n@@ -4223,11 +4223,7 @@ int transform_todos(unsigned flags)\n \treturn i;\n }\n \n-enum check_level {\n-\tCHECK_IGNORE = 0, CHECK_WARN, CHECK_ERROR\n-};\n-\n-static enum check_level get_missing_commit_check_level(void)\n+enum check_level get_missing_commit_check_level(void)\n {\n \tconst char *value;\n \ndiff --git a/sequencer.h b/sequencer.h\nindex c5787c6b5..08397b0d1 100644\n--- a/sequencer.h\n+++ b/sequencer.h\n@@ -3,6 +3,7 @@\n \n const char *git_path_commit_editmsg(void);\n const char *git_path_seq_dir(void);\n+const char *rebase_path_todo(void);\n \n #define APPEND_SIGNOFF_DEDUP (1u << 0)\n \n@@ -57,6 +58,10 @@ struct replay_opts {\n };\n #define REPLAY_OPTS_INIT { .action = -1, .current_fixups = STRBUF_INIT }\n \n+enum check_level {\n+\tCHECK_IGNORE = 0, CHECK_WARN, CHECK_ERROR\n+};\n+\n /* Call this to setup defaults before parsing command line options */\n void sequencer_init_config(struct replay_opts *opts);\n int sequencer_pick_revisions(struct replay_opts *opts);\n@@ -79,6 +84,7 @@ int sequencer_make_script(FILE *out, int argc, const char **argv,\n \n int sequencer_add_exec_commands(const char *command);\n int transform_todos(unsigned flags);\n+enum check_level get_missing_commit_check_level(void);\n int check_todo_list(void);\n int skip_unnecessary_picks(void);\n int rearrange_squash(void);\n-- \n2.18.0\n\n"},{"id":"350974","messageId":"20180626161643.31152-3-alban.gruin@gmail.com","threadId":"48613","inReplyTo":"20180626161643.31152-1-alban.gruin@gmail.com","subject":"[GSoC][PATCH v4 2/2] rebase--interactive: rewrite append_todo_help() in C","fromName":"Alban Gruin","fromEmail":"alban.gruin@gmail.com","sentAt":"2018-06-26T16:16:43Z","receivedAt":"2018-06-26T16:17:47Z","isPatch":true,"sender":{"key":"alban.gruin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6310153?v=4"},"body":"This rewrites append_todo_help() from shell to C. It also incorporates\nsome parts of initiate_action() and complete_action() that also write\nhelp texts to the todo file.\n\nThis also introduces the source file rebase-interactive.c. This file\nwill contain functions necessary for interactive rebase that are too\nspecific for the sequencer, and is part of libgit.a.\n\nTwo flags are added to rebase--helper.c: one to call\nappend_todo_help() (`--append-todo-help`), and another one to tell\nappend_todo_help() to write the help text suited for the edit-todo\nmode (`--write-edit-todo`).\n\nFinally, append_todo_help() is removed from git-rebase--interactive.sh\nto use `rebase--helper --append-todo-help` instead.\n\nSigned-off-by: Alban Gruin <alban.gruin@gmail.com>\n---\n Makefile                   |  1 +\n builtin/rebase--helper.c   | 11 ++++--\n git-rebase--interactive.sh | 52 ++---------------------------\n rebase-interactive.c       | 68 ++++++++++++++++++++++++++++++++++++++\n rebase-interactive.h       |  6 ++++\n 5 files changed, 86 insertions(+), 52 deletions(-)\n create mode 100644 rebase-interactive.c\n create mode 100644 rebase-interactive.h\n\ndiff --git a/Makefile b/Makefile\nindex 0cb6590f2..a281139ef 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -922,6 +922,7 @@ LIB_OBJS += protocol.o\n LIB_OBJS += quote.o\n LIB_OBJS += reachable.o\n LIB_OBJS += read-cache.o\n+LIB_OBJS += rebase-interactive.o\n LIB_OBJS += reflog-walk.o\n LIB_OBJS += refs.o\n LIB_OBJS += refs/files-backend.o\ndiff --git a/builtin/rebase--helper.c b/builtin/rebase--helper.c\nindex f7c2a5fdc..05e73e71d 100644\n--- a/builtin/rebase--helper.c\n+++ b/builtin/rebase--helper.c\n@@ -3,6 +3,7 @@\n #include \"config.h\"\n #include \"parse-options.h\"\n #include \"sequencer.h\"\n+#include \"rebase-interactive.h\"\n \n static const char * const builtin_rebase_helper_usage[] = {\n \tN_(\"git rebase--helper [<options>]\"),\n@@ -12,12 +13,12 @@ static const char * const builtin_rebase_helper_usage[] = {\n int cmd_rebase__helper(int argc, const char **argv, const char *prefix)\n {\n \tstruct replay_opts opts = REPLAY_OPTS_INIT;\n-\tunsigned flags = 0, keep_empty = 0, rebase_merges = 0;\n+\tunsigned flags = 0, keep_empty = 0, rebase_merges = 0, write_edit_todo = 0;\n \tint abbreviate_commands = 0, rebase_cousins = -1;\n \tenum {\n \t\tCONTINUE = 1, ABORT, MAKE_SCRIPT, SHORTEN_OIDS, EXPAND_OIDS,\n \t\tCHECK_TODO_LIST, SKIP_UNNECESSARY_PICKS, REARRANGE_SQUASH,\n-\t\tADD_EXEC\n+\t\tADD_EXEC, APPEND_TODO_HELP\n \t} command = 0;\n \tstruct option options[] = {\n \t\tOPT_BOOL(0, \"ff\", &opts.allow_ff, N_(\"allow fast-forward\")),\n@@ -27,6 +28,8 @@ int cmd_rebase__helper(int argc, const char **argv, const char *prefix)\n \t\tOPT_BOOL(0, \"rebase-merges\", &rebase_merges, N_(\"rebase merge commits\")),\n \t\tOPT_BOOL(0, \"rebase-cousins\", &rebase_cousins,\n \t\t\t N_(\"keep original branch points of cousins\")),\n+\t\tOPT_BOOL(0, \"write-edit-todo\", &write_edit_todo,\n+\t\t\t N_(\"append the edit-todo message to the todo-list\")),\n \t\tOPT_CMDMODE(0, \"continue\", &command, N_(\"continue rebase\"),\n \t\t\t\tCONTINUE),\n \t\tOPT_CMDMODE(0, \"abort\", &command, N_(\"abort rebase\"),\n@@ -45,6 +48,8 @@ int cmd_rebase__helper(int argc, const char **argv, const char *prefix)\n \t\t\tN_(\"rearrange fixup/squash lines\"), REARRANGE_SQUASH),\n \t\tOPT_CMDMODE(0, \"add-exec-commands\", &command,\n \t\t\tN_(\"insert exec commands in todo list\"), ADD_EXEC),\n+\t\tOPT_CMDMODE(0, \"append-todo-help\", &command,\n+\t\t\t    N_(\"insert the help in the todo list\"), APPEND_TODO_HELP),\n \t\tOPT_END()\n \t};\n \n@@ -84,5 +89,7 @@ int cmd_rebase__helper(int argc, const char **argv, const char *prefix)\n \t\treturn !!rearrange_squash();\n \tif (command == ADD_EXEC && argc == 2)\n \t\treturn !!sequencer_add_exec_commands(argv[1]);\n+\tif (command == APPEND_TODO_HELP && argc == 1)\n+\t\treturn !!append_todo_help(write_edit_todo, keep_empty);\n \tusage_with_options(builtin_rebase_helper_usage, options);\n }\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 299ded213..94c23a7af 100644\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -39,38 +39,6 @@ comment_for_reflog () {\n \tesac\n }\n \n-append_todo_help () {\n-\tgettext \"\n-Commands:\n-p, pick <commit> = use commit\n-r, reword <commit> = use commit, but edit the commit message\n-e, edit <commit> = use commit, but stop for amending\n-s, squash <commit> = use commit, but meld into previous commit\n-f, fixup <commit> = like \\\"squash\\\", but discard this commit's log message\n-x, exec <command> = run command (the rest of the line) using shell\n-d, drop <commit> = remove commit\n-l, label <label> = label current HEAD with a name\n-t, reset <label> = reset HEAD to a label\n-m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]\n-.       create a merge commit using the original merge commit's\n-.       message (or the oneline, if no original merge commit was\n-.       specified). Use -c <commit> to reword the commit message.\n-\n-These lines can be re-ordered; they are executed from top to bottom.\n-\" | git stripspace --comment-lines >>\"$todo\"\n-\n-\tif test $(get_missing_commit_check_level) = error\n-\tthen\n-\t\tgettext \"\n-Do not remove any line. Use 'drop' explicitly to remove a commit.\n-\" | git stripspace --comment-lines >>\"$todo\"\n-\telse\n-\t\tgettext \"\n-If you remove a line here THAT COMMIT WILL BE LOST.\n-\" | git stripspace --comment-lines >>\"$todo\"\n-\tfi\n-}\n-\n die_abort () {\n \tapply_autostash\n \trm -rf \"$state_dir\"\n@@ -143,13 +111,7 @@ initiate_action () {\n \t\tgit stripspace --strip-comments <\"$todo\" >\"$todo\".new\n \t\tmv -f \"$todo\".new \"$todo\"\n \t\tcollapse_todo_ids\n-\t\tappend_todo_help\n-\t\tgettext \"\n-You are editing the todo file of an ongoing interactive rebase.\n-To continue rebase after editing, run:\n-    git rebase --continue\n-\n-\" | git stripspace --comment-lines >>\"$todo\"\n+\t\tgit rebase--helper --append-todo-help --write-edit-todo\n \n \t\tgit_sequence_editor \"$todo\" ||\n \t\t\tdie \"$(gettext \"Could not execute editor\")\"\n@@ -220,17 +182,7 @@ $comment_char $(eval_ngettext \\\n \t\"Rebase \\$shortrevisions onto \\$shortonto (\\$todocount commands)\" \\\n \t\"$todocount\")\n EOF\n-\tappend_todo_help\n-\tgettext \"\n-\tHowever, if you remove everything, the rebase will be aborted.\n-\n-\t\" | git stripspace --comment-lines >>\"$todo\"\n-\n-\tif test -z \"$keep_empty\"\n-\tthen\n-\t\tprintf '%s\\n' \"$comment_char $(gettext \"Note that empty commits are commented out\")\" >>\"$todo\"\n-\tfi\n-\n+\tgit rebase--helper --append-todo-help ${keep_empty:+--keep-empty}\n \n \thas_action \"$todo\" ||\n \t\treturn 2\ndiff --git a/rebase-interactive.c b/rebase-interactive.c\nnew file mode 100644\nindex 000000000..c79c819b9\n--- /dev/null\n+++ b/rebase-interactive.c\n@@ -0,0 +1,68 @@\n+#include \"cache.h\"\n+#include \"commit.h\"\n+#include \"rebase-interactive.h\"\n+#include \"sequencer.h\"\n+#include \"strbuf.h\"\n+\n+int append_todo_help(unsigned edit_todo, unsigned keep_empty)\n+{\n+\tstruct strbuf buf = STRBUF_INIT;\n+\tFILE *todo;\n+\tint ret;\n+\tconst char *msg = _(\"\\nCommands:\\n\"\n+\"p, pick <commit> = use commit\\n\"\n+\"r, reword <commit> = use commit, but edit the commit message\\n\"\n+\"e, edit <commit> = use commit, but stop for amending\\n\"\n+\"s, squash <commit> = use commit, but meld into previous commit\\n\"\n+\"f, fixup <commit> = like \\\"squash\\\", but discard this commit's log message\\n\"\n+\"x, exec <command> = run command (the rest of the line) using shell\\n\"\n+\"d, drop <commit> = remove commit\\n\"\n+\"l, label <label> = label current HEAD with a name\\n\"\n+\"t, reset <label> = reset HEAD to a label\\n\"\n+\"m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]\\n\"\n+\".       create a merge commit using the original merge commit's\\n\"\n+\".       message (or the oneline, if no original merge commit was\\n\"\n+\".       specified). Use -c <commit> to reword the commit message.\\n\"\n+\"\\n\"\n+\"These lines can be re-ordered; they are executed from top to bottom.\\n\");\n+\n+\ttodo = fopen_or_warn(rebase_path_todo(), \"a\");\n+\tif (!todo)\n+\t\treturn 1;\n+\n+\tstrbuf_add_commented_lines(&buf, msg, strlen(msg));\n+\n+\tif (get_missing_commit_check_level() == CHECK_ERROR)\n+\t\tmsg = _(\"\\nDo not remove any line. Use 'drop' \"\n+\t\t\t \"explicitly to remove a commit.\\n\");\n+\telse\n+\t\tmsg = _(\"\\nIf you remove a line here \"\n+\t\t\t \"THAT COMMIT WILL BE LOST.\\n\");\n+\n+\tstrbuf_add_commented_lines(&buf, msg, strlen(msg));\n+\n+\tif (edit_todo)\n+\t\tmsg = _(\"\\nYou are editing the todo file \"\n+\t\t\t\"of an ongoing interactive rebase.\\n\"\n+\t\t\t\"To continue rebase after editing, run:\\n\"\n+\t\t\t\"    git rebase --continue\\n\\n\");\n+\telse\n+\t\tmsg = _(\"\\nHowever, if you remove everything, \"\n+\t\t\t\"the rebase will be aborted.\\n\\n\");\n+\n+\tstrbuf_add_commented_lines(&buf, msg, strlen(msg));\n+\n+\tif (!keep_empty) {\n+\t\tmsg = _(\"Note that empty commits are commented out\");\n+\t\tstrbuf_add_commented_lines(&buf, msg, strlen(msg));\n+\t}\n+\n+\tret = fputs(buf.buf, todo);\n+\tif (ret < 0)\n+\t\terror_errno(_(\"Could not append help text to '%s'\"), rebase_path_todo());\n+\n+\tfclose(todo);\n+\tstrbuf_release(&buf);\n+\n+\treturn ret;\n+}\ndiff --git a/rebase-interactive.h b/rebase-interactive.h\nnew file mode 100644\nindex 000000000..47372624e\n--- /dev/null\n+++ b/rebase-interactive.h\n@@ -0,0 +1,6 @@\n+#ifndef REBASE_INTERACTIVE_H\n+#define REBASE_INTERACTIVE_H\n+\n+int append_todo_help(unsigned edit_todo, unsigned keep_empty);\n+\n+#endif\n-- \n2.18.0\n\n"},{"id":"351033","messageId":"nycvar.QRO.7.76.6.1806262336310.21419@tvgsbejvaqbjf.bet","threadId":"48613","inReplyTo":"20180626161643.31152-1-alban.gruin@gmail.com","subject":"Re: [GSoC][PATCH v4 0/2] rebase -i: rewrite append_todo_help() in C","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2018-06-26T21:37:06Z","receivedAt":"2018-06-26T21:37:17Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Alban,\n\nOn Tue, 26 Jun 2018, Alban Gruin wrote:\n\n> This patch rewrites append_todo_help() from shell to C. The C version\n> covers a bit more than the old shell version. To achieve that, some\n> parameters were added to rebase--helper.\n> \n> This also introduce a new source file, rebase-interactive.c.\n> \n> This is part of the effort to rewrite interactive rebase in C.\n> \n> This is based on next, as of 2018-06-26.\n\nOut of curiosity: which commits that are not yet in `master` are required?\n\n> Changes since v3:\n> \n>  - Show an error message when append_todo_help() fails to edit the todo\n>    list.\n> \n>  - Introducing rebase-interactive.c to contain functions necessary for\n>    interactive rebase.\n\nThank you very much!\nDscho\n"},{"id":"351035","messageId":"nycvar.QRO.7.76.6.1806262337360.21419@tvgsbejvaqbjf.bet","threadId":"48613","inReplyTo":"20180626161643.31152-2-alban.gruin@gmail.com","subject":"Re: [GSoC][PATCH v4 1/2] sequencer: make two functions and an enum from sequencer.c public","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2018-06-26T21:41:00Z","receivedAt":"2018-06-26T21:41:08Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Alban,\n\nOn Tue, 26 Jun 2018, Alban Gruin wrote:\n\n> diff --git a/sequencer.h b/sequencer.h\n> index c5787c6b5..08397b0d1 100644\n> --- a/sequencer.h\n> +++ b/sequencer.h\n> @@ -3,6 +3,7 @@\n>  \n>  const char *git_path_commit_editmsg(void);\n>  const char *git_path_seq_dir(void);\n> +const char *rebase_path_todo(void);\n>  \n>  #define APPEND_SIGNOFF_DEDUP (1u << 0)\n>  \n> @@ -57,6 +58,10 @@ struct replay_opts {\n>  };\n>  #define REPLAY_OPTS_INIT { .action = -1, .current_fixups = STRBUF_INIT }\n>  \n> +enum check_level {\n> +\tCHECK_IGNORE = 0, CHECK_WARN, CHECK_ERROR\n> +};\n> +\n\nWhile this is contained within scopes that include `sequencer.h`, it *is*\npublic now, so I am slightly uneasy about keeping this enum so generic.\nMaybe we want to use\n\nenum missing_commit_check_level {\n\tMISSING_COMMIT_CHECK_IGNORE = 0,\n\tMISSING_COMMIT_CHECK_WARN,\n\tMISSING_COMMIT_CHECK_ERROR\n};\n\ninstead?\n\nCiao,\nDscho\n"},{"id":"351038","messageId":"nycvar.QRO.7.76.6.1806262343050.21419@tvgsbejvaqbjf.bet","threadId":"48613","inReplyTo":"20180626161643.31152-3-alban.gruin@gmail.com","subject":"Re: [GSoC][PATCH v4 2/2] rebase--interactive: rewrite append_todo_help() in C","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2018-06-26T21:43:24Z","receivedAt":"2018-06-26T21:43:34Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Alban,\n\nOn Tue, 26 Jun 2018, Alban Gruin wrote:\n\n> This rewrites append_todo_help() from shell to C. It also incorporates\n> some parts of initiate_action() and complete_action() that also write\n> help texts to the todo file.\n> \n> This also introduces the source file rebase-interactive.c. This file\n> will contain functions necessary for interactive rebase that are too\n> specific for the sequencer, and is part of libgit.a.\n> \n> Two flags are added to rebase--helper.c: one to call\n> append_todo_help() (`--append-todo-help`), and another one to tell\n> append_todo_help() to write the help text suited for the edit-todo\n> mode (`--write-edit-todo`).\n> \n> Finally, append_todo_help() is removed from git-rebase--interactive.sh\n> to use `rebase--helper --append-todo-help` instead.\n\nLooks good!\n\nThanks,\nDscho\n"},{"id":"351111","messageId":"e2d8310a-0bbc-b786-97c1-e32c2090aca9@gmail.com","threadId":"48613","inReplyTo":"nycvar.QRO.7.76.6.1806262337360.21419@tvgsbejvaqbjf.bet","subject":"Re: [GSoC][PATCH v4 1/2] sequencer: make two functions and an enum from sequencer.c public","fromName":"Alban Gruin","fromEmail":"alban.gruin@gmail.com","sentAt":"2018-06-27T14:54:34Z","receivedAt":"2018-06-27T14:54:50Z","isPatch":true,"sender":{"key":"alban.gruin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6310153?v=4"},"body":"Hi Johannes,\n\nLe 26/06/2018 à 23:41, Johannes Schindelin a écrit :\n> Hi Alban,\n> \n> On Tue, 26 Jun 2018, Alban Gruin wrote:\n> \n>> diff --git a/sequencer.h b/sequencer.h\n>> index c5787c6b5..08397b0d1 100644\n>> --- a/sequencer.h\n>> +++ b/sequencer.h\n>> @@ -3,6 +3,7 @@\n>>  \n>>  const char *git_path_commit_editmsg(void);\n>>  const char *git_path_seq_dir(void);\n>> +const char *rebase_path_todo(void);\n>>  \n>>  #define APPEND_SIGNOFF_DEDUP (1u << 0)\n>>  \n>> @@ -57,6 +58,10 @@ struct replay_opts {\n>>  };\n>>  #define REPLAY_OPTS_INIT { .action = -1, .current_fixups = STRBUF_INIT }\n>>  \n>> +enum check_level {\n>> +\tCHECK_IGNORE = 0, CHECK_WARN, CHECK_ERROR\n>> +};\n>> +\n> \n> While this is contained within scopes that include `sequencer.h`, it *is*\n> public now, so I am slightly uneasy about keeping this enum so generic.\n> Maybe we want to use\n> \n> enum missing_commit_check_level {\n> \tMISSING_COMMIT_CHECK_IGNORE = 0,\n> \tMISSING_COMMIT_CHECK_WARN,\n> \tMISSING_COMMIT_CHECK_ERROR\n> };\n> \n> instead?\n> \n\nYou’re right, this would be better.\n\nCheers,\nAlban\n\n"},{"id":"351112","messageId":"8b5038e7-05c4-9824-c585-963243160897@gmail.com","threadId":"48613","inReplyTo":"nycvar.QRO.7.76.6.1806262336310.21419@tvgsbejvaqbjf.bet","subject":"Re: [GSoC][PATCH v4 0/2] rebase -i: rewrite append_todo_help() in C","fromName":"Alban Gruin","fromEmail":"alban.gruin@gmail.com","sentAt":"2018-06-27T14:54:59Z","receivedAt":"2018-06-27T14:55:04Z","isPatch":true,"sender":{"key":"alban.gruin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6310153?v=4"},"body":"Hi Johannes,\n\nLe 26/06/2018 à 23:37, Johannes Schindelin a écrit :\n> Hi Alban,\n> \n> On Tue, 26 Jun 2018, Alban Gruin wrote:\n> \n>> This patch rewrites append_todo_help() from shell to C. The C version\n>> covers a bit more than the old shell version. To achieve that, some\n>> parameters were added to rebase--helper.\n>>\n>> This also introduce a new source file, rebase-interactive.c.\n>>\n>> This is part of the effort to rewrite interactive rebase in C.\n>>\n>> This is based on next, as of 2018-06-26.\n> \n> Out of curiosity: which commits that are not yet in `master` are required?\n> \n\nNone, actually.\n\nCheers,\nAlban\n\n"},{"id":"351195","messageId":"20180628100411.8092-1-alban.gruin@gmail.com","threadId":"48613","inReplyTo":"20180626161643.31152-1-alban.gruin@gmail.com","subject":"[GSoC][PATCH v5 0/2] rebase -i: rewrite append_todo_help() in C","fromName":"Alban Gruin","fromEmail":"alban.gruin@gmail.com","sentAt":"2018-06-28T10:04:09Z","receivedAt":"2018-06-28T10:04:30Z","isPatch":true,"sender":{"key":"alban.gruin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6310153?v=4"},"body":"This patch rewrites append_todo_help() from shell to C. The C version\ncovers a bit more than the old shell version. To achieve that, some\nparameters were added to rebase--helper.\n\nThis also introduce a new source file, rebase-interactive.c.\n\nThis is part of the effort to rewrite interactive rebase in C.\n\nThis is based on next, as of 2018-06-28.\n\nChanges since v4:\n\n - Renaming enumeration check_level and its values to avoid namespace\n   pollution.\n\nAlban Gruin (2):\n  sequencer: make two functions and an enum from sequencer.c public\n  rebase--interactive: rewrite append_todo_help() in C\n\n Makefile                   |  1 +\n builtin/rebase--helper.c   | 11 ++++--\n git-rebase--interactive.sh | 52 ++---------------------------\n rebase-interactive.c       | 68 ++++++++++++++++++++++++++++++++++++++\n rebase-interactive.h       |  6 ++++\n sequencer.c                | 22 +++++-------\n sequencer.h                |  8 +++++\n 7 files changed, 103 insertions(+), 65 deletions(-)\n create mode 100644 rebase-interactive.c\n create mode 100644 rebase-interactive.h\n\n-- \n2.18.0\n\n"},{"id":"351196","messageId":"20180628100411.8092-2-alban.gruin@gmail.com","threadId":"48613","inReplyTo":"20180628100411.8092-1-alban.gruin@gmail.com","subject":"[GSoC][PATCH v5 1/2] sequencer: make two functions and an enum from sequencer.c public","fromName":"Alban Gruin","fromEmail":"alban.gruin@gmail.com","sentAt":"2018-06-28T10:04:10Z","receivedAt":"2018-06-28T10:04:33Z","isPatch":true,"sender":{"key":"alban.gruin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6310153?v=4"},"body":"This makes rebase_path_todo(), get_missing_commit_check_level() and the\nenum check_level accessible outside sequencer.c.  check_level is renamed\nmissing_commit_check_level, and its value names are prefixed by\nMISSING_COMMIT_ to avoid namespace pollution.\n\nThis will be needed for the rewrite of append_todo_help() from shell to\nC, as it will be in a new library source file, rebase-interactive.c.\n\nSigned-off-by: Alban Gruin <alban.gruin@gmail.com>\n---\n sequencer.c | 22 +++++++++-------------\n sequencer.h |  8 ++++++++\n 2 files changed, 17 insertions(+), 13 deletions(-)\n\ndiff --git a/sequencer.c b/sequencer.c\nindex 0a291c91f..cb7ec9807 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -52,7 +52,7 @@ static GIT_PATH_FUNC(rebase_path, \"rebase-merge\")\n  * the lines are processed, they are removed from the front of this\n  * file and written to the tail of 'done'.\n  */\n-static GIT_PATH_FUNC(rebase_path_todo, \"rebase-merge/git-rebase-todo\")\n+GIT_PATH_FUNC(rebase_path_todo, \"rebase-merge/git-rebase-todo\")\n /*\n  * The rebase command lines that have already been processed. A line\n  * is moved here when it is first handled, before any associated user\n@@ -4223,24 +4223,20 @@ int transform_todos(unsigned flags)\n \treturn i;\n }\n \n-enum check_level {\n-\tCHECK_IGNORE = 0, CHECK_WARN, CHECK_ERROR\n-};\n-\n-static enum check_level get_missing_commit_check_level(void)\n+enum missing_commit_check_level get_missing_commit_check_level(void)\n {\n \tconst char *value;\n \n \tif (git_config_get_value(\"rebase.missingcommitscheck\", &value) ||\n \t\t\t!strcasecmp(\"ignore\", value))\n-\t\treturn CHECK_IGNORE;\n+\t\treturn MISSING_COMMIT_CHECK_IGNORE;\n \tif (!strcasecmp(\"warn\", value))\n-\t\treturn CHECK_WARN;\n+\t\treturn MISSING_COMMIT_CHECK_WARN;\n \tif (!strcasecmp(\"error\", value))\n-\t\treturn CHECK_ERROR;\n+\t\treturn MISSING_COMMIT_CHECK_ERROR;\n \twarning(_(\"unrecognized setting %s for option \"\n \t\t  \"rebase.missingCommitsCheck. Ignoring.\"), value);\n-\treturn CHECK_IGNORE;\n+\treturn MISSING_COMMIT_CHECK_IGNORE;\n }\n \n define_commit_slab(commit_seen, unsigned char);\n@@ -4252,7 +4248,7 @@ define_commit_slab(commit_seen, unsigned char);\n  */\n int check_todo_list(void)\n {\n-\tenum check_level check_level = get_missing_commit_check_level();\n+\tenum missing_commit_check_level check_level = get_missing_commit_check_level();\n \tstruct strbuf todo_file = STRBUF_INIT;\n \tstruct todo_list todo_list = TODO_LIST_INIT;\n \tstruct strbuf missing = STRBUF_INIT;\n@@ -4269,7 +4265,7 @@ int check_todo_list(void)\n \tadvise_to_edit_todo = res =\n \t\tparse_insn_buffer(todo_list.buf.buf, &todo_list);\n \n-\tif (res || check_level == CHECK_IGNORE)\n+\tif (res || check_level == MISSING_COMMIT_CHECK_IGNORE)\n \t\tgoto leave_check;\n \n \t/* Mark the commits in git-rebase-todo as seen */\n@@ -4304,7 +4300,7 @@ int check_todo_list(void)\n \tif (!missing.len)\n \t\tgoto leave_check;\n \n-\tif (check_level == CHECK_ERROR)\n+\tif (check_level == MISSING_COMMIT_CHECK_ERROR)\n \t\tadvise_to_edit_todo = res = 1;\n \n \tfprintf(stderr,\ndiff --git a/sequencer.h b/sequencer.h\nindex c5787c6b5..ffab798f1 100644\n--- a/sequencer.h\n+++ b/sequencer.h\n@@ -3,6 +3,7 @@\n \n const char *git_path_commit_editmsg(void);\n const char *git_path_seq_dir(void);\n+const char *rebase_path_todo(void);\n \n #define APPEND_SIGNOFF_DEDUP (1u << 0)\n \n@@ -57,6 +58,12 @@ struct replay_opts {\n };\n #define REPLAY_OPTS_INIT { .action = -1, .current_fixups = STRBUF_INIT }\n \n+enum missing_commit_check_level {\n+\tMISSING_COMMIT_CHECK_IGNORE = 0,\n+\tMISSING_COMMIT_CHECK_WARN,\n+\tMISSING_COMMIT_CHECK_ERROR\n+};\n+\n /* Call this to setup defaults before parsing command line options */\n void sequencer_init_config(struct replay_opts *opts);\n int sequencer_pick_revisions(struct replay_opts *opts);\n@@ -79,6 +86,7 @@ int sequencer_make_script(FILE *out, int argc, const char **argv,\n \n int sequencer_add_exec_commands(const char *command);\n int transform_todos(unsigned flags);\n+enum missing_commit_check_level get_missing_commit_check_level(void);\n int check_todo_list(void);\n int skip_unnecessary_picks(void);\n int rearrange_squash(void);\n-- \n2.18.0\n\n"},{"id":"351197","messageId":"20180628100411.8092-3-alban.gruin@gmail.com","threadId":"48613","inReplyTo":"20180628100411.8092-1-alban.gruin@gmail.com","subject":"[GSoC][PATCH v5 2/2] rebase--interactive: rewrite append_todo_help() in C","fromName":"Alban Gruin","fromEmail":"alban.gruin@gmail.com","sentAt":"2018-06-28T10:04:11Z","receivedAt":"2018-06-28T10:04:36Z","isPatch":true,"sender":{"key":"alban.gruin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6310153?v=4"},"body":"This rewrites append_todo_help() from shell to C. It also incorporates\nsome parts of initiate_action() and complete_action() that also write\nhelp texts to the todo file.\n\nThis also introduces the source file rebase-interactive.c. This file\nwill contain functions necessary for interactive rebase that are too\nspecific for the sequencer, and is part of libgit.a.\n\nTwo flags are added to rebase--helper.c: one to call\nappend_todo_help() (`--append-todo-help`), and another one to tell\nappend_todo_help() to write the help text suited for the edit-todo\nmode (`--write-edit-todo`).\n\nFinally, append_todo_help() is removed from git-rebase--interactive.sh\nto use `rebase--helper --append-todo-help` instead.\n\nSigned-off-by: Alban Gruin <alban.gruin@gmail.com>\n---\n Makefile                   |  1 +\n builtin/rebase--helper.c   | 11 ++++--\n git-rebase--interactive.sh | 52 ++---------------------------\n rebase-interactive.c       | 68 ++++++++++++++++++++++++++++++++++++++\n rebase-interactive.h       |  6 ++++\n 5 files changed, 86 insertions(+), 52 deletions(-)\n create mode 100644 rebase-interactive.c\n create mode 100644 rebase-interactive.h\n\ndiff --git a/Makefile b/Makefile\nindex 0cb6590f2..a281139ef 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -922,6 +922,7 @@ LIB_OBJS += protocol.o\n LIB_OBJS += quote.o\n LIB_OBJS += reachable.o\n LIB_OBJS += read-cache.o\n+LIB_OBJS += rebase-interactive.o\n LIB_OBJS += reflog-walk.o\n LIB_OBJS += refs.o\n LIB_OBJS += refs/files-backend.o\ndiff --git a/builtin/rebase--helper.c b/builtin/rebase--helper.c\nindex f7c2a5fdc..05e73e71d 100644\n--- a/builtin/rebase--helper.c\n+++ b/builtin/rebase--helper.c\n@@ -3,6 +3,7 @@\n #include \"config.h\"\n #include \"parse-options.h\"\n #include \"sequencer.h\"\n+#include \"rebase-interactive.h\"\n \n static const char * const builtin_rebase_helper_usage[] = {\n \tN_(\"git rebase--helper [<options>]\"),\n@@ -12,12 +13,12 @@ static const char * const builtin_rebase_helper_usage[] = {\n int cmd_rebase__helper(int argc, const char **argv, const char *prefix)\n {\n \tstruct replay_opts opts = REPLAY_OPTS_INIT;\n-\tunsigned flags = 0, keep_empty = 0, rebase_merges = 0;\n+\tunsigned flags = 0, keep_empty = 0, rebase_merges = 0, write_edit_todo = 0;\n \tint abbreviate_commands = 0, rebase_cousins = -1;\n \tenum {\n \t\tCONTINUE = 1, ABORT, MAKE_SCRIPT, SHORTEN_OIDS, EXPAND_OIDS,\n \t\tCHECK_TODO_LIST, SKIP_UNNECESSARY_PICKS, REARRANGE_SQUASH,\n-\t\tADD_EXEC\n+\t\tADD_EXEC, APPEND_TODO_HELP\n \t} command = 0;\n \tstruct option options[] = {\n \t\tOPT_BOOL(0, \"ff\", &opts.allow_ff, N_(\"allow fast-forward\")),\n@@ -27,6 +28,8 @@ int cmd_rebase__helper(int argc, const char **argv, const char *prefix)\n \t\tOPT_BOOL(0, \"rebase-merges\", &rebase_merges, N_(\"rebase merge commits\")),\n \t\tOPT_BOOL(0, \"rebase-cousins\", &rebase_cousins,\n \t\t\t N_(\"keep original branch points of cousins\")),\n+\t\tOPT_BOOL(0, \"write-edit-todo\", &write_edit_todo,\n+\t\t\t N_(\"append the edit-todo message to the todo-list\")),\n \t\tOPT_CMDMODE(0, \"continue\", &command, N_(\"continue rebase\"),\n \t\t\t\tCONTINUE),\n \t\tOPT_CMDMODE(0, \"abort\", &command, N_(\"abort rebase\"),\n@@ -45,6 +48,8 @@ int cmd_rebase__helper(int argc, const char **argv, const char *prefix)\n \t\t\tN_(\"rearrange fixup/squash lines\"), REARRANGE_SQUASH),\n \t\tOPT_CMDMODE(0, \"add-exec-commands\", &command,\n \t\t\tN_(\"insert exec commands in todo list\"), ADD_EXEC),\n+\t\tOPT_CMDMODE(0, \"append-todo-help\", &command,\n+\t\t\t    N_(\"insert the help in the todo list\"), APPEND_TODO_HELP),\n \t\tOPT_END()\n \t};\n \n@@ -84,5 +89,7 @@ int cmd_rebase__helper(int argc, const char **argv, const char *prefix)\n \t\treturn !!rearrange_squash();\n \tif (command == ADD_EXEC && argc == 2)\n \t\treturn !!sequencer_add_exec_commands(argv[1]);\n+\tif (command == APPEND_TODO_HELP && argc == 1)\n+\t\treturn !!append_todo_help(write_edit_todo, keep_empty);\n \tusage_with_options(builtin_rebase_helper_usage, options);\n }\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 299ded213..94c23a7af 100644\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -39,38 +39,6 @@ comment_for_reflog () {\n \tesac\n }\n \n-append_todo_help () {\n-\tgettext \"\n-Commands:\n-p, pick <commit> = use commit\n-r, reword <commit> = use commit, but edit the commit message\n-e, edit <commit> = use commit, but stop for amending\n-s, squash <commit> = use commit, but meld into previous commit\n-f, fixup <commit> = like \\\"squash\\\", but discard this commit's log message\n-x, exec <command> = run command (the rest of the line) using shell\n-d, drop <commit> = remove commit\n-l, label <label> = label current HEAD with a name\n-t, reset <label> = reset HEAD to a label\n-m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]\n-.       create a merge commit using the original merge commit's\n-.       message (or the oneline, if no original merge commit was\n-.       specified). Use -c <commit> to reword the commit message.\n-\n-These lines can be re-ordered; they are executed from top to bottom.\n-\" | git stripspace --comment-lines >>\"$todo\"\n-\n-\tif test $(get_missing_commit_check_level) = error\n-\tthen\n-\t\tgettext \"\n-Do not remove any line. Use 'drop' explicitly to remove a commit.\n-\" | git stripspace --comment-lines >>\"$todo\"\n-\telse\n-\t\tgettext \"\n-If you remove a line here THAT COMMIT WILL BE LOST.\n-\" | git stripspace --comment-lines >>\"$todo\"\n-\tfi\n-}\n-\n die_abort () {\n \tapply_autostash\n \trm -rf \"$state_dir\"\n@@ -143,13 +111,7 @@ initiate_action () {\n \t\tgit stripspace --strip-comments <\"$todo\" >\"$todo\".new\n \t\tmv -f \"$todo\".new \"$todo\"\n \t\tcollapse_todo_ids\n-\t\tappend_todo_help\n-\t\tgettext \"\n-You are editing the todo file of an ongoing interactive rebase.\n-To continue rebase after editing, run:\n-    git rebase --continue\n-\n-\" | git stripspace --comment-lines >>\"$todo\"\n+\t\tgit rebase--helper --append-todo-help --write-edit-todo\n \n \t\tgit_sequence_editor \"$todo\" ||\n \t\t\tdie \"$(gettext \"Could not execute editor\")\"\n@@ -220,17 +182,7 @@ $comment_char $(eval_ngettext \\\n \t\"Rebase \\$shortrevisions onto \\$shortonto (\\$todocount commands)\" \\\n \t\"$todocount\")\n EOF\n-\tappend_todo_help\n-\tgettext \"\n-\tHowever, if you remove everything, the rebase will be aborted.\n-\n-\t\" | git stripspace --comment-lines >>\"$todo\"\n-\n-\tif test -z \"$keep_empty\"\n-\tthen\n-\t\tprintf '%s\\n' \"$comment_char $(gettext \"Note that empty commits are commented out\")\" >>\"$todo\"\n-\tfi\n-\n+\tgit rebase--helper --append-todo-help ${keep_empty:+--keep-empty}\n \n \thas_action \"$todo\" ||\n \t\treturn 2\ndiff --git a/rebase-interactive.c b/rebase-interactive.c\nnew file mode 100644\nindex 000000000..015e08cd0\n--- /dev/null\n+++ b/rebase-interactive.c\n@@ -0,0 +1,68 @@\n+#include \"cache.h\"\n+#include \"commit.h\"\n+#include \"rebase-interactive.h\"\n+#include \"sequencer.h\"\n+#include \"strbuf.h\"\n+\n+int append_todo_help(unsigned edit_todo, unsigned keep_empty)\n+{\n+\tstruct strbuf buf = STRBUF_INIT;\n+\tFILE *todo;\n+\tint ret;\n+\tconst char *msg = _(\"\\nCommands:\\n\"\n+\"p, pick <commit> = use commit\\n\"\n+\"r, reword <commit> = use commit, but edit the commit message\\n\"\n+\"e, edit <commit> = use commit, but stop for amending\\n\"\n+\"s, squash <commit> = use commit, but meld into previous commit\\n\"\n+\"f, fixup <commit> = like \\\"squash\\\", but discard this commit's log message\\n\"\n+\"x, exec <command> = run command (the rest of the line) using shell\\n\"\n+\"d, drop <commit> = remove commit\\n\"\n+\"l, label <label> = label current HEAD with a name\\n\"\n+\"t, reset <label> = reset HEAD to a label\\n\"\n+\"m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]\\n\"\n+\".       create a merge commit using the original merge commit's\\n\"\n+\".       message (or the oneline, if no original merge commit was\\n\"\n+\".       specified). Use -c <commit> to reword the commit message.\\n\"\n+\"\\n\"\n+\"These lines can be re-ordered; they are executed from top to bottom.\\n\");\n+\n+\ttodo = fopen_or_warn(rebase_path_todo(), \"a\");\n+\tif (!todo)\n+\t\treturn 1;\n+\n+\tstrbuf_add_commented_lines(&buf, msg, strlen(msg));\n+\n+\tif (get_missing_commit_check_level() == MISSING_COMMIT_CHECK_ERROR)\n+\t\tmsg = _(\"\\nDo not remove any line. Use 'drop' \"\n+\t\t\t \"explicitly to remove a commit.\\n\");\n+\telse\n+\t\tmsg = _(\"\\nIf you remove a line here \"\n+\t\t\t \"THAT COMMIT WILL BE LOST.\\n\");\n+\n+\tstrbuf_add_commented_lines(&buf, msg, strlen(msg));\n+\n+\tif (edit_todo)\n+\t\tmsg = _(\"\\nYou are editing the todo file \"\n+\t\t\t\"of an ongoing interactive rebase.\\n\"\n+\t\t\t\"To continue rebase after editing, run:\\n\"\n+\t\t\t\"    git rebase --continue\\n\\n\");\n+\telse\n+\t\tmsg = _(\"\\nHowever, if you remove everything, \"\n+\t\t\t\"the rebase will be aborted.\\n\\n\");\n+\n+\tstrbuf_add_commented_lines(&buf, msg, strlen(msg));\n+\n+\tif (!keep_empty) {\n+\t\tmsg = _(\"Note that empty commits are commented out\");\n+\t\tstrbuf_add_commented_lines(&buf, msg, strlen(msg));\n+\t}\n+\n+\tret = fputs(buf.buf, todo);\n+\tif (ret < 0)\n+\t\terror_errno(_(\"Could not append help text to '%s'\"), rebase_path_todo());\n+\n+\tfclose(todo);\n+\tstrbuf_release(&buf);\n+\n+\treturn ret;\n+}\ndiff --git a/rebase-interactive.h b/rebase-interactive.h\nnew file mode 100644\nindex 000000000..47372624e\n--- /dev/null\n+++ b/rebase-interactive.h\n@@ -0,0 +1,6 @@\n+#ifndef REBASE_INTERACTIVE_H\n+#define REBASE_INTERACTIVE_H\n+\n+int append_todo_help(unsigned edit_todo, unsigned keep_empty);\n+\n+#endif\n-- \n2.18.0\n\n"},{"id":"351250","messageId":"xmqq1scqyegi.fsf@gitster-ct.c.googlers.com","threadId":"48613","inReplyTo":"20180628100411.8092-1-alban.gruin@gmail.com","subject":"Re: [GSoC][PATCH v5 0/2] rebase -i: rewrite append_todo_help() in C","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-06-28T18:05:01Z","receivedAt":"2018-06-28T18:05:08Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Alban Gruin <alban.gruin@gmail.com> writes:\n\n> This patch rewrites append_todo_help() from shell to C. The C version\n> covers a bit more than the old shell version. To achieve that, some\n> parameters were added to rebase--helper.\n>\n> This also introduce a new source file, rebase-interactive.c.\n>\n> This is part of the effort to rewrite interactive rebase in C.\n>\n> This is based on next, as of 2018-06-28.\n\nPlease do not base new development on 'next'.  You typically do not\nrequire the whole of 'next'; there is *NO* reason why this topic\nmust wait until say ds/ewah-cleanup topic graduates to 'master', for\nexample.\n\nYou may still depend on just a handful of selected topics that you\nbuild on that are not yet in 'master'.  Identify them and build on\ntop of the merge of them on top of whatever integration branch you\nare aiming for (typically 'master').\n\nAnd list these topics explicitly, instead of saying 'based on next'.\n"}]}