From patchwork Sat Nov 23 14:37:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alban Gruin X-Patchwork-Id: 11258813 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5AF1A112B for ; Sat, 23 Nov 2019 14:45:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3A52C20706 for ; Sat, 23 Nov 2019 14:45:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BQ36Arvg" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726775AbfKWOpy (ORCPT ); Sat, 23 Nov 2019 09:45:54 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:36100 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726638AbfKWOpy (ORCPT ); Sat, 23 Nov 2019 09:45:54 -0500 Received: by mail-wm1-f68.google.com with SMTP id n188so8994523wme.1 for ; Sat, 23 Nov 2019 06:45:51 -0800 (PST) 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=x6T8n9ofQ5yvpBR4OTB57nmZonnh7MyJGYi+C89M7Zs=; b=BQ36ArvgCPW0tHw2AqNzZaRX+KFj4Yz/e9v/DFRgHlmfR717mLWNr9gbYzE0nq+3kr E2sKeUrGraM38d1uUzPYYNaOBgPwhfDzMQxMhIwtiCmVc0SSMs0n1ekCTfm+6KQKNNdC 8bdcHTypZlvETx90quvgTofKOeeNhh2HC8IyYs8/u4UXFW08yglnYytXR5CD2GfUXPXC gpYGoVf/1UOV0NRxMlKPcXGNuW5A41G4NnxSkPSr0eLay7s6379En93c5wvBmgcjE7Tf WXSibkGzGJYd4q7g/KYHsF3Pm/UIWQTopCKSyPIHI5DMVWXRbJbg9Xi6qRxv0311rV7e gRwA== 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=x6T8n9ofQ5yvpBR4OTB57nmZonnh7MyJGYi+C89M7Zs=; b=P5GmVpcawaoKK9/fupdUCRDD59Sh1vDuMMZ7He8755qhCfv19cCQNea33lY/2hYrMC z0YUW2cfzC0Fv0s6MqdGcsJbZm6nsqa6KGZh5NFrA1ViAX8K2FHnt7wuCC7PTFrwf34L syUumuQ+OaUUbiZC3hhMS5Pn46AmxE81SUrYrQowuaCnuJtxxM4jb2l8G+chbAtLnwnf FsEoMsLiJKBG5aUjObnIPgKrZmcstQr7N+g1QMr4VJIdsI0YNIMPbe3d3RBCW+zHZjoU zej6OiAaXow8HWxdvG+Mjs3Bwfe5qmaoTq35XruGKxMhzt0dYl0W7jqBOQiUYM4RylYR 05UA== X-Gm-Message-State: APjAAAUQ411io1NjPzZCbZpdmIn0X5xVzLJGKHAhvXTsAV6cPuEWUNa2 Yn/iRpZGSMmQboS++gqODVUj57ua X-Google-Smtp-Source: APXvYqytFmJUQOm8MK8eg7pqx+vJ1KvISDemqG8k0h6fv5wQJWIdoJuM9oqlkugA2/lgQtdDb76ing== X-Received: by 2002:a7b:c308:: with SMTP id k8mr20547783wmj.32.1574520039766; Sat, 23 Nov 2019 06:40:39 -0800 (PST) Received: from localhost.localdomain (atoulouse-658-1-110-106.w86-199.abo.wanadoo.fr. [86.199.33.106]) by smtp.googlemail.com with ESMTPSA id b10sm2399298wrw.53.2019.11.23.06.40.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 23 Nov 2019 06:40:39 -0800 (PST) From: Alban Gruin To: git@vger.kernel.org Cc: Johannes Schindelin , Phillip Wood , Junio C Hamano , Jonathan Tan , Alban Gruin Subject: [PATCH v3 1/5] sequencer: update `total_nr' when adding an item to a todo list Date: Sat, 23 Nov 2019 15:37:01 +0100 Message-Id: <20191123143705.17280-2-alban.gruin@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191123143705.17280-1-alban.gruin@gmail.com> References: <20191007092641.12661-1-alban.gruin@gmail.com> <20191123143705.17280-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 `total_nr' is the total number of items, counting both done and todo, that are in a todo list. But unlike `nr', it was not updated when an item was appended to the list. This variable is mostly used by command prompts (ie. git-prompt.sh and the like). By forgetting to update it, the original code made it not reflect the reality, but this flaw was masked by the code calling unnecessarily read_populate_todo() again to update the variable to its correct value. At the end of this series, the unnecessary call will be removed, and the inconsistency addressed by this patch would start to matter. Signed-off-by: Alban Gruin --- sequencer.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sequencer.c b/sequencer.c index d648aaf416..575b852a5a 100644 --- a/sequencer.c +++ b/sequencer.c @@ -2070,6 +2070,7 @@ void todo_list_release(struct todo_list *todo_list) static struct todo_item *append_new_todo(struct todo_list *todo_list) { ALLOC_GROW(todo_list->items, todo_list->nr + 1, todo_list->alloc); + todo_list->total_nr++; return todo_list->items + todo_list->nr++; } From patchwork Sat Nov 23 14:37:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alban Gruin X-Patchwork-Id: 11258823 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 10E75930 for ; Sat, 23 Nov 2019 14:49:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E2ABE20706 for ; Sat, 23 Nov 2019 14:49:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="qa1LXCo5" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726740AbfKWOtA (ORCPT ); Sat, 23 Nov 2019 09:49:00 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:43847 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726704AbfKWOtA (ORCPT ); Sat, 23 Nov 2019 09:49:00 -0500 Received: by mail-lf1-f67.google.com with SMTP id l14so7687163lfh.10 for ; Sat, 23 Nov 2019 06:48:58 -0800 (PST) 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=p3OtT2rirIH7XHYdJ8mtcDtYT9Y4YgaC5OpznLG+v7g=; b=qa1LXCo5xF70E1r0xTjx4WJPsF3SZUoF+Ae8mV+pXpoB56zbdO10klvdwVYSTN93wb CMRopbxSvcsX+rG/k/VF6a8OVFlxufMhL+zjRTzeEjzOdq/lf0h62IzvpBFFZkdHC/Hx 8CFnnTht7OSEp/5WCo2mSZbzMnJeY+CX11qGA7jFlKbsvHMond2NVjqNrUmANvAMZh1U fv2KF3ubpHiYDnHdqqv9GM16h/4UzMeChPXnIodCIF0xdMPPioPIgwAJ6FFpgiNUziar mpIm8T+AT2ye2s7iOfmy9eWFRxEgyegx3Cj+/OSXRoXk2ZvRziCVdZ7fwyItQsQfgTmS pcVA== 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=p3OtT2rirIH7XHYdJ8mtcDtYT9Y4YgaC5OpznLG+v7g=; b=RZPnHP4k9eVgBhU0oOMDtTLQ429sVlKjGV6Ebo7qvN8EWQ5mswoWd9eK2nJzhfVxIP UfR0FfpPqWmCXnmnfIO0IQ/IKJjYKqoNlvg5dMgRyjnOV9f9SbVhNVO67+st3K7RIXuA SgH3xqlJ0JqGG+qnnX6/Kh/TkjlIEHdyHhE1jSH2AR7kZv1aZrjekbjiAyN+QWM3auJi +ESbjgjWdXtXs22kgsaOeJNwKI1MWxQIK0g4t5WmiEu5Fq8q33vzZw6bw4JdxutIpYUK 5sDSsQ3FTk7buV/e8loUcjWsAhlQPQ7BhKYtqZFzYa+7fiey686ndj0OG6YnEf+E97Ww Nr1Q== X-Gm-Message-State: APjAAAUwRxV5AeS814NIaSCL07ldC5zjVmIMIega3zd2A17D2YTKh6/T vUJnG6PLLD6y3rjs/BypAiIxXpt+ X-Google-Smtp-Source: APXvYqw6RpPTw0FvBsa4aUTgwkMHPHMWZTQiiz95ta+bklq1FS7GdVQan37/1WcyTmYxwBV/My1OaQ== X-Received: by 2002:adf:ff90:: with SMTP id j16mr5031425wrr.361.1574520040883; Sat, 23 Nov 2019 06:40:40 -0800 (PST) Received: from localhost.localdomain (atoulouse-658-1-110-106.w86-199.abo.wanadoo.fr. [86.199.33.106]) by smtp.googlemail.com with ESMTPSA id b10sm2399298wrw.53.2019.11.23.06.40.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 23 Nov 2019 06:40:40 -0800 (PST) From: Alban Gruin To: git@vger.kernel.org Cc: Johannes Schindelin , Phillip Wood , Junio C Hamano , Jonathan Tan , Alban Gruin Subject: [PATCH v3 2/5] sequencer: update `done_nr' when skipping commands in a todo list Date: Sat, 23 Nov 2019 15:37:02 +0100 Message-Id: <20191123143705.17280-3-alban.gruin@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191123143705.17280-1-alban.gruin@gmail.com> References: <20191007092641.12661-1-alban.gruin@gmail.com> <20191123143705.17280-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 In a todo list, `done_nr' is the amount of commands that were executed or skipped, but skip_unnecessary_picks() did not update it. This variable is mostly used by command prompts (ie. git-prompt.sh and the like). As in the previous commit, this inconsistent behaviour is not a problem yet, but it would start to matter at the end of this series the same reason. Signed-off-by: Alban Gruin --- sequencer.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sequencer.c b/sequencer.c index 575b852a5a..42313f8de6 100644 --- a/sequencer.c +++ b/sequencer.c @@ -5054,6 +5054,7 @@ static int skip_unnecessary_picks(struct repository *r, MOVE_ARRAY(todo_list->items, todo_list->items + i, todo_list->nr - i); todo_list->nr -= i; todo_list->current = 0; + todo_list->done_nr += i; if (is_fixup(peek_command(todo_list, 0))) record_in_rewritten(base_oid, peek_command(todo_list, 0)); From patchwork Sat Nov 23 14:37:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alban Gruin X-Patchwork-Id: 11258821 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E4FA6112B for ; Sat, 23 Nov 2019 14:47:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C4A8B2071B for ; Sat, 23 Nov 2019 14:47:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fbfsfgJ0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726855AbfKWOrg (ORCPT ); Sat, 23 Nov 2019 09:47:36 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:35612 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726704AbfKWOrf (ORCPT ); Sat, 23 Nov 2019 09:47:35 -0500 Received: by mail-wm1-f66.google.com with SMTP id n5so797446wmc.0 for ; Sat, 23 Nov 2019 06:47:33 -0800 (PST) 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=raobcgxZIeCMIufQzXkhKjVYw9ZZcAw8TdKexUZshJE=; b=fbfsfgJ0XWeDlXiBp735/ettcBvWqMN4l3KLHQd80gYkc8JiKIzbnivxQwW7tC0xlz a2ghT3fAWWWDBmZskH1E4Vtzf91kzK85j/5T0iQfydf8PTlGEc3wxgSZ992bJR8hoHi3 1yn1HDkAp+D1mJ+g1TT1Rdow4SarUZ8tud3ILicDbWaoPuwgdwCzoQ70L82ocyQuPTug EUR8jwAMLWcI46IRj1gtBWtIAkctHkVr0NW5M/iGgzGY/ljf9AeWQmasEgPxWvhV9Ge9 lwUeXxVHwKTeSsG5aIOAJtt2AD+U5HvVeQ9DfQScOXeO6dyz9iu6oF2iSO7qPDZokpwg qnpg== 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=raobcgxZIeCMIufQzXkhKjVYw9ZZcAw8TdKexUZshJE=; b=QLVf29ZJKyWdb9zrrvU86NuHGAIFwIxFWmQCdbilVEQ4oUKM5ag9ks1xwWerZNyOso Q5OUBbMOyqRTsPU1/gSiCu3dyebojPpMbiJMrXwTBQk3BTok15KQohIi+ChtJeJXnRFD U4aJRjuFn4p5NsBd1eWG2tdfSv5PhhxDRC8Xg4bV2/O/5Cbavrf+Hj3BQnl9s2HTDusZ c0k8CTPAFdJXbHUXagfz/XUlHqXj1grbmkMwSpJ7sHZkDfwbTk6osAHTXjh5CtlHAR8q hOFT3Tn36e9rZrrK3kxDqxlSMRr4H1rHI6szkV4r68CL/LBwpnFJ2BLQZVpiNOBairsz lNTQ== X-Gm-Message-State: APjAAAX9SXYbVZQEAki98x/G9y693gew08qcznRAeIZoU9mWGWuhICC+ FQCrbm5W+Xkd7Gr90ZI0JdPD8v+U X-Google-Smtp-Source: APXvYqwhzml+BCUw1qRs6HEKqDJOeIy2/K9C46XLULsXhfa/tiUX+CLtK6mY5Fq8avEJsE1cdPdwDA== X-Received: by 2002:a05:600c:22c3:: with SMTP id 3mr20888311wmg.139.1574520041893; Sat, 23 Nov 2019 06:40:41 -0800 (PST) Received: from localhost.localdomain (atoulouse-658-1-110-106.w86-199.abo.wanadoo.fr. [86.199.33.106]) by smtp.googlemail.com with ESMTPSA id b10sm2399298wrw.53.2019.11.23.06.40.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 23 Nov 2019 06:40:41 -0800 (PST) From: Alban Gruin To: git@vger.kernel.org Cc: Johannes Schindelin , Phillip Wood , Junio C Hamano , Jonathan Tan , Alban Gruin Subject: [PATCH v3 3/5] sequencer: move the code writing total_nr on the disk to a new function Date: Sat, 23 Nov 2019 15:37:03 +0100 Message-Id: <20191123143705.17280-4-alban.gruin@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191123143705.17280-1-alban.gruin@gmail.com> References: <20191007092641.12661-1-alban.gruin@gmail.com> <20191123143705.17280-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 The total amount of commands can be used to show the progression of the rebasing in a shell. It is written to the disk by read_populate_todo() when the todo list is loaded from sequencer_continue() or pick_commits(), but not by complete_action(). This moves the part writing total_nr to a new function so it can be called from complete_action(). Signed-off-by: Alban Gruin --- sequencer.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/sequencer.c b/sequencer.c index 42313f8de6..ec7ea8d9e5 100644 --- a/sequencer.c +++ b/sequencer.c @@ -2342,6 +2342,16 @@ void sequencer_post_commit_cleanup(struct repository *r, int verbose) sequencer_remove_state(&opts); } +static void todo_list_write_total_nr(struct todo_list *todo_list) +{ + FILE *f = fopen_or_warn(rebase_path_msgtotal(), "w"); + + if (f) { + fprintf(f, "%d\n", todo_list->total_nr); + fclose(f); + } +} + static int read_populate_todo(struct repository *r, struct todo_list *todo_list, struct replay_opts *opts) @@ -2387,7 +2397,6 @@ static int read_populate_todo(struct repository *r, if (is_rebase_i(opts)) { struct todo_list done = TODO_LIST_INIT; - FILE *f = fopen_or_warn(rebase_path_msgtotal(), "w"); if (strbuf_read_file(&done.buf, rebase_path_done(), 0) > 0 && !todo_list_parse_insn_buffer(r, done.buf.buf, &done)) @@ -2399,10 +2408,7 @@ static int read_populate_todo(struct repository *r, + count_commands(todo_list); todo_list_release(&done); - if (f) { - fprintf(f, "%d\n", todo_list->total_nr); - fclose(f); - } + todo_list_write_total_nr(todo_list); } return 0; From patchwork Sat Nov 23 14:37:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alban Gruin X-Patchwork-Id: 11258815 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0D60A112B for ; Sat, 23 Nov 2019 14:46:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DF88920719 for ; Sat, 23 Nov 2019 14:46:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dqWmP3CW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726803AbfKWOqd (ORCPT ); Sat, 23 Nov 2019 09:46:33 -0500 Received: from mail-ed1-f67.google.com ([209.85.208.67]:42630 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726638AbfKWOqd (ORCPT ); Sat, 23 Nov 2019 09:46:33 -0500 Received: by mail-ed1-f67.google.com with SMTP id m13so8507244edv.9 for ; Sat, 23 Nov 2019 06:46:31 -0800 (PST) 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=fXbqoHk5sy1+srZ9EBF2TtASRKkO02tX5K+iDaduaZ4=; b=dqWmP3CWnzybcwtSnuzTsjayJLk5SnnrONIu0gFTuIDZ7A14MZc0zXmA8x5dwYEHmY qMfj3PQkg6AdFTvgzuEJSQDeP4sCybXa1ieTJWvKvzVHTyNSU4cYVNB98fJaEN7uHpmJ EASjuHWnvlu+bLTa9C1Nd//dGxfZylJXbmi3TGnLsG/mATX66RWa4T1Yj3EHUjkShKLH /XgoMaGO+R3y2d50gFitEvs6kq50ZEjAfBmhB5wXer9hotUdg0b1jJgHHh3OTEeNWke9 3cToJ+Q5nmTtNavB0y8tJ3npJzO4lE22jxmhhQUb4UoMIKys8L3gFy/aggj3GqZRJ05k VUqg== 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=fXbqoHk5sy1+srZ9EBF2TtASRKkO02tX5K+iDaduaZ4=; b=Q/t+z5cQZWIkAUJQ/NO3MNBeCGqZqLQIjoVrzNrGnr3GeBuXlTy5WJptt9LHv4CIUj tYga3G28zZl8gl3OInEH6Qc2kmspiGb0ZYZGSxiBX74skQAMrNjoxUUypqPKx+YqK0Hv WLwpQJYdQpPknexZhQr1102FwQNh1svGXcTy7TZj+mNladtHNl+hgrupzk542YDmxHTW PD/mVE0jRbhZcRLbqGadgSbHRzxToO8UGATkGinbW2ihOroXlBRjl5j1bj0x8R3BXJhl RmunT8QlSLXrXB0hBw5+LpFrvBUHq6XYpTGsGycKDMHO8i8DUS6qQNeDO7ETX1OtZ6Dd tfDw== X-Gm-Message-State: APjAAAXWMso6MrlWNfsXXsH1AXRtDtvz4c4ff0TplOV+XNRjVIgEcD6c YgDCD9Wa04P34nVzptBuwYFO3Zbz X-Google-Smtp-Source: APXvYqzIgot51aZBLtYlj4M1jsu32LpmDCHTy77kVDtYP6CD6k+DZngiitlvIT6DKz2YLEulFj/caQ== X-Received: by 2002:adf:f3c5:: with SMTP id g5mr23019942wrp.5.1574520042984; Sat, 23 Nov 2019 06:40:42 -0800 (PST) Received: from localhost.localdomain (atoulouse-658-1-110-106.w86-199.abo.wanadoo.fr. [86.199.33.106]) by smtp.googlemail.com with ESMTPSA id b10sm2399298wrw.53.2019.11.23.06.40.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 23 Nov 2019 06:40:42 -0800 (PST) From: Alban Gruin To: git@vger.kernel.org Cc: Johannes Schindelin , Phillip Wood , Junio C Hamano , Jonathan Tan , Alban Gruin Subject: [PATCH v3 4/5] rebase: fill `squash_onto' in get_replay_opts() Date: Sat, 23 Nov 2019 15:37:04 +0100 Message-Id: <20191123143705.17280-5-alban.gruin@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191123143705.17280-1-alban.gruin@gmail.com> References: <20191007092641.12661-1-alban.gruin@gmail.com> <20191123143705.17280-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 When sequencer_continue() is called by complete_action(), `opts' has been filled by get_replay_opts(). Currently, it does not initialise the `squash_onto' field (used by the `--root' mode), only read_populate_opts() does. It’s not a problem yet since sequencer_continue() calls it before pick_commits(), but it would lead to incorrect results once complete_action() is modified to call pick_commits() directly. Let’s change that. Signed-off-by: Alban Gruin --- builtin/rebase.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/builtin/rebase.c b/builtin/rebase.c index e8319d5946..2097d41edc 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -117,6 +117,11 @@ static struct replay_opts get_replay_opts(const struct rebase_options *opts) if (opts->strategy_opts) parse_strategy_opts(&replay, opts->strategy_opts); + if (opts->squash_onto) { + oidcpy(&replay.squash_onto, opts->squash_onto); + replay.have_squash_onto = 1; + } + return replay; } From patchwork Sat Nov 23 14:37:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alban Gruin X-Patchwork-Id: 11258819 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 75806930 for ; Sat, 23 Nov 2019 14:47:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 54B2E2071B for ; Sat, 23 Nov 2019 14:47:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="tFQTzrPQ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726840AbfKWOrc (ORCPT ); Sat, 23 Nov 2019 09:47:32 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:34610 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726704AbfKWOrc (ORCPT ); Sat, 23 Nov 2019 09:47:32 -0500 Received: by mail-wm1-f67.google.com with SMTP id j18so12456061wmk.1 for ; Sat, 23 Nov 2019 06:47:30 -0800 (PST) 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=FLBc34Uz8vmA0g3wPA6jInm6SI34pchu74/TCjp84yI=; b=tFQTzrPQPY91Fr99W9oHePgVY2Pg/OLaOkbmwUOtwi25+G4rxCWyRAFLTOoWHI+u8E R8TAqL7mnMXC0Wvf3y1VedIFh1ZZLO7Jv2ZKm3wRxtMkp8OfGibJAoNubHQznV/iN9z5 IssZxEyvpLn5X6C1bhFJCBIUJIkQDRlehG8fhg11rSChrYiBDyevBzd7kim09FTo83fQ WRUSd2fZGoybXOw8yajKjXdDENcNCsFSaqiRqPh6z+tz+IOk7nVUASLYX9+hlWzYF6+Z Ef0bynvnVK78ZH17PtV1mZK00vp+wGToUTyF7gs1PQzL7PthHlTUXfLOMBYPZuSYnxR7 uZcg== 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=FLBc34Uz8vmA0g3wPA6jInm6SI34pchu74/TCjp84yI=; b=UMC9DTlvuDWRX+YBvHH2U1GCwoeee5iw0YoMdzSpaZ5HtWZkAVDYAocJd1qfHvaU4q rVi9pzyX2igxJsXmpAGE/FzZwKp5lYz1lSaps/aLV4C+3dFZQkqU0nn/HaAoJtEheF2Y xrMSdY3723SywbDPCqcy9ZW1oHngvFG5Wamw7xgPoUMDjCoIm/5Z1z7dcL7leSwAaViO 0/4uoH0r6JT1qyh+jK5AdB0QUm9GXVJTMhBcX9dLJdTY+gLtYPVzsTJQm3kyO9Z7fPSz VVP35QWEwgvq9+XUzBpHrdcoQn+9+izDLPGT13s0NPeomDzIkXwJftf04FLgdbdaeb59 t9HQ== X-Gm-Message-State: APjAAAWDZZ9YV53tKTqSC20xashcmEbwcaDH/vdl1Kos31ZmaraFhxfl zIcQu5K6bXcEPFmvv7wX5mwJDP8K X-Google-Smtp-Source: APXvYqyGINuQv1ZaSlWuqTk5eArnCD8nNlPPx+dt0eXKLyXN40LrT5m29SnGQ8eem6/dn+lLptuLQQ== X-Received: by 2002:a7b:c44c:: with SMTP id l12mr14860608wmi.71.1574520044043; Sat, 23 Nov 2019 06:40:44 -0800 (PST) Received: from localhost.localdomain (atoulouse-658-1-110-106.w86-199.abo.wanadoo.fr. [86.199.33.106]) by smtp.googlemail.com with ESMTPSA id b10sm2399298wrw.53.2019.11.23.06.40.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 23 Nov 2019 06:40:43 -0800 (PST) From: Alban Gruin To: git@vger.kernel.org Cc: Johannes Schindelin , Phillip Wood , Junio C Hamano , Jonathan Tan , Alban Gruin Subject: [PATCH v3 5/5] sequencer: directly call pick_commits() from complete_action() Date: Sat, 23 Nov 2019 15:37:05 +0100 Message-Id: <20191123143705.17280-6-alban.gruin@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191123143705.17280-1-alban.gruin@gmail.com> References: <20191007092641.12661-1-alban.gruin@gmail.com> <20191123143705.17280-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 Currently, complete_action(), used by builtin/rebase.c to start a new rebase, calls sequencer_continue() to do it. Before the former calls pick_commits(), it - calls read_and_refresh_cache() -- this is unnecessary here as we've just called require_clean_work_tree() in complete_action() - calls read_populate_opts() -- this is unnecessary as we're starting a new rebase, so `opts' is fully populated - loads the todo list -- this is unnecessary as we've just populated the todo list in complete_action() - commits any staged changes -- this is unnecessary as we're starting a new rebase, so there are no staged changes - calls record_in_rewritten() -- this is unnecessary as we're starting a new rebase. This changes complete_action() to directly call pick_commits() to avoid these unnecessary steps. Signed-off-by: Alban Gruin --- sequencer.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/sequencer.c b/sequencer.c index ec7ea8d9e5..ec0b793fc5 100644 --- a/sequencer.c +++ b/sequencer.c @@ -5140,15 +5140,21 @@ int complete_action(struct repository *r, struct replay_opts *opts, unsigned fla return error_errno(_("could not write '%s'"), todo_file); } - todo_list_release(&new_todo); + res = -1; if (checkout_onto(r, opts, onto_name, &oid, orig_head)) - return -1; + goto cleanup; if (require_clean_work_tree(r, "rebase", "", 1, 1)) - return -1; + goto cleanup; - return sequencer_continue(r, opts); + todo_list_write_total_nr(&new_todo); + res = pick_commits(r, &new_todo, opts); + +cleanup: + todo_list_release(&new_todo); + + return res; } struct subject2item_entry {