From patchwork Thu Sep 27 21:55:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alban Gruin X-Patchwork-Id: 10618621 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B7E451759 for ; Thu, 27 Sep 2018 22:00:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AAF352B8B6 for ; Thu, 27 Sep 2018 22:00:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9EAB02B8C9; Thu, 27 Sep 2018 22:00:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0E1022B8B6 for ; Thu, 27 Sep 2018 22:00:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727269AbeI1EU4 (ORCPT ); Fri, 28 Sep 2018 00:20:56 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:34710 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726132AbeI1EU4 (ORCPT ); Fri, 28 Sep 2018 00:20:56 -0400 Received: by mail-wr1-f66.google.com with SMTP id z4-v6so2855385wrb.1 for ; Thu, 27 Sep 2018 15:00:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ngUDtohThwk0HJVrv/FyDBSPP/VInNQ/cfxq9bqg/Js=; b=JOfRxt58jjtwrxeqQv8n5FQNuHg7nuhrtoeg+N1EqopCpjmQ6hlc8bOnPu/sQ7WwA2 OUg+iUN2bmzi+Dq5WIk0QjwM/hn5WIoGCt6sEmHfpYvi773wrT1PjgCITos14RM0lE1m IkiygtuovAyLfrbWqx68LHhrai6AL916kGHX0Wsh0SHNAXL/PUcM5XhOAmSiXSt/EGuV rUQHYSmyt4jq+T5ywxy3fLMrkk8RsUyb2v8yo2bJTB2ckY35FPSzT1bDh5oTpv/v/HGB zfUZdfA2GoC8Goq+iJhdvuubou8AAtogZGgXqTwfkywb4HIZz670bJ45v96R8jRCgzHm EHXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ngUDtohThwk0HJVrv/FyDBSPP/VInNQ/cfxq9bqg/Js=; b=VMn1Zob86oaEbBBtYlQelRLxduILgANszvgQoSrn1lNDQUEL9zRGj3W0jfrsNNOB87 UzJ9Vv4y5H7ggARHVFj1BD/VhJHxbjkE0Vq6n4YofNfp9lDojcLuqhbBQ3FBoWdIoi1X XybfyrMpf5ChzmN3pDMYhTkkDdJyyYQBlY1Ge49kjWPPQr87mMGNxmjvmxUMAu8lnsR3 MeVB/uhK64YQlT+yMv2pqagAXyZVZOetKirGbjVsVyfy7cimxM1eKMe/ZG/WY0ADujzl VSVvQ/q849P0D+sMZYMAelR+iu4MPqPmo67hoXxWL52yAPIowNrjcqvEQ5btcTSGhRfL VC/Q== X-Gm-Message-State: ABuFfoh8/cEzAgIfGbJAKNT3go4kW1Wii9122ZVU0x66aHZ76Hsy3ZSB Jx7iXhb/vIgikIms+WjrbagThArw X-Google-Smtp-Source: ACcGV63A4/J5BA6pnVLeMO0zSS06hayufhlF2owNDTLvVFgBpup33P1ivQrTNKjsrfX7XILN+SfFGg== X-Received: by 2002:adf:ac13:: with SMTP id v19-v6mr10191605wrc.135.1538085628887; Thu, 27 Sep 2018 15:00:28 -0700 (PDT) Received: from localhost.localdomain (AToulouse-658-1-28-140.w86-222.abo.wanadoo.fr. [86.222.27.140]) by smtp.googlemail.com with ESMTPSA id h206-v6sm243153wmf.25.2018.09.27.15.00.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Sep 2018 15:00:28 -0700 (PDT) From: Alban Gruin To: git@vger.kernel.org Cc: Stefan Beller , Christian Couder , Pratik Karki , Johannes Schindelin , phillip.wood@dunelm.org.uk, gitster@pobox.com, Alban Gruin Subject: [GSoC][PATCH v8 01/20] sequencer: make three functions and an enum from sequencer.c public Date: Thu, 27 Sep 2018 23:55:51 +0200 Message-Id: <20180927215610.32210-2-alban.gruin@gmail.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180927215610.32210-1-alban.gruin@gmail.com> References: <20180828121045.14933-1-alban.gruin@gmail.com> <20180927215610.32210-1-alban.gruin@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This makes rebase_path_todo(), get_missing_commit_check_level(), write_message() and the enum check_level accessible outside sequencer.c, renames check_level to missing_commit_check_level, and prefixes its value names by MISSING_COMMIT_ to avoid namespace pollution. This function and this enum will eventually be moved to rebase-interactive.c and become static again, so no special attention was given to the naming. This will be needed for the rewrite of append_todo_help() from shell to C, as it will be in a new library source file, rebase-interactive.c. Signed-off-by: Alban Gruin --- No changes since v7. sequencer.c | 26 +++++++++++--------------- sequencer.h | 11 +++++++++++ 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/sequencer.c b/sequencer.c index ddb41a62d9..c24d37dfb1 100644 --- a/sequencer.c +++ b/sequencer.c @@ -53,7 +53,7 @@ static GIT_PATH_FUNC(rebase_path, "rebase-merge") * the lines are processed, they are removed from the front of this * file and written to the tail of 'done'. */ -static GIT_PATH_FUNC(rebase_path_todo, "rebase-merge/git-rebase-todo") +GIT_PATH_FUNC(rebase_path_todo, "rebase-merge/git-rebase-todo") /* * The rebase command lines that have already been processed. A line * is moved here when it is first handled, before any associated user @@ -377,8 +377,8 @@ static void print_advice(int show_hint, struct replay_opts *opts) } } -static int write_message(const void *buf, size_t len, const char *filename, - int append_eol) +int write_message(const void *buf, size_t len, const char *filename, + int append_eol) { struct lock_file msg_file = LOCK_INIT; @@ -4422,24 +4422,20 @@ int transform_todos(unsigned flags) return i; } -enum check_level { - CHECK_IGNORE = 0, CHECK_WARN, CHECK_ERROR -}; - -static enum check_level get_missing_commit_check_level(void) +enum missing_commit_check_level get_missing_commit_check_level(void) { const char *value; if (git_config_get_value("rebase.missingcommitscheck", &value) || !strcasecmp("ignore", value)) - return CHECK_IGNORE; + return MISSING_COMMIT_CHECK_IGNORE; if (!strcasecmp("warn", value)) - return CHECK_WARN; + return MISSING_COMMIT_CHECK_WARN; if (!strcasecmp("error", value)) - return CHECK_ERROR; + return MISSING_COMMIT_CHECK_ERROR; warning(_("unrecognized setting %s for option " "rebase.missingCommitsCheck. Ignoring."), value); - return CHECK_IGNORE; + return MISSING_COMMIT_CHECK_IGNORE; } define_commit_slab(commit_seen, unsigned char); @@ -4451,7 +4447,7 @@ define_commit_slab(commit_seen, unsigned char); */ int check_todo_list(void) { - enum check_level check_level = get_missing_commit_check_level(); + enum missing_commit_check_level check_level = get_missing_commit_check_level(); struct strbuf todo_file = STRBUF_INIT; struct todo_list todo_list = TODO_LIST_INIT; struct strbuf missing = STRBUF_INIT; @@ -4468,7 +4464,7 @@ int check_todo_list(void) advise_to_edit_todo = res = parse_insn_buffer(todo_list.buf.buf, &todo_list); - if (res || check_level == CHECK_IGNORE) + if (res || check_level == MISSING_COMMIT_CHECK_IGNORE) goto leave_check; /* Mark the commits in git-rebase-todo as seen */ @@ -4503,7 +4499,7 @@ int check_todo_list(void) if (!missing.len) goto leave_check; - if (check_level == CHECK_ERROR) + if (check_level == MISSING_COMMIT_CHECK_ERROR) advise_to_edit_todo = res = 1; fprintf(stderr, diff --git a/sequencer.h b/sequencer.h index c986bc8251..579de9127b 100644 --- a/sequencer.h +++ b/sequencer.h @@ -8,6 +8,7 @@ struct commit; const char *git_path_commit_editmsg(void); const char *git_path_seq_dir(void); +const char *rebase_path_todo(void); #define APPEND_SIGNOFF_DEDUP (1u << 0) @@ -62,6 +63,15 @@ struct replay_opts { }; #define REPLAY_OPTS_INIT { .action = -1, .current_fixups = STRBUF_INIT } +enum missing_commit_check_level { + MISSING_COMMIT_CHECK_IGNORE = 0, + MISSING_COMMIT_CHECK_WARN, + MISSING_COMMIT_CHECK_ERROR +}; + +int write_message(const void *buf, size_t len, const char *filename, + int append_eol); + /* Call this to setup defaults before parsing command line options */ void sequencer_init_config(struct replay_opts *opts); int sequencer_pick_revisions(struct replay_opts *opts); @@ -84,6 +94,7 @@ int sequencer_make_script(FILE *out, int argc, const char **argv, int sequencer_add_exec_commands(const char *command); int transform_todos(unsigned flags); +enum missing_commit_check_level get_missing_commit_check_level(void); int check_todo_list(void); int skip_unnecessary_picks(void); int rearrange_squash(void); From patchwork Thu Sep 27 21:55:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alban Gruin X-Patchwork-Id: 10618623 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4ED35175A for ; Thu, 27 Sep 2018 22:00:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 40CD32B8B6 for ; Thu, 27 Sep 2018 22:00:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 347DA2B8C2; Thu, 27 Sep 2018 22:00:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 61F912B8B8 for ; Thu, 27 Sep 2018 22:00:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727358AbeI1EU5 (ORCPT ); Fri, 28 Sep 2018 00:20:57 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:51038 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727068AbeI1EU4 (ORCPT ); Fri, 28 Sep 2018 00:20:56 -0400 Received: by mail-wm1-f68.google.com with SMTP id s12-v6so320900wmc.0 for ; Thu, 27 Sep 2018 15:00:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aWt5e6qT4kmhvE+Xbam/ld2s2AoX8QzcdNdxuocVwr0=; b=IZhFFXxnbc02jhqE0lfhQJbTCjKeQ8Nv9ztvM7o7DD0jlUNgwJAG7TGW94oL8xqWzq HzBPH8S+P2pQeSkQF/ReYTO8x2KNmKg1SykoElhaKETdThTIjA4Z5OXwIbDc9smceL8C lJb3cM3CZfKler+FS5hO5EEMSF7pXsgyvjbsoMJ0dA4gTBw6EE4p1XKvRYsyBBAH/tOn n7wA1i3i/QVd61P1Jbz6/NouBeH71EgWYWZch4M61XHQo5CCaZ+Xj91Iak4zj45gXTQ/ gd4LCju+XLXLJsd2a1OPpNoYc5JlqqhYmF+G4iywp7X9lDpNp+b1QY5LVlKOi+d4iYZN jYug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aWt5e6qT4kmhvE+Xbam/ld2s2AoX8QzcdNdxuocVwr0=; b=ayAEvHosgEVkxnT76ADICn6MPDUi7nJuw6OJbR6Ut35HI//y3SWWLkcWbQ5axoA1V1 fVj7bh4HHjoX3LmTaMC4+KgnDPjZ7gmxsYFpj3W91SadiLNCkeTuBPVSqQINQJmPKmfj TeN4fIIKjnfgiDwbdfy3mNOVrQ+LWhs62myK3szYGtJS/xNOYfxX0La9nO1Kq+8HYoZs 6bahoq2VcBxJTiwwhK3/0aOlcs5+QNpsA+pRicMS1EHp69XRHcVLtO24hcN2zHg3kr47 ZYYGlX+riZ5qefbEmv5uzFtWhmKoL54GE41VPn+hmh0vHC0knOrTeduCOfY7ho+rweU3 ZnCg== X-Gm-Message-State: ABuFfojvrRJx3tDF/lUCpHo2Qczr/pB0j0P1gjcbGcoFjTV+DKrI5eaK AMHsADMaZv7a7EdXADv87tvbm0l7 X-Google-Smtp-Source: ACcGV63Urv8Y7XH2omIc/yNABHZWj9WmFRBObmJEg4yFH8rj0n98qonec+73SOezhOmyIKDsn0n9tw== X-Received: by 2002:a1c:6c0a:: with SMTP id h10-v6mr336788wmc.47.1538085630105; Thu, 27 Sep 2018 15:00:30 -0700 (PDT) Received: from localhost.localdomain (AToulouse-658-1-28-140.w86-222.abo.wanadoo.fr. [86.222.27.140]) by smtp.googlemail.com with ESMTPSA id h206-v6sm243153wmf.25.2018.09.27.15.00.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Sep 2018 15:00:29 -0700 (PDT) From: Alban Gruin To: git@vger.kernel.org Cc: Stefan Beller , Christian Couder , Pratik Karki , Johannes Schindelin , phillip.wood@dunelm.org.uk, gitster@pobox.com, Alban Gruin Subject: [GSoC][PATCH v8 02/20] rebase -i: rewrite append_todo_help() in C Date: Thu, 27 Sep 2018 23:55:52 +0200 Message-Id: <20180927215610.32210-3-alban.gruin@gmail.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180927215610.32210-1-alban.gruin@gmail.com> References: <20180828121045.14933-1-alban.gruin@gmail.com> <20180927215610.32210-1-alban.gruin@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This rewrites append_todo_help() from shell to C. It also incorporates some parts of initiate_action() and complete_action() that also write help texts to the todo file. This also introduces the source file rebase-interactive.c. This file will contain functions necessary for interactive rebase that are too specific for the sequencer, and is part of libgit.a. Two flags are added to rebase--helper.c: one to call append_todo_help() (`--append-todo-help`), and another one to tell append_todo_help() to write the help text suited for the edit-todo mode (`--write-edit-todo`). Finally, append_todo_help() is removed from git-rebase--interactive.sh to use `rebase--helper --append-todo-help` instead. Signed-off-by: Alban Gruin --- The changes are due to the rebase, no real changes otherwise. Makefile | 1 + builtin/rebase--helper.c | 11 ++++-- git-rebase--interactive.sh | 52 ++--------------------------- rebase-interactive.c | 68 ++++++++++++++++++++++++++++++++++++++ rebase-interactive.h | 6 ++++ 5 files changed, 86 insertions(+), 52 deletions(-) create mode 100644 rebase-interactive.c create mode 100644 rebase-interactive.h diff --git a/Makefile b/Makefile index 13e1c52478..ff7f01634f 100644 --- a/Makefile +++ b/Makefile @@ -942,6 +942,7 @@ LIB_OBJS += quote.o LIB_OBJS += range-diff.o LIB_OBJS += reachable.o LIB_OBJS += read-cache.o +LIB_OBJS += rebase-interactive.o LIB_OBJS += reflog-walk.o LIB_OBJS += refs.o LIB_OBJS += refs/files-backend.o diff --git a/builtin/rebase--helper.c b/builtin/rebase--helper.c index f7c2a5fdc8..05e73e71d4 100644 --- a/builtin/rebase--helper.c +++ b/builtin/rebase--helper.c @@ -3,6 +3,7 @@ #include "config.h" #include "parse-options.h" #include "sequencer.h" +#include "rebase-interactive.h" static const char * const builtin_rebase_helper_usage[] = { N_("git rebase--helper []"), @@ -12,12 +13,12 @@ static const char * const builtin_rebase_helper_usage[] = { int cmd_rebase__helper(int argc, const char **argv, const char *prefix) { struct replay_opts opts = REPLAY_OPTS_INIT; - unsigned flags = 0, keep_empty = 0, rebase_merges = 0; + unsigned flags = 0, keep_empty = 0, rebase_merges = 0, write_edit_todo = 0; int abbreviate_commands = 0, rebase_cousins = -1; enum { CONTINUE = 1, ABORT, MAKE_SCRIPT, SHORTEN_OIDS, EXPAND_OIDS, CHECK_TODO_LIST, SKIP_UNNECESSARY_PICKS, REARRANGE_SQUASH, - ADD_EXEC + ADD_EXEC, APPEND_TODO_HELP } command = 0; struct option options[] = { OPT_BOOL(0, "ff", &opts.allow_ff, N_("allow fast-forward")), @@ -27,6 +28,8 @@ int cmd_rebase__helper(int argc, const char **argv, const char *prefix) OPT_BOOL(0, "rebase-merges", &rebase_merges, N_("rebase merge commits")), OPT_BOOL(0, "rebase-cousins", &rebase_cousins, N_("keep original branch points of cousins")), + OPT_BOOL(0, "write-edit-todo", &write_edit_todo, + N_("append the edit-todo message to the todo-list")), OPT_CMDMODE(0, "continue", &command, N_("continue rebase"), CONTINUE), OPT_CMDMODE(0, "abort", &command, N_("abort rebase"), @@ -45,6 +48,8 @@ int cmd_rebase__helper(int argc, const char **argv, const char *prefix) N_("rearrange fixup/squash lines"), REARRANGE_SQUASH), OPT_CMDMODE(0, "add-exec-commands", &command, N_("insert exec commands in todo list"), ADD_EXEC), + OPT_CMDMODE(0, "append-todo-help", &command, + N_("insert the help in the todo list"), APPEND_TODO_HELP), OPT_END() }; @@ -84,5 +89,7 @@ int cmd_rebase__helper(int argc, const char **argv, const char *prefix) return !!rearrange_squash(); if (command == ADD_EXEC && argc == 2) return !!sequencer_add_exec_commands(argv[1]); + if (command == APPEND_TODO_HELP && argc == 1) + return !!append_todo_help(write_edit_todo, keep_empty); usage_with_options(builtin_rebase_helper_usage, options); } diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh index 299ded2137..94c23a7af2 100644 --- a/git-rebase--interactive.sh +++ b/git-rebase--interactive.sh @@ -39,38 +39,6 @@ comment_for_reflog () { esac } -append_todo_help () { - gettext " -Commands: -p, pick = use commit -r, reword = use commit, but edit the commit message -e, edit = use commit, but stop for amending -s, squash = use commit, but meld into previous commit -f, fixup = like \"squash\", but discard this commit's log message -x, exec = run command (the rest of the line) using shell -d, drop = remove commit -l, label