From patchwork Wed Jul 17 14:39:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alban Gruin X-Patchwork-Id: 11047991 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 9385313BD for ; Wed, 17 Jul 2019 14:41:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8226D286C1 for ; Wed, 17 Jul 2019 14:41:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 764E2287C2; Wed, 17 Jul 2019 14:41:57 +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 B1F1B287C0 for ; Wed, 17 Jul 2019 14:41:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727210AbfGQOlz (ORCPT ); Wed, 17 Jul 2019 10:41:55 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:39964 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726452AbfGQOlz (ORCPT ); Wed, 17 Jul 2019 10:41:55 -0400 Received: by mail-wr1-f67.google.com with SMTP id r1so25108531wrl.7 for ; Wed, 17 Jul 2019 07:41:53 -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=GdMD/fAN+lZwJ82MReeYciRQSDLmINXX7d7VjAd675k=; b=n0UxQnJpWlTVM2Lb3Dtlbr/4CGZLU97dIwPl5YjEi6oP3oQMmttjvtdITgiaI0Rp3D TQY6LsG8mdXnYQtHLQ5r6rUlAQoYzWXx3hzCjpkyXXbX79UMQQNuZtaQ80lIZRg9WqPt ofPlEDaCUNW2hmQCCq+h16+aPGT0WaL1rtGoVlRNWi6BSP7JDzN4PzM+hYFMdGKuAdlz qeoOMXiz46AIgRfWIZzjjmpAuK9KSR7ST2UEtBrwaC1wSwmpcsGo1F6Hi9TVlIZSATR6 UoxtB2BMTxBe7+/25wOShs8qbQWJ2sGVHMMkfcWXdPKMWA4aZ+lBuW2c9/G4zr77vlCp 00Ng== 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=GdMD/fAN+lZwJ82MReeYciRQSDLmINXX7d7VjAd675k=; b=mWdnL3reqFFRAIHlKvWS8WXK3TiIK9aA7XHZwCsV7r321zleGWbaYg2s5ALH6mkC02 HTdRF7mXnmSok7KcOhuVTbiaHlY/nymnqSsB09osS2zPzP5sldyb0ELVJMOFwgML0EJW CroYeGTCo6zJjyFUFiY0ENUTisq4ybnbWiQ8YPNw8Vgo6lphLqvg6gRv5UULgm8LGjTT DJEHej//fjIZOJggrOtFEwZRhvkne3ZmUVSFBZn3tXJ9rK/eUvDTv6ch9ktRs38TqKvV /No9CHbBCiILSr6bWytbReQ1/czI7KGZk5nNdH1adqkFbtY28riAYzyiTGv/l1/Pq6lq kCxA== X-Gm-Message-State: APjAAAWOLJZlYxD4X5WJRZdJl6svGZlGiqBDzifgjkvmm4nihUS/Yq0W cn+skBw8kMzq/y2mwJSCt+UI9biG X-Google-Smtp-Source: APXvYqxOipvshELRoFAkh4y6uFQYXldRE0N6Pxigum8RxkmdP0GJxPuMbtIkkogAgrIFFNgIYODf0g== X-Received: by 2002:adf:fe4f:: with SMTP id m15mr13568106wrs.36.1563374513063; Wed, 17 Jul 2019 07:41:53 -0700 (PDT) Received: from localhost.localdomain (atoulouse-658-1-183-65.w86-199.abo.wanadoo.fr. [86.199.38.65]) by smtp.googlemail.com with ESMTPSA id p18sm21815968wrm.16.2019.07.17.07.41.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Jul 2019 07:41:52 -0700 (PDT) From: Alban Gruin To: git@vger.kernel.org Cc: Johannes Schindelin , Phillip Wood , Alban Gruin Subject: [RFC PATCH 1/9] t3404: demonstrate that --edit-todo does not check for dropped commits Date: Wed, 17 Jul 2019 16:39:10 +0200 Message-Id: <20190717143918.7406-2-alban.gruin@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190717143918.7406-1-alban.gruin@gmail.com> References: <20190717143918.7406-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 When set to "warn" or "error", `rebase.missingCommitCheck' would make rebase -i warn if the user removed commits from the todo list to prevent mistakes. Unfortunately, rebase --edit-todo and rebase --continue don't take it into account. This adds three tests to t3404 to demonstrate this. The first one is not broken, as when `rebase.missingCommitsCheck' is not set, nothing in particular must be done towards dropped commits. The two others are broken, demonstrating the problem. Signed-off-by: Alban Gruin --- t/t3404-rebase-interactive.sh | 82 +++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 461dd539ff..f5c0a8d2bb 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -1345,6 +1345,88 @@ test_expect_success 'rebase -i respects rebase.missingCommitsCheck = error' ' test B = $(git cat-file commit HEAD^ | sed -ne \$p) ' +test_expect_success 'rebase --edit-todo respects rebase.missingCommitsCheck = ignore' ' + test_config rebase.missingCommitsCheck ignore && + rebase_setup_and_clean missing-commit && + set_fake_editor && + test_must_fail env FAKE_LINES="1 2 bad 3 4" \ + git rebase -i --root >/dev/null 2>stderr && + FAKE_LINES="1 2 4" git rebase --edit-todo && + git rebase --continue 2>actual && + test D = $(git cat-file commit HEAD | sed -ne \$p) && + test_i18ngrep \ + "Successfully rebased and updated refs/heads/missing-commit" \ + actual +' + +cat >expect <expect.2 + +test_expect_failure 'rebase --edit-todo respects rebase.missingCommitsCheck = warn' ' + test_config rebase.missingCommitsCheck warn && + rebase_setup_and_clean missing-commit && + set_fake_editor && + test_must_fail env FAKE_LINES="1 2 3 4 bad 5" \ + git rebase -i --root >/dev/null 2>stderr && + FAKE_LINES="1 2 3 4" git rebase --edit-todo 2>actual && + test_i18ncmp expect actual && + git rebase --continue 2>actual.2 && + head -n 8 actual && + test_i18ncmp expect.2 actual && + test D = $(git cat-file commit HEAD | sed -ne \$p) && + test_i18ngrep \ + "Successfully rebased and updated refs/heads/missing-commit" \ + actual.2 +' + +cat >expect <expect.2 + +test_expect_failure 'rebase --edit-todo respects rebase.missingCommitsCheck = error' ' + test_config rebase.missingCommitsCheck error && + rebase_setup_and_clean missing-commit && + set_fake_editor && + test_must_fail env FAKE_LINES="1 2 bad 3 4" \ + git rebase -i --root >/dev/null 2>stderr && + test_must_fail env FAKE_LINES="1 2 4" \ + git rebase --edit-todo 2>actual && + test_i18ncmp expect actual && + test_must_fail git rebase --continue 2>actual && + test_i18ncmp expect.2 actual && + cp .git/rebase-merge/git-rebase-todo.backup \ + .git/rebase-merge/git-rebase-todo && + FAKE_LINES="1 2 drop 3 4 drop 5" \ + git rebase --edit-todo && + git rebase --continue 2>actual && + test D = $(git cat-file commit HEAD | sed -ne \$p) && + test_i18ngrep \ + "Successfully rebased and updated refs/heads/missing-commit" \ + actual +' + test_expect_success 'respects rebase.abbreviateCommands with fixup, squash and exec' ' rebase_setup_and_clean abbrevcmd && test_commit "first" file1.txt "first line" first && From patchwork Wed Jul 17 14:39:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alban Gruin X-Patchwork-Id: 11047993 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 3A89913BD for ; Wed, 17 Jul 2019 14:41:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2AF80286C1 for ; Wed, 17 Jul 2019 14:41:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F439287C2; Wed, 17 Jul 2019 14:41:59 +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 AB54628710 for ; Wed, 17 Jul 2019 14:41:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727242AbfGQOl5 (ORCPT ); Wed, 17 Jul 2019 10:41:57 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:41107 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726452AbfGQOl5 (ORCPT ); Wed, 17 Jul 2019 10:41:57 -0400 Received: by mail-wr1-f67.google.com with SMTP id c2so21916736wrm.8 for ; Wed, 17 Jul 2019 07:41:56 -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=8bAEYP/5Ony482hTu/GBgV0DIOKx0kU7we/oqdgMykQ=; b=EE4UVeXyZNjuL5CxfQlILrJQ3oUSzjvVSMkZ5GdSXgwpAWuccpkIU/HzCpCnM9DQKj /GK/TbZ6tserZxG8kldv1Z5DdENVzLf1EWkaHIVvWsXLfK1dkZ23UQst23FqKJSG2Wj3 WtT7aMftLG81ceufr9zprqoCXTOj0TeE0kguz2moXR2zTrGPg1IDxhejYXQ0IfkoW6Id dqMTCBT3BMg7Y9EdxsvcuU6kSiV3zXoCloRPeIAw5QHv9pjRZkb2x3izXWNFcRhGirn1 MndqFSL+9yFp5zanXYCTeALjFgUuq0uvtFubguVs+fsRKcPmDupaf5Ze754hjctq1iVt kBkQ== 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=8bAEYP/5Ony482hTu/GBgV0DIOKx0kU7we/oqdgMykQ=; b=r1r5YY6ARj12XEmGs7LJGp14VKKuXshkiyJmtwOmj+ej7RuYHGEywNqUHA/GOWu42j 3Ep4tgAkuXaZM/G+r7pitrzZlvM5n9WmOQBPHD07t49sdW60wr/mMfQORjbsMyUQHwYK eW2FX/Uej2z7x/dkhySpypT/Iom/gd6RuhFXNb1dkrn5GO0KuoU/q8/EilASP41Pc4O6 zPOGrWAbh00QYPXIeM08DIObnmmf68LoFIg8Lul6inC/qW/T0j0Bo9khyqkTmTaVXG0C I8+PaTLkGqCJO17hGY+GFoKI0Aw2cDEWDi1W6pHcriLFf7IvP1ilf6U23oyoC/Cq2PVa yBPQ== X-Gm-Message-State: APjAAAWz/iif+dOmX+tbfupltxEo8tZ/okUZyL+C3RybcQ8ZG+Tb3bLx /ib1V9PMG6PWqLlaNmtloXp6kqR5 X-Google-Smtp-Source: APXvYqwNFRdAhWpmLffHdqal5UsbKS0fH7ObZ8gXdANpJ3C7kPC0PZwDzPvspqGx7gsHh7LY6hCymA== X-Received: by 2002:a5d:63c9:: with SMTP id c9mr7245359wrw.15.1563374515210; Wed, 17 Jul 2019 07:41:55 -0700 (PDT) Received: from localhost.localdomain (atoulouse-658-1-183-65.w86-199.abo.wanadoo.fr. [86.199.38.65]) by smtp.googlemail.com with ESMTPSA id p18sm21815968wrm.16.2019.07.17.07.41.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Jul 2019 07:41:54 -0700 (PDT) From: Alban Gruin To: git@vger.kernel.org Cc: Johannes Schindelin , Phillip Wood , Alban Gruin Subject: [RFC PATCH 2/9] t3429: demonstrate that rebase exec does not check for dropped commits Date: Wed, 17 Jul 2019 16:39:11 +0200 Message-Id: <20190717143918.7406-3-alban.gruin@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190717143918.7406-1-alban.gruin@gmail.com> References: <20190717143918.7406-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 After executing a command, rebase reloads the todo list from the disk, in case the script has modified it, but does not honour rebase.missingCommitsCheck. This adds three tests to t3429 to demonstrate this. The first one is not broken, as when `rebase.missingCommitsCheck' is not set, nothing should be done for dropped commits. The last two are, demonstrating the problem. Signed-off-by: Alban Gruin --- t/t3429-rebase-edit-todo.sh | 44 +++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/t/t3429-rebase-edit-todo.sh b/t/t3429-rebase-edit-todo.sh index 76f6d306ea..2bb9fb65fa 100755 --- a/t/t3429-rebase-edit-todo.sh +++ b/t/t3429-rebase-edit-todo.sh @@ -4,15 +4,16 @@ test_description='rebase should reread the todo file if an exec modifies it' . ./test-lib.sh +todo=.git/rebase-merge/git-rebase-todo + test_expect_success 'rebase exec modifies rebase-todo' ' test_commit initial && - todo=.git/rebase-merge/git-rebase-todo && git rebase HEAD -x "echo exec touch F >>$todo" && test -e F ' test_expect_success SHA1 'loose object cache vs re-reading todo list' ' - GIT_REBASE_TODO=.git/rebase-merge/git-rebase-todo && + GIT_REBASE_TODO=$todo && export GIT_REBASE_TODO && write_script append-todo.sh <<-\EOS && # For values 5 and 6, this yields SHA-1s with the same first two digits @@ -33,4 +34,43 @@ test_expect_success SHA1 'loose object cache vs re-reading todo list' ' git rebase HEAD -x "./append-todo.sh 5 6" ' +test_expect_success 'rebase exec respects rebase.missingCommitsCheck = ignore' ' + test_config rebase.missingCommitsCheck ignore && + git rebase HEAD~2 --keep-empty -x "echo >$todo" && + test 5 = $(git cat-file commit HEAD | sed -ne \$p) +' + +cat >expect <$todo" 2>actual.2 && + head -n8 actual.2 | tail -n7 >actual && + test_i18ncmp expect actual && + test 5 = $(git cat-file commit HEAD | sed -ne \$p) +' + +test_expect_failure 'rebase exec respects rebase.missingCommitsCheck = error' ' + test_config rebase.missingCommitsCheck error && + git reset --hard HEAD@{2} && + test_must_fail git rebase HEAD~2 --keep-empty -x "echo >$todo" 2>actual.2 && + head -n8 actual.2 | tail -n7 >actual && + test_i18ncmp expect actual && + echo drop $(git rev-list --pretty=oneline -1 HEAD@{1}) >$todo && + git rebase --continue 2>actual && + test 5 = $(git cat-file commit HEAD | sed -ne \$p) && + test_i18ngrep \ + "Successfully rebased and updated refs/heads/master" \ + actual +' + test_done From patchwork Wed Jul 17 14:39:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alban Gruin X-Patchwork-Id: 11047995 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 EFA1A1510 for ; Wed, 17 Jul 2019 14:42:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E06BB28620 for ; Wed, 17 Jul 2019 14:42:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D4E8728714; Wed, 17 Jul 2019 14:42:00 +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 9407328620 for ; Wed, 17 Jul 2019 14:42:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727311AbfGQOl7 (ORCPT ); Wed, 17 Jul 2019 10:41:59 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:45280 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726452AbfGQOl6 (ORCPT ); Wed, 17 Jul 2019 10:41:58 -0400 Received: by mail-wr1-f65.google.com with SMTP id f9so25087128wre.12 for ; Wed, 17 Jul 2019 07:41:58 -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=pYY/tozECmNEaY4vtGtG3KGzMn49VSt0IcZC55WD/Qo=; b=iT9rvt310Vyo65N6A8xNuVTF+5nbLGM+UcVTV/JAFUgE+FwRRhnvtakH821EmxhnJb wQaRw61TygpvQ0y0ZpwPeZ7i+43dHUwtTbnuA3ghk/ZFsXI2n1DvZzejsOh1/TN09NvU r6Y3mX+ULUjNNLIBOqwtLaiW7CLjPHbLOA9Vpy+5WgVT11hvsas30inWimDbjiMsY4Gy rRDqMMj9H0QAIbmXuJ2pDxoaQx6VrzZjFcVjtlp6oVqy0rlbRQte++9RtTlK9mSjkotE 6iK1ELOcaK1zIvQKIgZhkzOVLNEOLfcyUQdzyrZqZoQrz7SAKqts372r13IqKz7z7JEz sfFQ== 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=pYY/tozECmNEaY4vtGtG3KGzMn49VSt0IcZC55WD/Qo=; b=RjWysX2QcjGT4x4L16v/eVzEB6xgg3u7U/Qhu++5K1ipujnlq0Y5fSmJA1ZiMfUV3G BuvnoAB7eusye3Po/X+Wsz/WvipJYHbCwJnPilSZ9HgzXga57WOSbLcayfLtYZUL4JpE 4zmh+i1ny1P7GpRCLNUS1kdIcdofTAqOgltRHHG0B5JsqPtkM8nMmUKQ+AuNxdNcXf0S 81yAQEQVxESqv754A+4zo1yiduBUh2CT26Ahmcf45EyxEAQFHr6HqaebhOcHJsoHfK02 EItQGWV3BrAolDOYH6x5iUE7K8ZzghP4e+1uv3++xa3VOjijNusd+wsyxD6hVGEDeV8g YtXQ== X-Gm-Message-State: APjAAAVu5aBmTziw+MTFlVIurDeiM3fJHRdUukjU/T+iywX27gpvLnEP P8Bo8abdIDAVrIkHMOoFMx6yF9MM X-Google-Smtp-Source: APXvYqyQrCdX6KyevOICVw8r0InsDUg4iBAzXO/KjX4S8izwr9pZQPO0y5tpdOGqJqWDGP2pVfuMLw== X-Received: by 2002:a5d:528d:: with SMTP id c13mr42798002wrv.247.1563374516916; Wed, 17 Jul 2019 07:41:56 -0700 (PDT) Received: from localhost.localdomain (atoulouse-658-1-183-65.w86-199.abo.wanadoo.fr. [86.199.38.65]) by smtp.googlemail.com with ESMTPSA id p18sm21815968wrm.16.2019.07.17.07.41.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Jul 2019 07:41:56 -0700 (PDT) From: Alban Gruin To: git@vger.kernel.org Cc: Johannes Schindelin , Phillip Wood , Alban Gruin Subject: [RFC PATCH 3/9] sequencer: update `total_nr' when adding an item to a todo list Date: Wed, 17 Jul 2019 16:39:12 +0200 Message-Id: <20190717143918.7406-4-alban.gruin@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190717143918.7406-1-alban.gruin@gmail.com> References: <20190717143918.7406-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 `total_nr' is the total amount of items, done and toto, that are in a todo list. But unlike `nr', it was not updated when an item was appended to the list. Signed-off-by: Alban Gruin --- sequencer.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sequencer.c b/sequencer.c index cf262701e8..e61ae75451 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 Wed Jul 17 14:39:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alban Gruin X-Patchwork-Id: 11047997 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 2B1CF1510 for ; Wed, 17 Jul 2019 14:42:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B77028710 for ; Wed, 17 Jul 2019 14:42:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 103AD287C0; Wed, 17 Jul 2019 14:42:03 +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 B557528710 for ; Wed, 17 Jul 2019 14:42:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727331AbfGQOmB (ORCPT ); Wed, 17 Jul 2019 10:42:01 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:36306 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727285AbfGQOmA (ORCPT ); Wed, 17 Jul 2019 10:42:00 -0400 Received: by mail-wr1-f66.google.com with SMTP id n4so25167344wrs.3 for ; Wed, 17 Jul 2019 07:41:59 -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=sr8TIFH8S4UqiZBovoK4G12GCMc+iWn85+nmFOqx1Ys=; b=VqxBi0M6taQ/yDF3U+kWRZ2ry2KR5OGoMDYP1dy5isjUrMnbL/nEtK4S9QFNYy0Acw JRbmZbYJ5Np+46bxwWy5xZKx+XThuHgbOH9WYcaZ+BADhwAo554CNJW50DerfVXK37BE tIceafqyOv2EURyvOaeehcXFT0bJbAdlQxsg9ZhSUByfJHD9Rf5cOduynpzrXoktjF9R xSLCnYFYa23eTT6dXdG+kbnkWQp9Iss2jO1Dfo/6pp5gRkKd5ZtmlJc/JBzNfNlVpJvO SAU9+6c9YnTHOyZ4snRkk+PaxBJM1mylYlhUwrXFOCgk/BXQ4S9KXV/XaTGlFgRtrCO8 A7wA== 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=sr8TIFH8S4UqiZBovoK4G12GCMc+iWn85+nmFOqx1Ys=; b=WqfglYGoR3iYkhnqMHrHooAlAF3vSJB8e+3EUhoqxMu3hJ4lhh+TPQ7HPmuSMoS04T 7it7SiH4SMB0BBM+JFGDmPUjKBvV6iKBsTvDayVKtr/mO22FyCPYG99SublYYqRmtFQP HD61jIAMY/LxS56q9dlxbA+/NjYiz6/J9TGynUBmHd7tzW3xdljzeYFl0x8nKhhyJrKf AfLe0ruQiuU2/ZcjBRq8t+RSzxMWK9jJ066r5a9zJNxPaywbmhCQrtAXMW0aYBcIIXOS AcaJhPu/5hmGnZ9sQ0J54ciPv22BLH94tyu6EMxX81NdHEUGGmtiIy3dQYsIOemAXd7H OHVw== X-Gm-Message-State: APjAAAUFpqqq8v9rn33V2GcymGJjrHK8gg2cH0wsqaA9DhWui9vEPmwB 7hBZOzUm6DeQ0oL5ayr6rtdOaM/i X-Google-Smtp-Source: APXvYqzy+M/vePVxlfyFGTZPypTKqqx0ukqjsodL41nGMj/zB72C3ST5BSwBvhPBQuroKun6iqFfTg== X-Received: by 2002:adf:f6d2:: with SMTP id y18mr42711838wrp.102.1563374518567; Wed, 17 Jul 2019 07:41:58 -0700 (PDT) Received: from localhost.localdomain (atoulouse-658-1-183-65.w86-199.abo.wanadoo.fr. [86.199.38.65]) by smtp.googlemail.com with ESMTPSA id p18sm21815968wrm.16.2019.07.17.07.41.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Jul 2019 07:41:58 -0700 (PDT) From: Alban Gruin To: git@vger.kernel.org Cc: Johannes Schindelin , Phillip Wood , Alban Gruin Subject: [RFC PATCH 4/9] sequencer: update `done_nr' when skipping commands in a todo list Date: Wed, 17 Jul 2019 16:39:13 +0200 Message-Id: <20190717143918.7406-5-alban.gruin@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190717143918.7406-1-alban.gruin@gmail.com> References: <20190717143918.7406-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 In a todo list, `done_nr' is the amount of commands that were executed or skipped, but skip_unnecessary_picks() did not update it. Signed-off-by: Alban Gruin --- sequencer.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sequencer.c b/sequencer.c index e61ae75451..ec9c3d4dc5 100644 --- a/sequencer.c +++ b/sequencer.c @@ -4939,6 +4939,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 Wed Jul 17 14:39:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alban Gruin X-Patchwork-Id: 11047999 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 6755C13BD for ; Wed, 17 Jul 2019 14:42:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5841A286A4 for ; Wed, 17 Jul 2019 14:42:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4CF7F2871E; Wed, 17 Jul 2019 14:42:04 +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 EA0FA287BF for ; Wed, 17 Jul 2019 14:42:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727358AbfGQOmD (ORCPT ); Wed, 17 Jul 2019 10:42:03 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:36310 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726452AbfGQOmC (ORCPT ); Wed, 17 Jul 2019 10:42:02 -0400 Received: by mail-wr1-f67.google.com with SMTP id n4so25167454wrs.3 for ; Wed, 17 Jul 2019 07:42:01 -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=7tobFTg7AVZQDvPzSsfhTT1tJ9CUQC01AcBkkA0DAlI=; b=QuIvPJPUG4v0mkbnwcbJxiioS0Etki+lSqcdBSTQbHNzPb0FMHPMm+8dHfbxAD8lKN KPfLjXgkfGsrK7phqqCNNWffNxlhFJiNnJIg/uioftfvvYauQHvVoKGZxRM3wKEM21Po rkBVMHde/dd1NXXWxczIDenVE5p8bDk9uxLLfS12w8h0+FCNu8AJ9SupoMyPJweHFSbG bW41cF8jJ/QGWomcAh5P/7Ble1CoJfRO6mA3Y2tdQtqKClQ/Nne3ND+a8TxQq55Uro4C TPck1WP37AEALoqhVlTq5h227FLsQKJVyVCR7RrYvwWOLfo43zrBSjFCJ7r4+9IeYF6w NnGA== 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=7tobFTg7AVZQDvPzSsfhTT1tJ9CUQC01AcBkkA0DAlI=; b=hun49hndDdysdRqTIw2CfADCwgFzmSrZ2/OYrrx8ckfzleX4jN6xIUUO3447s6MmVa 74o9jzBz88AkBvOxHP4AQpih28he+pHIHgWkCiQ2jEEu4H5zcmX6ADjER2+wdFGiRU9e o5ttNrgBUydGCyyuGlf6aUFVhTnPKMPLG/lSXHZRazsUb3TkS7Nq+I69EJXvibMe7sQs hMp2EOq/+zJ9uogC23acKGOYEB/6nhIJponBLBDIaYgxe6XcYAHt1TxvRczCR9az0LKN v6FCtqDlpOhuFHXaOxpb5laTFhuNbDB79caqQjfQvKzuNKdiuuFaduXW1ST2ZanBz5tm 7WUw== X-Gm-Message-State: APjAAAWY6D1I3LXvgGUqGFbvSXJ9sPjv86Ba8t2mLwX3CpjIu6iMjJV6 AMBG0J1EeajHyLtlkRfy1OWIqWUC X-Google-Smtp-Source: APXvYqztzoIZ3k2lIjC+jnQVdQQJ/mB2KEknkrufW0uUE7iLu4s2ekFJSRF5v3TFh09E1Yn1dhFEkQ== X-Received: by 2002:adf:f04d:: with SMTP id t13mr8991559wro.133.1563374520357; Wed, 17 Jul 2019 07:42:00 -0700 (PDT) Received: from localhost.localdomain (atoulouse-658-1-183-65.w86-199.abo.wanadoo.fr. [86.199.38.65]) by smtp.googlemail.com with ESMTPSA id p18sm21815968wrm.16.2019.07.17.07.41.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Jul 2019 07:41:59 -0700 (PDT) From: Alban Gruin To: git@vger.kernel.org Cc: Johannes Schindelin , Phillip Wood , Alban Gruin Subject: [RFC PATCH 5/9] sequencer: move the code writing total_nr on the disk to a new function Date: Wed, 17 Jul 2019 16:39:14 +0200 Message-Id: <20190717143918.7406-6-alban.gruin@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190717143918.7406-1-alban.gruin@gmail.com> References: <20190717143918.7406-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 The total amount of commands can be used to show the progression of the rebasing in a shell. This number 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(), which releases its todo list before calling sequencer_continue(), which reloads it immediatly afterwards. To avoid to reload the todo list from the disk, sequencer_continue() will be modified to accept a todo list, and if it is not null, read_populate_todo() will not be called. This moves the part writing total_nr to a new function so it can be called by 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 ec9c3d4dc5..d66b80d49f 100644 --- a/sequencer.c +++ b/sequencer.c @@ -2343,6 +2343,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) @@ -2388,7 +2398,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)) @@ -2400,10 +2409,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 Wed Jul 17 14:39:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alban Gruin X-Patchwork-Id: 11048001 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 BE19A13BD for ; Wed, 17 Jul 2019 14:42:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AE7A0287D1 for ; Wed, 17 Jul 2019 14:42:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A2B4828714; Wed, 17 Jul 2019 14:42:06 +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 2BBC7287B7 for ; Wed, 17 Jul 2019 14:42:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727408AbfGQOmF (ORCPT ); Wed, 17 Jul 2019 10:42:05 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:52268 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726452AbfGQOmE (ORCPT ); Wed, 17 Jul 2019 10:42:04 -0400 Received: by mail-wm1-f66.google.com with SMTP id s3so22436778wms.2 for ; Wed, 17 Jul 2019 07:42:03 -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=ziQkMtRJNKMT2OPbJgfukivTaU1CF27jG7EemtvEwis=; b=Z7G5GnhCFcBW2ZRYkGA5pHwjy3RffLGk5Mkx+MLMT3wU0fCEhBOijAnUHkobEzM8JP XRuq4Leu/LHYkadLOr30NjIBFbP9rXrurKllWQCGjNLnAJtFxEJl+Vtx8CuvYLnNWPAi gN6Ybc9GQoy1lGPUUXz/p9GDRSrhLBuDo+9WDguLeuUA1VxSq+UmZpU5YwRLeTREnHAh q6c0My4qFVgm2vIrl+6QHgJzFNpQU8dZdxyMprsBw12p1zT16hmo+Cxuahi7ge8ITIrD z+mRXreRXEXR8eXxGUcXdjIx4t1kb98p/750j2bYsxZbUqB9tRJ4PAJrNjvMrzt0i2S0 dXiQ== 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=ziQkMtRJNKMT2OPbJgfukivTaU1CF27jG7EemtvEwis=; b=bZ+zWEU8iQvj/kapy9x7H1iOB7TkqjNaK7jyDFs0TMUhd6zmknJ+Ps04doMqV980qq 4CCtce+QaIwJVCk3hC5aSvUZAIFG4ztMy4kPHStS2IKWIvADqTlNd/jSDKV+l40uVY1F ygDaKuwatcs6zogryEBfWPpnmV0/Q3CNYrmAkqhbZQXdsjcQCVOKBtYhi7OFkZox3H6W ND3CQZ6EZUCWVJSfbXUGYHM6419N0FYIGp+tg/4tA/rd6igyd+3MNyFkjcoNc3cDMO/f 49iW8n6/OrgZhL3F57lsJFWPSuNbWrsIfO4xR/zpFHspGYmVMfoZ5G3u6N9G3/i3tQiT iD1Q== X-Gm-Message-State: APjAAAU4y58Z81iTnIQJQ02AW98rKLBDC66MCbMKiaHAHXurERbycod4 JvgbkeybwRs2zmLYPFJWkoR0F1qa X-Google-Smtp-Source: APXvYqy+P1wkcc/KvCjaR7WS8N6uUoaNNtygRebRoTxdkj0sQ09qyBZOlo4fMf11PkEiomD0vhsQcg== X-Received: by 2002:a05:600c:214c:: with SMTP id v12mr37061080wml.28.1563374522332; Wed, 17 Jul 2019 07:42:02 -0700 (PDT) Received: from localhost.localdomain (atoulouse-658-1-183-65.w86-199.abo.wanadoo.fr. [86.199.38.65]) by smtp.googlemail.com with ESMTPSA id p18sm21815968wrm.16.2019.07.17.07.42.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Jul 2019 07:42:01 -0700 (PDT) From: Alban Gruin To: git@vger.kernel.org Cc: Johannes Schindelin , Phillip Wood , Alban Gruin Subject: [RFC PATCH 6/9] sequencer: add a parameter to sequencer_continue() to accept a todo list Date: Wed, 17 Jul 2019 16:39:15 +0200 Message-Id: <20190717143918.7406-7-alban.gruin@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190717143918.7406-1-alban.gruin@gmail.com> References: <20190717143918.7406-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 As it is called by sequencer_continue() or after an exec command, read_populate_todo() is a great place to check for dropped commits in the todo list, but complete_action() (a caller of sequencer_continue()) already does. Double-checking would show the message twice. This adds a parameter to sequencer_continue() to accept a todo list. If a valid list is provided, read_populate_todo() won't be called. complete_action() is modified to pass its todo list to sequencer_continue(). This also avoids reloading the todo list from the disk just after releasing it. Signed-off-by: Alban Gruin --- builtin/rebase.c | 2 +- builtin/revert.c | 2 +- sequencer.c | 26 +++++++++++++++----------- sequencer.h | 3 ++- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/builtin/rebase.c b/builtin/rebase.c index 89fc4b8153..205916ca11 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -393,7 +393,7 @@ static int run_rebase_interactive(struct rebase_options *opts, case ACTION_CONTINUE: { struct replay_opts replay_opts = get_replay_opts(opts); - ret = sequencer_continue(the_repository, &replay_opts); + ret = sequencer_continue(the_repository, &replay_opts, NULL); break; } case ACTION_EDIT_TODO: diff --git a/builtin/revert.c b/builtin/revert.c index 4e71b2f2aa..45a5c6217d 100644 --- a/builtin/revert.c +++ b/builtin/revert.c @@ -207,7 +207,7 @@ static int run_sequencer(int argc, const char **argv, struct replay_opts *opts) return ret; } if (cmd == 'c') - return sequencer_continue(the_repository, opts); + return sequencer_continue(the_repository, opts, NULL); if (cmd == 'a') return sequencer_rollback(the_repository, opts); return sequencer_pick_revisions(the_repository, opts); diff --git a/sequencer.c b/sequencer.c index d66b80d49f..3fb15ff8d9 100644 --- a/sequencer.c +++ b/sequencer.c @@ -4147,9 +4147,11 @@ static int commit_staged_changes(struct repository *r, return 0; } -int sequencer_continue(struct repository *r, struct replay_opts *opts) +int sequencer_continue(struct repository *r, struct replay_opts *opts, + struct todo_list *p_todo_list) { - struct todo_list todo_list = TODO_LIST_INIT; + struct todo_list todo_list = TODO_LIST_INIT, + *ptr_todo = (p_todo_list) ? p_todo_list : &todo_list; int res; if (read_and_refresh_cache(r, opts)) @@ -4158,13 +4160,13 @@ int sequencer_continue(struct repository *r, struct replay_opts *opts) if (read_populate_opts(opts)) return -1; if (is_rebase_i(opts)) { - if ((res = read_populate_todo(r, &todo_list, opts))) + if (!p_todo_list && (res = read_populate_todo(r, &todo_list, opts))) goto release_todo_list; - if (commit_staged_changes(r, opts, &todo_list)) + if (commit_staged_changes(r, opts, ptr_todo)) return -1; } else if (!file_exists(get_todo_path(opts))) return continue_single_pick(r); - else if ((res = read_populate_todo(r, &todo_list, opts))) + else if (!p_todo_list && (res = read_populate_todo(r, &todo_list, opts))) goto release_todo_list; if (!is_rebase_i(opts)) { @@ -4179,18 +4181,18 @@ int sequencer_continue(struct repository *r, struct replay_opts *opts) res = error_dirty_index(r, opts); goto release_todo_list; } - todo_list.current++; + ptr_todo->current++; } else if (file_exists(rebase_path_stopped_sha())) { struct strbuf buf = STRBUF_INIT; struct object_id oid; if (read_oneliner(&buf, rebase_path_stopped_sha(), 1) && !get_oid_committish(buf.buf, &oid)) - record_in_rewritten(&oid, peek_command(&todo_list, 0)); + record_in_rewritten(&oid, peek_command(ptr_todo, 0)); strbuf_release(&buf); } - res = pick_commits(r, &todo_list, opts); + res = pick_commits(r, ptr_todo, opts); release_todo_list: todo_list_release(&todo_list); return res; @@ -5025,15 +5027,17 @@ 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); - if (checkout_onto(r, opts, onto_name, &oid, orig_head)) return -1; if (require_clean_work_tree(r, "rebase", "", 1, 1)) return -1; - return sequencer_continue(r, opts); + todo_list_write_total_nr(&new_todo); + res = sequencer_continue(r, opts, &new_todo); + todo_list_release(&new_todo); + + return res; } struct subject2item_entry { diff --git a/sequencer.h b/sequencer.h index 3d0b68c34c..858816f94a 100644 --- a/sequencer.h +++ b/sequencer.h @@ -127,7 +127,8 @@ const char *todo_item_get_arg(struct todo_list *todo_list, void sequencer_init_config(struct replay_opts *opts); int sequencer_pick_revisions(struct repository *repo, struct replay_opts *opts); -int sequencer_continue(struct repository *repo, struct replay_opts *opts); +int sequencer_continue(struct repository *repo, struct replay_opts *opts, + struct todo_list *p_todo_list); int sequencer_rollback(struct repository *repo, struct replay_opts *opts); int sequencer_remove_state(struct replay_opts *opts); From patchwork Wed Jul 17 14:39:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alban Gruin X-Patchwork-Id: 11048003 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 5EC1A1510 for ; Wed, 17 Jul 2019 14:42:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4E4A9287DC for ; Wed, 17 Jul 2019 14:42:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 428B7287C0; Wed, 17 Jul 2019 14:42:09 +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 9BDC8287B7 for ; Wed, 17 Jul 2019 14:42:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727520AbfGQOmH (ORCPT ); Wed, 17 Jul 2019 10:42:07 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:36738 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727456AbfGQOmH (ORCPT ); Wed, 17 Jul 2019 10:42:07 -0400 Received: by mail-wm1-f66.google.com with SMTP id g67so18339991wme.1 for ; Wed, 17 Jul 2019 07:42:05 -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=bxNVyN9DKf2MUp+4R28QEcsjpDTJskvcn4VRx/f/bsY=; b=OcLyHt0cTMI61qpyGnPq/MwNycd5p14PU7YT0nkB7EcjlsedNHL/U1lI9FbWjK6lRF K89EagfONcj8yiTN+zh0hQaKogmLHvNPIN/AM9AlQg2raUw9SesB0anGJdQ4YiSjWbld YU/jignTJ8uc5zSZNe0GLPhcKcfDGnb4GIMpt7/AttvTZ1xm+A8Wo9nlkHUboOrfoxnp Z51F8mq0LWcZmgzZ099fY9q/wDwfT+qQKoPCkF251RzelPvxFbNYdrgn8xx6BJ2ozgkp Sh4D8RQ9gVw0UF0XX2X+53I4xumwI2A0zQlICUc2pMW/n/v67pvcMIPsn+wi0ss+yYxY qn/A== 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=bxNVyN9DKf2MUp+4R28QEcsjpDTJskvcn4VRx/f/bsY=; b=ZyJt76JBOEmbt/YfKeBndrC6H5u6iwQZderdboZg7JUVwQYS/mv4nKmEEUOJN6kE+N E5VSsglpAynuzBuo/CdG85ZgXOvPooyIgUFxqc70FD1xfnd7OTWr5alBZ55KfIQwTcDy UoU8wlKP6anC2mtBBtvFIos7Sh3gbIOEfsY64iU3qbNWM6kuAfPfiYHweBuVGwX5qp50 V+/nrRkGYNMAq9/XfOTQN/NM4BMcZjjGY4GYiR0Whd+eqHtN/WmYiXzowNYuSVtQJ1rY 5NVFIGBz2ktBq1tI5yXcjVaaz7S+sbwapAAlX+VB25RElpPd2wFJMKV24EVihDaqyWpo rnDQ== X-Gm-Message-State: APjAAAW2y97082i8B0XhqUfMM7j2LJgvpvCl5+EaIQQmWZK8IP8WkO0c VDoFSFcNUYafrrM9z7JUmwxXN5zZ X-Google-Smtp-Source: APXvYqx1N7SRWHMC8hJlNRPFtmZLo/tfcLHm9hTqCv2eD8erp5ZBULRDgo5GfB7Sv4UayIQ30FE9Kg== X-Received: by 2002:a05:600c:212:: with SMTP id 18mr5703860wmi.88.1563374524151; Wed, 17 Jul 2019 07:42:04 -0700 (PDT) Received: from localhost.localdomain (atoulouse-658-1-183-65.w86-199.abo.wanadoo.fr. [86.199.38.65]) by smtp.googlemail.com with ESMTPSA id p18sm21815968wrm.16.2019.07.17.07.42.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Jul 2019 07:42:03 -0700 (PDT) From: Alban Gruin To: git@vger.kernel.org Cc: Johannes Schindelin , Phillip Wood , Alban Gruin Subject: [RFC PATCH 7/9] rebase-interactive: todo_list_check() also uses the done list Date: Wed, 17 Jul 2019 16:39:16 +0200 Message-Id: <20190717143918.7406-8-alban.gruin@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190717143918.7406-1-alban.gruin@gmail.com> References: <20190717143918.7406-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 todo_list_check() works by checking if every commit in old_todo (the backup list) is also present in new_todo (the todo list to check). This works only when no commits have been picked (ie. right after the initial edit). In other cases, the backup list will contain one or several commits that have been applied and are no longer in the todo list. Let's take this todo list, for instance: pick 123abc An interesting change break pick cba321 A boring change After executing the `break' command, the backup list will contain the original todo list, while the todo list will only contain the last `pick' insn. Even if commit 123abc has been picked up, in this case, todo_list_check() will fail because it is not part of the todo list. There is another list containing every command that have been executed: the "done" list. In our example, after the `break' command, the "done" list will contain the first commit (123abc). Comparing the backup list against the todo list and the done list will fix this problem. This changes todo_list_check() to compare old_todo against new_todo _and_ the done list. This should be useful to check the todo list when resuming a rebase or reloading the todo list after an `exec' command, but not for `--edit-todo' (the todo list is copied before edition). But, for the sake of safety, it is still done in the next commit. This also adds a function, todo_list_check_against_backup(), to load the done list and the backup list, and call todo_list_check(). Signed-off-by: Alban Gruin --- rebase-interactive.c | 57 ++++++++++++++++++++++++++++++++++++++------ rebase-interactive.h | 6 ++++- sequencer.c | 4 ++-- 3 files changed, 57 insertions(+), 10 deletions(-) diff --git a/rebase-interactive.c b/rebase-interactive.c index aa18ae82b7..c7dea85553 100644 --- a/rebase-interactive.c +++ b/rebase-interactive.c @@ -6,6 +6,8 @@ #include "commit-slab.h" #include "config.h" +static GIT_PATH_FUNC(rebase_path_done, "rebase-merge/done") + enum missing_commit_check_level { MISSING_COMMIT_CHECK_IGNORE = 0, MISSING_COMMIT_CHECK_WARN, @@ -124,13 +126,27 @@ int edit_todo_list(struct repository *r, struct todo_list *todo_list, } define_commit_slab(commit_seen, unsigned char); + +static void mark_commits_as_seen(struct commit_seen *commit_seen, + struct todo_list *list) +{ + int i; + + for (i = 0; i < list->nr; i++) { + struct commit *commit = list->items[i].commit; + if (commit) + *commit_seen_at(commit_seen, commit) = 1; + } +} + /* * Check if the user dropped some commits by mistake * Behaviour determined by rebase.missingCommitsCheck. * Check if there is an unrecognized command or a * bad SHA-1 in a command. */ -int todo_list_check(struct todo_list *old_todo, struct todo_list *new_todo) +int todo_list_check(struct todo_list *old_todo, struct todo_list *new_todo, + struct todo_list *done) { enum missing_commit_check_level check_level = get_missing_commit_check_level(); struct strbuf missing = STRBUF_INIT; @@ -142,12 +158,11 @@ int todo_list_check(struct todo_list *old_todo, struct todo_list *new_todo) if (check_level == MISSING_COMMIT_CHECK_IGNORE) goto leave_check; - /* Mark the commits in git-rebase-todo as seen */ - for (i = 0; i < new_todo->nr; i++) { - struct commit *commit = new_todo->items[i].commit; - if (commit) - *commit_seen_at(&commit_seen, commit) = 1; - } + /* Mark the commits in git-rebase-todo and git-rebase-done as + seen */ + mark_commits_as_seen(&commit_seen, new_todo); + if (done) + mark_commits_as_seen(&commit_seen, done); /* Find commits in git-rebase-todo.backup yet unseen */ for (i = old_todo->nr - 1; i >= 0; i--) { @@ -187,3 +202,31 @@ int todo_list_check(struct todo_list *old_todo, struct todo_list *new_todo) clear_commit_seen(&commit_seen); return res; } + +int todo_list_check_against_backup(struct repository *r, + struct todo_list *todo_list) +{ + struct todo_list done = TODO_LIST_INIT, initial = TODO_LIST_INIT; + int res; + + if (strbuf_read_file(&done.buf, rebase_path_done(), 0) < 0 && errno != ENOENT) + return error(_("could not read '%s'"), rebase_path_done()); + + strbuf_read_file(&done.buf, rebase_path_done(), 0); + todo_list_parse_insn_buffer(r, done.buf.buf, &done); + + if (strbuf_read_file(&initial.buf, rebase_path_todo_backup(), 0) < 0 && + errno != ENOENT) { + todo_list_release(&done); + return error(_("could not read '%s'"), rebase_path_done()); + } + + todo_list_parse_insn_buffer(r, initial.buf.buf, &initial); + + res = todo_list_check(&initial, todo_list, &done); + + todo_list_release(&done); + todo_list_release(&initial); + + return res; +} diff --git a/rebase-interactive.h b/rebase-interactive.h index 44dbb06311..ac401cda25 100644 --- a/rebase-interactive.h +++ b/rebase-interactive.h @@ -11,6 +11,10 @@ void append_todo_help(unsigned keep_empty, int command_count, int edit_todo_list(struct repository *r, struct todo_list *todo_list, struct todo_list *new_todo, const char *shortrevisions, const char *shortonto, unsigned flags); -int todo_list_check(struct todo_list *old_todo, struct todo_list *new_todo); + +int todo_list_check(struct todo_list *old_todo, struct todo_list *new_todo, + struct todo_list *done); +int todo_list_check_against_backup(struct repository *r, + struct todo_list *todo_list); #endif diff --git a/sequencer.c b/sequencer.c index 3fb15ff8d9..0638c92f12 100644 --- a/sequencer.c +++ b/sequencer.c @@ -4898,7 +4898,7 @@ int check_todo_list_from_file(struct repository *r) if (!res) res = todo_list_parse_insn_buffer(r, new_todo.buf.buf, &new_todo); if (!res) - res = todo_list_check(&old_todo, &new_todo); + res = todo_list_check(&old_todo, &new_todo, NULL); if (res) fprintf(stderr, _(edit_todo_list_advice)); out: @@ -5008,7 +5008,7 @@ int complete_action(struct repository *r, struct replay_opts *opts, unsigned fla } if (todo_list_parse_insn_buffer(r, new_todo.buf.buf, &new_todo) || - todo_list_check(todo_list, &new_todo)) { + todo_list_check(todo_list, &new_todo, NULL)) { fprintf(stderr, _(edit_todo_list_advice)); checkout_onto(r, opts, onto_name, &onto->object.oid, orig_head); todo_list_release(&new_todo); From patchwork Wed Jul 17 14:39:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alban Gruin X-Patchwork-Id: 11048005 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 7EC201510 for ; Wed, 17 Jul 2019 14:42:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6D4CA287C2 for ; Wed, 17 Jul 2019 14:42:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 61CBB287CF; Wed, 17 Jul 2019 14:42:10 +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 19450287C2 for ; Wed, 17 Jul 2019 14:42:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727594AbfGQOmJ (ORCPT ); Wed, 17 Jul 2019 10:42:09 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:56199 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726452AbfGQOmI (ORCPT ); Wed, 17 Jul 2019 10:42:08 -0400 Received: by mail-wm1-f66.google.com with SMTP id a15so22425573wmj.5 for ; Wed, 17 Jul 2019 07:42:06 -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=rfshZRPLJED8TsMTWY3ns+QjCQKe0FXzyXfPXOtu4c0=; b=iah95mnMR8S8pkbIMgFl5zLuhBD+szz7riSiqdCnRc+XCoxgLlDazjYW8Cpvkxb5y2 MXnjbxm25P46RDOcUV3/jqxyua9r/XBe5y72NdXot0cLIh4UktLrcljFl5gZZzSt3wua J5kUg5T9xtF/goDiyeA8P3ygTJzLZ8Mhn/i7IzW2LnVG7BW2RbQszY1mOxvEvqZ65T6m mpPW044NG0uQqSeWyTidwKOk55wdnSiKa40xnIZTZwEYyT/B4Gdrp5U9EWfCzAgux3ZK CL+/sYYeDNWf0Bc3AVLhPt6PJRwovImS/8ibDG73dD2fRUL82ovupw/qYOhKHfPYrNgb b/KA== 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=rfshZRPLJED8TsMTWY3ns+QjCQKe0FXzyXfPXOtu4c0=; b=N1j3IwXp21D8PF6gJiJQ+CvzAHhzz5KLJyMVAvIaFVX9zmlR5k0pcUgTSlldnI83FJ yoW9aGiNJA0akv8Alb/k16z/IvOQ5PGrBXb7ozrYYgIx+6W/QS7FNij8r12/uE/uy4jV a7VPxr4C6sUaz+CeHpyQAX/nOFCQ3YOGjRNcR5Mu6Dq2HtQ/XFG3tfXH4KHzSEJ14JRo f8qdGZAoA3gQrljut80n/0MyBHD31Oeqj5e9uWTCwWWOJCEhbyew26gKZLbmEdmb1a1Y 55uJojOS6CCeHMRSTLycOa+14FwuqTgp4mpztE9Ya6dok129PW9HgKN1LVWrFEgHTdQV Afww== X-Gm-Message-State: APjAAAVpl+MyHRVCHrukvFh7M1rnZWrT85HBIYQ8gh0cXrc+kHl1YBYn pKSBjQjw0UwUl8oBt5ioSlp5hlDW X-Google-Smtp-Source: APXvYqxsKfDPGRytBZrmN2zWgOZFGvda/llZ8gp4ayOT5d/oj954uyn/yeZDXeGqq/kzORY7fuRw4A== X-Received: by 2002:a1c:2e09:: with SMTP id u9mr37272427wmu.137.1563374525802; Wed, 17 Jul 2019 07:42:05 -0700 (PDT) Received: from localhost.localdomain (atoulouse-658-1-183-65.w86-199.abo.wanadoo.fr. [86.199.38.65]) by smtp.googlemail.com with ESMTPSA id p18sm21815968wrm.16.2019.07.17.07.42.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Jul 2019 07:42:05 -0700 (PDT) From: Alban Gruin To: git@vger.kernel.org Cc: Johannes Schindelin , Phillip Wood , Alban Gruin Subject: [RFC PATCH 8/9] rebase-interactive: warn if commit is dropped with --edit-todo Date: Wed, 17 Jul 2019 16:39:17 +0200 Message-Id: <20190717143918.7406-9-alban.gruin@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190717143918.7406-1-alban.gruin@gmail.com> References: <20190717143918.7406-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 adds the ability for --edit-todo to check if commits were dropped by the user using todo_list_check_against_backup(). Signed-off-by: Alban Gruin --- rebase-interactive.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/rebase-interactive.c b/rebase-interactive.c index c7dea85553..c346d4ced4 100644 --- a/rebase-interactive.c +++ b/rebase-interactive.c @@ -95,6 +95,7 @@ int edit_todo_list(struct repository *r, struct todo_list *todo_list, { const char *todo_file = rebase_path_todo(); unsigned initial = shortrevisions && shortonto; + int res = 0; /* If the user is editing the todo list, we first try to parse * it. If there is an error, we do not return, because the user @@ -119,10 +120,13 @@ int edit_todo_list(struct repository *r, struct todo_list *todo_list, /* For the initial edit, the todo list gets parsed in * complete_action(). */ - if (!initial) - return todo_list_parse_insn_buffer(r, new_todo->buf.buf, new_todo); + if (!initial) { + res = todo_list_parse_insn_buffer(r, new_todo->buf.buf, new_todo); + if (!res) + res = todo_list_check_against_backup(r, new_todo); + } - return 0; + return res; } define_commit_slab(commit_seen, unsigned char); From patchwork Wed Jul 17 14:39:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alban Gruin X-Patchwork-Id: 11048007 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 ABD9E13BD for ; Wed, 17 Jul 2019 14:42:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9BA5328714 for ; Wed, 17 Jul 2019 14:42:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8D0BE2871E; Wed, 17 Jul 2019 14:42:11 +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 2BECE287BF for ; Wed, 17 Jul 2019 14:42:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727661AbfGQOmK (ORCPT ); Wed, 17 Jul 2019 10:42:10 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:54492 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727456AbfGQOmJ (ORCPT ); Wed, 17 Jul 2019 10:42:09 -0400 Received: by mail-wm1-f67.google.com with SMTP id p74so22416807wme.4 for ; Wed, 17 Jul 2019 07:42:08 -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=zKSBIwbiUSn2bZIJ1EMlrqfHiGBPqFZIqAghIfHxVCY=; b=k4iqJJh/doJ3hMwQ1zI+Y8MlPn7wOXX8aXQb17yUhOqlsxEs/CDSYA/pwp36Eo9bhQ G5ZhqaUkES6NYS3L16WrOfNzpus0p34RThrAK0V5qyhZz09tXFqWDmxWBALJK3TmfNM7 NWGCE4geJtzIXeEwDVoRxOMWJa9hYe8cq9RERMjZGHxBxHNHY7QJSx7LiR++Ww1QJiYW RtLTl5rNswmN0IrXnbdefJABy2qXW387SpBC4cK5YY3N/TIw1NXpFFrwElNg3GuPQ8uF hR8Ea021APY93DLO6Kb3OoPOTvNoeuq7O/ErLPB1QS8FbDOYrgO5F2OcolB10f+ySKX2 U7FA== 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=zKSBIwbiUSn2bZIJ1EMlrqfHiGBPqFZIqAghIfHxVCY=; b=pXf3daSHk5c34Zeomn+ekjODXcg41q7sEi32uebQsS3t6pnZuMTLd+8LrGBJM+4O9q ov3MxnG4G6P8H0sSftmDmYstZKY/kcjWi+3pY57v3Kh/P0XHdnBXy2wm4Zt/5UgQe0GD C+chviGLJcJDMuqXJYY94t3zyEDC/vwuUWBLhzjWqwf3Ue4LCk02mgGXZZNnvjw6IbiL /VU803vM/GTlxkZ5853nvk+7LRikx6dWZm7HUNryQ0Dinc3QRiyM3aQ604bCXD9Nu0rj JW0b6f+iGHJVh4xgJJ7c1nmJp1DLm+POsADVOtMcYqU9x7pPV3OOwmmm5sp3JzfM2qDq C3MQ== X-Gm-Message-State: APjAAAXJD+eBwr63TX/zonbTamKvprUDB1XYk6QG286ClcaVZkSdnzRF bmPaGhfdGNsla7WWsyw6UFTEM6ka X-Google-Smtp-Source: APXvYqwkCqjWIJGkhxdPBpVOGCauGy3KPdokPOqhmnPQvbzeftRPw/zeS5ds/mbmmR/LdE2yeOQGVQ== X-Received: by 2002:a05:600c:2243:: with SMTP id a3mr35678995wmm.83.1563374527403; Wed, 17 Jul 2019 07:42:07 -0700 (PDT) Received: from localhost.localdomain (atoulouse-658-1-183-65.w86-199.abo.wanadoo.fr. [86.199.38.65]) by smtp.googlemail.com with ESMTPSA id p18sm21815968wrm.16.2019.07.17.07.42.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Jul 2019 07:42:06 -0700 (PDT) From: Alban Gruin To: git@vger.kernel.org Cc: Johannes Schindelin , Phillip Wood , Alban Gruin Subject: [RFC PATCH 9/9] sequencer: have read_populate_todo() check for dropped commits Date: Wed, 17 Jul 2019 16:39:18 +0200 Message-Id: <20190717143918.7406-10-alban.gruin@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190717143918.7406-1-alban.gruin@gmail.com> References: <20190717143918.7406-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 adds the ability to check if commits were dropped when resuming a rebase (with `--continue') or when reloading the todo list after an `exec' command. Tests added previously should work now. Signed-off-by: Alban Gruin --- sequencer.c | 5 ++++- t/t3404-rebase-interactive.sh | 4 ++-- t/t3429-rebase-edit-todo.sh | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/sequencer.c b/sequencer.c index 0638c92f12..d2c4459e7c 100644 --- a/sequencer.c +++ b/sequencer.c @@ -2360,7 +2360,6 @@ static int read_populate_todo(struct repository *r, struct stat st; const char *todo_file = get_todo_path(opts); int res; - strbuf_reset(&todo_list->buf); if (strbuf_read_file_or_whine(&todo_list->buf, todo_file) < 0) return -1; @@ -2378,6 +2377,10 @@ static int read_populate_todo(struct repository *r, return error(_("unusable instruction sheet: '%s'"), todo_file); } + res = todo_list_check_against_backup(r, todo_list); + if (res) + return -1; + if (!todo_list->nr && (!is_rebase_i(opts) || !file_exists(rebase_path_done()))) return error(_("no commits parsed.")); diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index f5c0a8d2bb..090a496bcc 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -1373,7 +1373,7 @@ EOF tail -n 8 expect.2 -test_expect_failure 'rebase --edit-todo respects rebase.missingCommitsCheck = warn' ' +test_expect_success 'rebase --edit-todo respects rebase.missingCommitsCheck = warn' ' test_config rebase.missingCommitsCheck warn && rebase_setup_and_clean missing-commit && set_fake_editor && @@ -1405,7 +1405,7 @@ EOF tail -n 9 expect.2 -test_expect_failure 'rebase --edit-todo respects rebase.missingCommitsCheck = error' ' +test_expect_success 'rebase --edit-todo respects rebase.missingCommitsCheck = error' ' test_config rebase.missingCommitsCheck error && rebase_setup_and_clean missing-commit && set_fake_editor && diff --git a/t/t3429-rebase-edit-todo.sh b/t/t3429-rebase-edit-todo.sh index 2bb9fb65fa..79cd5657b3 100755 --- a/t/t3429-rebase-edit-todo.sh +++ b/t/t3429-rebase-edit-todo.sh @@ -50,7 +50,7 @@ Use 'git config rebase.missingCommitsCheck' to change the level of warnings. The possible behaviours are: ignore, warn, error. EOF -test_expect_failure 'rebase exec respects rebase.missingCommitsCheck = warn' ' +test_expect_success 'rebase exec respects rebase.missingCommitsCheck = warn' ' test_config rebase.missingCommitsCheck warn && git reset --hard HEAD@{2} && git rebase HEAD~2 --keep-empty -x "echo >$todo" 2>actual.2 && @@ -59,7 +59,7 @@ test_expect_failure 'rebase exec respects rebase.missingCommitsCheck = warn' ' test 5 = $(git cat-file commit HEAD | sed -ne \$p) ' -test_expect_failure 'rebase exec respects rebase.missingCommitsCheck = error' ' +test_expect_success 'rebase exec respects rebase.missingCommitsCheck = error' ' test_config rebase.missingCommitsCheck error && git reset --hard HEAD@{2} && test_must_fail git rebase HEAD~2 --keep-empty -x "echo >$todo" 2>actual.2 &&