From patchwork Sun Jun 23 20:03:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rohit Ashiwal X-Patchwork-Id: 11011929 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 C55EE1908 for ; Sun, 23 Jun 2019 20:06:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B4996289E5 for ; Sun, 23 Jun 2019 20:06:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A93F828560; Sun, 23 Jun 2019 20:06:23 +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 68B6C289E5 for ; Sun, 23 Jun 2019 20:06:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726368AbfFWUGE (ORCPT ); Sun, 23 Jun 2019 16:06:04 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:33591 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726285AbfFWUGE (ORCPT ); Sun, 23 Jun 2019 16:06:04 -0400 Received: by mail-pf1-f194.google.com with SMTP id x15so6268766pfq.0 for ; Sun, 23 Jun 2019 13:06:04 -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=wfwetWPcY0ifTB5OqiiOsCs1cIb+E7JAq6rJrad6EzI=; b=Vf0qYxdp9bd5OQynp4geN+1xOUwQgPz1BwGQgNJTmsnj+pCpDKgH7dwO0sYjQQxGdi 3fEM4EVdvpxhXjTlY6JeOaO4P8CubXJRvy+fMKenAtzlE3s6rm0lUCCs/m4vrgj4O8r0 tzaUkTXsv1oJTeSFgC3VPn7TDs6pk+hFdIsUOFRFS5o8GtDoJMtXL8UMUHiblRmrvfba dPAL4VcSCXdKRYagpbQEHkqJzVTfoubXN0Sd9IWkQogVKXf6wVShdDSBfUaptmvlPITQ gk8XoUMmuel9SHG4gs2+dI3ieb+21wvlr5M2t4nW6BaWK5PzuVri858QFWgSxpvkydKu AJCA== 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=wfwetWPcY0ifTB5OqiiOsCs1cIb+E7JAq6rJrad6EzI=; b=al3OO4STZo8SM3w1ZTHv+9yxOJaNzd0Q7Llk+51rO2a/bGul9IkqfIaGuPYb614hTH vLmifSshPWbyDLtt2xhtmeeNFxoIsaEVLnoDmvEj8VC5OEz+lzuY3dYh1AoeM+M8iv1n nVSKV7RTgN7oNBTrvF3ERNcsAEeGOrvnCIY+jLBOxSt0+oxv1FDYxi9Qm0YU98Al2g5t pdC2U4D/QC9LeV/bd3uBvCQbMFGbJgxmsTx6RqJpyVBxgAC9CTU3RMKa8viqs1BYULqt k0RpqDbIixqqS6946Ku2/ZDple5JwNSi3w60GcSVpitKKCN75e8ajGZRtmSPDecucuRZ 4omw== X-Gm-Message-State: APjAAAU7YzH4iEtNTIqrBcFzbSPbHYT9jrOdYKppczgyL+nOqOZfIJqm CJp+a6WlXNhREQVx9FDAyL8DZzzHQbo= X-Google-Smtp-Source: APXvYqwwa7EvesFy/UQkzkKbVJ0neSoT/9gzEHbaHxhVg51PGKGRZ2WUFBkSJfIMop1PDoajDzYQDw== X-Received: by 2002:a63:de50:: with SMTP id y16mr12965141pgi.431.1561320363479; Sun, 23 Jun 2019 13:06:03 -0700 (PDT) Received: from ar135.iitr.ac.in ([103.37.200.213]) by smtp.gmail.com with ESMTPSA id 27sm8621882pgt.6.2019.06.23.13.05.59 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 23 Jun 2019 13:06:02 -0700 (PDT) From: Rohit Ashiwal To: rohit.ashiwal265@gmail.com Cc: git@vger.kernel.org, newren@gmail.com, t.gummerer@gmail.com, phillip.wood123@gmail.com, gitster@pobox.com, martin.agren@gmail.com Subject: [GSoC][PATCH v7 1/6] advice: add sequencerInUse config variable Date: Mon, 24 Jun 2019 01:33:33 +0530 Message-Id: <20190623200338.17144-2-rohit.ashiwal265@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190623200338.17144-1-rohit.ashiwal265@gmail.com> References: <20190608191958.4593-1-rohit.ashiwal265@gmail.com> <20190623200338.17144-1-rohit.ashiwal265@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 Calls to advise() which are not guarded by advice.* config variables are "bad" as they do not let the user say, "I've learned this part of Git enough, please don't tell me what to do verbosely.". Add a configuration variable "sequencerInUse" which controls whether to display advice when any sequencer command is in progress. Signed-off-by: Rohit Ashiwal --- Documentation/config/advice.txt | 2 ++ advice.c | 2 ++ advice.h | 1 + 3 files changed, 5 insertions(+) diff --git a/Documentation/config/advice.txt b/Documentation/config/advice.txt index ec4f6ae658..1cd9096c98 100644 --- a/Documentation/config/advice.txt +++ b/Documentation/config/advice.txt @@ -57,6 +57,8 @@ advice.*:: resolveConflict:: Advice shown by various commands when conflicts prevent the operation from being performed. + sequencerInUse:: + Advice shown when a sequencer command is already in progress. implicitIdentity:: Advice on how to set your identity configuration when your information is guessed from the system username and diff --git a/advice.c b/advice.c index ce5f374ecd..b101f0c264 100644 --- a/advice.c +++ b/advice.c @@ -15,6 +15,7 @@ int advice_status_u_option = 1; int advice_commit_before_merge = 1; int advice_reset_quiet_warning = 1; int advice_resolve_conflict = 1; +int advice_sequencer_in_use = 1; int advice_implicit_identity = 1; int advice_detached_head = 1; int advice_set_upstream_failure = 1; @@ -71,6 +72,7 @@ static struct { { "commitBeforeMerge", &advice_commit_before_merge }, { "resetQuiet", &advice_reset_quiet_warning }, { "resolveConflict", &advice_resolve_conflict }, + { "sequencerInUse", &advice_sequencer_in_use }, { "implicitIdentity", &advice_implicit_identity }, { "detachedHead", &advice_detached_head }, { "setupStreamFailure", &advice_set_upstream_failure }, diff --git a/advice.h b/advice.h index e50f02cdfe..ebc838d7bc 100644 --- a/advice.h +++ b/advice.h @@ -15,6 +15,7 @@ extern int advice_status_u_option; extern int advice_commit_before_merge; extern int advice_reset_quiet_warning; extern int advice_resolve_conflict; +extern int advice_sequencer_in_use; extern int advice_implicit_identity; extern int advice_detached_head; extern int advice_set_upstream_failure; From patchwork Sun Jun 23 20:03:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rohit Ashiwal X-Patchwork-Id: 11011921 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 2A14613AF for ; Sun, 23 Jun 2019 20:06:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1CCFB28ABE for ; Sun, 23 Jun 2019 20:06:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 108DB28AD1; Sun, 23 Jun 2019 20:06:23 +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 8817D28ABE for ; Sun, 23 Jun 2019 20:06:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726369AbfFWUGH (ORCPT ); Sun, 23 Jun 2019 16:06:07 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:35352 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726285AbfFWUGH (ORCPT ); Sun, 23 Jun 2019 16:06:07 -0400 Received: by mail-pg1-f196.google.com with SMTP id s27so5930813pgl.2 for ; Sun, 23 Jun 2019 13:06:07 -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=8YQUHvJD4DvbM6l96Vp9ZUv5oAEHyEStYs69WrbSj/Q=; b=mwKIrAQeQZHhCjTqY6kA6OW8ywBxMQswshw05sDtvwJhjWC4qYF5nvW+jZ1G/c6Sfq Ki1KkZy05WNy+dhKUMO8TaGU1cXV6zXVZGCbiU6NKb5x4FtwSnrtTDKBIDNw+XzmRmhw SR3mmX9vlXn/1ZABkasvHuap8B+HnF/HabRTkxGhjLoIPdwHKUjqEcb9BdUYnVwfmdVI KEhZl3+Zgo7mYh+rbDU71KXFIF3Pcf3mbTUUZPkkwRzpa63bcC49UeBm801n2D4hy6XL XpzFSbk77kOEs3IuptHKF4zLogb14vlE92p7GWcXoghBRGJGp0KQEFEraE0BLl/Yn+kQ wpbA== 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=8YQUHvJD4DvbM6l96Vp9ZUv5oAEHyEStYs69WrbSj/Q=; b=LPeRw0Km8g04Ya30BplTQGZzy/vjdC14N9i3UpQKYOHX3DYEGRKRUK0Nh/5xs1Zv78 PVXiI499Enxsz9h1gYqsA3ONmluEC4MYadlLTK5+mkEN4IcGcbgnIA9TZ/6iiojmZfvC QYhhnVB4RByXDEEVvMOuSVrZRb+uPnd/dcdzMhjXJXzXtGGuWj9VMVZ7xNlfn9FW1zZJ twZ8wmEle3xuQm5hnINeg9Mo+GBaeO2xK8xSh/DMx2vOL2kN8QuJsXGn6zX1ELt0vdPx 7zI58RIeN1ST8XRSv0O6RcdgDOod5JtP7d0AQ9FbUFnQyb3G38NvHCfp1oCq068TMotR gtPw== X-Gm-Message-State: APjAAAX5JGScf0TtHGaa6+m0o1k0jsfU1SPv76ka1+21+a2YmJSsQvIS w0fVqRLGkagZbZvFdy3VA+ZgbgW1DfA= X-Google-Smtp-Source: APXvYqxoDT9ciEbEQlLwOA8MadjXAXPj07u9hMPY5KwPLPeBRZIk2KwpFHmO5caPfgDHiGZ63tDW7g== X-Received: by 2002:a17:90a:bc0c:: with SMTP id w12mr19348604pjr.111.1561320366826; Sun, 23 Jun 2019 13:06:06 -0700 (PDT) Received: from ar135.iitr.ac.in ([103.37.200.213]) by smtp.gmail.com with ESMTPSA id 27sm8621882pgt.6.2019.06.23.13.06.03 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 23 Jun 2019 13:06:06 -0700 (PDT) From: Rohit Ashiwal To: rohit.ashiwal265@gmail.com Cc: git@vger.kernel.org, newren@gmail.com, t.gummerer@gmail.com, phillip.wood123@gmail.com, gitster@pobox.com, martin.agren@gmail.com Subject: [GSoC][PATCH v7 2/6] sequencer: add advice for revert Date: Mon, 24 Jun 2019 01:33:34 +0530 Message-Id: <20190623200338.17144-3-rohit.ashiwal265@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190623200338.17144-1-rohit.ashiwal265@gmail.com> References: <20190608191958.4593-1-rohit.ashiwal265@gmail.com> <20190623200338.17144-1-rohit.ashiwal265@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 the case of merge conflicts, while performing a revert, we are currently advised to use `git cherry-pick --` of which --continue is incompatible for continuing the revert. Introduce a separate advice message for `git revert`. Also change the signature of `create_seq_dir` to handle which advice to display selectively. Signed-off-by: Rohit Ashiwal --- sequencer.c | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/sequencer.c b/sequencer.c index f88a97fb10..0ef2622a69 100644 --- a/sequencer.c +++ b/sequencer.c @@ -2650,15 +2650,38 @@ static int walk_revs_populate_todo(struct todo_list *todo_list, return 0; } -static int create_seq_dir(void) +static int create_seq_dir(struct repository *r) { - if (file_exists(git_path_seq_dir())) { - error(_("a cherry-pick or revert is already in progress")); - advise(_("try \"git cherry-pick (--continue | --quit | --abort)\"")); + enum replay_action action; + const char *in_progress_error = NULL; + const char *in_progress_advice = NULL; + + if (!sequencer_get_last_command(r, &action)) { + switch (action) { + case REPLAY_REVERT: + in_progress_error = _("revert is already in progress"); + in_progress_advice = + _("try \"git revert (--continue | --abort | --quit)\""); + break; + case REPLAY_PICK: + in_progress_error = _("cherry-pick is already in progress"); + in_progress_advice = + _("try \"git cherry-pick (--continue | --abort | --quit)\""); + break; + default: + BUG("unexpected action in create_seq_dir"); + } + } + if (in_progress_error) { + error("%s", in_progress_error); + if (advice_sequencer_in_use) + advise("%s", in_progress_advice); return -1; - } else if (mkdir(git_path_seq_dir(), 0777) < 0) + } + if (mkdir(git_path_seq_dir(), 0777) < 0) return error_errno(_("could not create sequencer directory '%s'"), git_path_seq_dir()); + return 0; } @@ -4237,7 +4260,7 @@ int sequencer_pick_revisions(struct repository *r, */ if (walk_revs_populate_todo(&todo_list, opts) || - create_seq_dir() < 0) + create_seq_dir(r) < 0) return -1; if (get_oid("HEAD", &oid) && (opts->action == REPLAY_REVERT)) return error(_("can't revert as initial commit")); From patchwork Sun Jun 23 20:03:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rohit Ashiwal X-Patchwork-Id: 11011925 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 76632186E for ; Sun, 23 Jun 2019 20:06:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 698FB28560 for ; Sun, 23 Jun 2019 20:06:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5740C28AC4; Sun, 23 Jun 2019 20:06:23 +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 D156628560 for ; Sun, 23 Jun 2019 20:06:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726393AbfFWUGO (ORCPT ); Sun, 23 Jun 2019 16:06:14 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:46988 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726285AbfFWUGO (ORCPT ); Sun, 23 Jun 2019 16:06:14 -0400 Received: by mail-pl1-f195.google.com with SMTP id e5so5623311pls.13 for ; Sun, 23 Jun 2019 13:06:13 -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=sjxQC9ExWqlfRwxfY1lcZGsCIZu7g+wklshVn6nyRpc=; b=T9AWf9QIoczWH0mESNuzzInPqBCMzLIVUhyw+LiuGFicVgECxpeU3BGklVEbbd95lp q/vOiH2GpmQcpLAIAhdLmyNno/lCw8sKmcvvj+k9xe8UFdokKHHilNLAROX8vCPa8Cq4 4HQkSBafHYneh5v1u4s+QQ0lecxrAKhMrLyENv/Kik4PKkk16eONbp0JRKHTZ6yRZ+yt NYycy0KOE2iRcgBNBwcT4MvAiDBBQdAaNBeVpuz/ByGjetCHR7YR8J7NsegVMvUrEgEk eMUzF7MBPhAjc3640ZVGU53dtjbcJEM8rYVpL/3DPjGuh+H1ZScAqQd73rdga3ruKElp vUOg== 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=sjxQC9ExWqlfRwxfY1lcZGsCIZu7g+wklshVn6nyRpc=; b=h9hEnyKuyjPiROBLxepEMqxxbVCPrLXcJqMlOptI8CgDEvZTpnOtMsdN6N+O1V7WlW yS/HU1HYMOdAIclW6CQ/Nphmhl15fvAr8hpRAS3xQ4O3QRj2U83eSebOMyjH6uL+PQs3 R32aAfPi+7yTSy5bZxdlmwVR1zy7/kw9vSUNwX6ACYs2ls2KcDmxG6PDW29pA6qoWl9C Yk65l4+JjfXwGYE//v3Lr2mWMX8OD4YAUlI4fvgeZEPMRS8ReHVUj/iAzdWIH8Gvpd93 UuzLB4HxIR0w7QuKFBJzTILZmgkYYLEZVIEEUD6x5w0lrZmTseYe+qW+Gdr2BKzQ/7k1 UF6g== X-Gm-Message-State: APjAAAUcVoF3FVzB5zpx8PqkZXo5B3d5QZ8DH5hZ63vzcYXJtD5do9Jt su6HAqGeqjiDuB3MOAZjil73ossVn2k= X-Google-Smtp-Source: APXvYqxBypN1w81s1wRTTbzq6kr7mtA8p7gILrRsapvNOKz2JJmHN5mk6gWntLLTDlZGMjxEIimu6g== X-Received: by 2002:a17:902:aa83:: with SMTP id d3mr119114150plr.74.1561320373321; Sun, 23 Jun 2019 13:06:13 -0700 (PDT) Received: from ar135.iitr.ac.in ([103.37.200.213]) by smtp.gmail.com with ESMTPSA id 27sm8621882pgt.6.2019.06.23.13.06.10 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 23 Jun 2019 13:06:12 -0700 (PDT) From: Rohit Ashiwal To: rohit.ashiwal265@gmail.com Cc: git@vger.kernel.org, newren@gmail.com, t.gummerer@gmail.com, phillip.wood123@gmail.com, gitster@pobox.com, martin.agren@gmail.com Subject: [GSoC][PATCH v7 4/6] sequencer: use argv_array in reset_merge Date: Mon, 24 Jun 2019 01:33:36 +0530 Message-Id: <20190623200338.17144-5-rohit.ashiwal265@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190623200338.17144-1-rohit.ashiwal265@gmail.com> References: <20190608191958.4593-1-rohit.ashiwal265@gmail.com> <20190623200338.17144-1-rohit.ashiwal265@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 Avoid using magic numbers for array size and index under `reset_merge` function. Use `argv_array` instead. This will make code shorter and easier to extend. Signed-off-by: Rohit Ashiwal --- sequencer.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/sequencer.c b/sequencer.c index cb856bcfc3..70efe36ee8 100644 --- a/sequencer.c +++ b/sequencer.c @@ -2734,13 +2734,18 @@ static int rollback_is_safe(void) static int reset_merge(const struct object_id *oid) { - const char *argv[4]; /* reset --merge + NULL */ + int ret; + struct argv_array argv = ARGV_ARRAY_INIT; - argv[0] = "reset"; - argv[1] = "--merge"; - argv[2] = oid_to_hex(oid); - argv[3] = NULL; - return run_command_v_opt(argv, RUN_GIT_CMD); + argv_array_pushl(&argv, "reset", "--merge", NULL); + + if (!is_null_oid(oid)) + argv_array_push(&argv, oid_to_hex(oid)); + + ret = run_command_v_opt(argv.argv, RUN_GIT_CMD); + argv_array_clear(&argv); + + return ret; } static int rollback_single_pick(struct repository *r) From patchwork Sun Jun 23 20:03:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rohit Ashiwal X-Patchwork-Id: 11011931 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 F0A90299D for ; Sun, 23 Jun 2019 20:06:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DFEEE28560 for ; Sun, 23 Jun 2019 20:06:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D3E22289E5; Sun, 23 Jun 2019 20:06:23 +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 F164228AC8 for ; Sun, 23 Jun 2019 20:06:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726401AbfFWUGS (ORCPT ); Sun, 23 Jun 2019 16:06:18 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:45490 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726285AbfFWUGR (ORCPT ); Sun, 23 Jun 2019 16:06:17 -0400 Received: by mail-pl1-f193.google.com with SMTP id bi6so5633254plb.12 for ; Sun, 23 Jun 2019 13:06:17 -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=7y/kL5Nok/GYir2EOd9bxMuhqFh5Z185neSHy7az5fM=; b=CZ8s7vkaee8JEgIW3oSxmu4D6LQbvDU9g2IdNgZinTbMIY9aHFc33xNzgFy1Gbc926 S+2+Y1OsJ/HvCbyM9E6FXpgAAom/2SkAcJYjXR7BLFBCCJEVNAq66asmuY1pO50wozQM 6wS0NJRkXwhL5sE0QHBGODlPREAm1EAV+36Ley2NVqzEND8enDYqFh9e7CQJmIRSdu+a c+VGzqrOWpkAnN1gSWgr0vgFUYnBqSGO6LadS60zmRBvH+8Xp3NavB2QjPcNSqnjpJ6Y sGpls4+dnyqtfxFZhooawEO7GZ+FY0qfboF8jMWTTSD5ND5SrbkKosym2Gg30AUmD2jK r1Kg== 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=7y/kL5Nok/GYir2EOd9bxMuhqFh5Z185neSHy7az5fM=; b=ge2xhs6ufdhhTcXGlvRKiya/wTSyr8HukRElIFlTjQsXmbkoIlpXXwf0X206ElwMfA vPc7Qc1v/uMK55VDmPPjokzpZ1ZzARpyVJNd5tVZhsiyL9rDdiPvt1QPrU9jeF78NToh GRZnSeZU0slBt9E5uuDGe9Ee7OvQNI2aUP/S1i1oF26UDsF14ZmVtdHM3EhUko3SWwhK ah7Nsfm9n15Zc4zj8U/jYgCrr3dqZJ3yQMclhuIMy9xL0BEeGf2SQtTcrjgotN9esj3Q FK5WrG+xYZ5EISlU/7I0sN1bm1O1ANTgszB90Rmuaw4O9gBZIqgdL4Mam0AutRai1ens Ncag== X-Gm-Message-State: APjAAAWLSnvEXMizlzznrkGT8Hdv7qL5aaffba00fg8QXlJ91zaWhDbc Uf1qGtrMLl9NcK+myQp/v80= X-Google-Smtp-Source: APXvYqzqM6w09tqVUs+J3QtwgM7MvcsZfrjokfCUgYn1QCXYHE7kpdipPh8tkoiHLUEVBpUE0a1Y2w== X-Received: by 2002:a17:902:aa41:: with SMTP id c1mr3132830plr.201.1561320376687; Sun, 23 Jun 2019 13:06:16 -0700 (PDT) Received: from ar135.iitr.ac.in ([103.37.200.213]) by smtp.gmail.com with ESMTPSA id 27sm8621882pgt.6.2019.06.23.13.06.13 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 23 Jun 2019 13:06:15 -0700 (PDT) From: Rohit Ashiwal To: rohit.ashiwal265@gmail.com Cc: git@vger.kernel.org, newren@gmail.com, t.gummerer@gmail.com, phillip.wood123@gmail.com, gitster@pobox.com, martin.agren@gmail.com Subject: [GSoC][PATCH v7 5/6] cherry-pick/revert: add --skip option Date: Mon, 24 Jun 2019 01:33:37 +0530 Message-Id: <20190623200338.17144-6-rohit.ashiwal265@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190623200338.17144-1-rohit.ashiwal265@gmail.com> References: <20190608191958.4593-1-rohit.ashiwal265@gmail.com> <20190623200338.17144-1-rohit.ashiwal265@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 git am or rebase have a --skip flag to skip the current commit if the user wishes to do so. During a cherry-pick or revert a user could likewise skip a commit, but needs to use 'git reset' (or in the case of conflicts 'git reset --merge'), followed by 'git (cherry-pick | revert) --continue' to skip the commit. This is more annoying and sometimes confusing on the users' part. Add a `--skip` option to make skipping commits easier for the user and to make the commands more consistent. In the next commit, we will change the advice messages hence finishing the process of teaching revert and cherry-pick "how to skip commits". Signed-off-by: Rohit Ashiwal --- Documentation/git-cherry-pick.txt | 4 +- Documentation/git-revert.txt | 4 +- Documentation/sequencer.txt | 4 ++ builtin/revert.c | 5 ++ sequencer.c | 73 +++++++++++++++++++++ sequencer.h | 1 + t/t3510-cherry-pick-sequence.sh | 102 ++++++++++++++++++++++++++++++ 7 files changed, 187 insertions(+), 6 deletions(-) diff --git a/Documentation/git-cherry-pick.txt b/Documentation/git-cherry-pick.txt index 754b16ce0c..83ce51aedf 100644 --- a/Documentation/git-cherry-pick.txt +++ b/Documentation/git-cherry-pick.txt @@ -10,9 +10,7 @@ SYNOPSIS [verse] 'git cherry-pick' [--edit] [-n] [-m parent-number] [-s] [-x] [--ff] [-S[]] ... -'git cherry-pick' --continue -'git cherry-pick' --quit -'git cherry-pick' --abort +'git cherry-pick' (--continue | --skip | --abort | --quit) DESCRIPTION ----------- diff --git a/Documentation/git-revert.txt b/Documentation/git-revert.txt index 0c82ca5bc0..665e065ee3 100644 --- a/Documentation/git-revert.txt +++ b/Documentation/git-revert.txt @@ -9,9 +9,7 @@ SYNOPSIS -------- [verse] 'git revert' [--[no-]edit] [-n] [-m parent-number] [-s] [-S[]] ... -'git revert' --continue -'git revert' --quit -'git revert' --abort +'git revert' (--continue | --skip | --abort | --quit) DESCRIPTION ----------- diff --git a/Documentation/sequencer.txt b/Documentation/sequencer.txt index 5a57c4a407..3bceb56474 100644 --- a/Documentation/sequencer.txt +++ b/Documentation/sequencer.txt @@ -3,6 +3,10 @@ `.git/sequencer`. Can be used to continue after resolving conflicts in a failed cherry-pick or revert. +--skip:: + Skip the current commit and continue with the rest of the + sequence. + --quit:: Forget about the current operation in progress. Can be used to clear the sequencer state after a failed cherry-pick or diff --git a/builtin/revert.c b/builtin/revert.c index d4dcedbdc6..5dc5891ea2 100644 --- a/builtin/revert.c +++ b/builtin/revert.c @@ -102,6 +102,7 @@ static int run_sequencer(int argc, const char **argv, struct replay_opts *opts) OPT_CMDMODE(0, "quit", &cmd, N_("end revert or cherry-pick sequence"), 'q'), OPT_CMDMODE(0, "continue", &cmd, N_("resume revert or cherry-pick sequence"), 'c'), OPT_CMDMODE(0, "abort", &cmd, N_("cancel revert or cherry-pick sequence"), 'a'), + OPT_CMDMODE(0, "skip", &cmd, N_("skip current commit and continue"), 's'), OPT_CLEANUP(&cleanup_arg), OPT_BOOL('n', "no-commit", &opts->no_commit, N_("don't automatically commit")), OPT_BOOL('e', "edit", &opts->edit, N_("edit the commit message")), @@ -151,6 +152,8 @@ static int run_sequencer(int argc, const char **argv, struct replay_opts *opts) this_operation = "--quit"; else if (cmd == 'c') this_operation = "--continue"; + else if (cmd == 's') + this_operation = "--skip"; else { assert(cmd == 'a'); this_operation = "--abort"; @@ -210,6 +213,8 @@ static int run_sequencer(int argc, const char **argv, struct replay_opts *opts) return sequencer_continue(the_repository, opts); if (cmd == 'a') return sequencer_rollback(the_repository, opts); + if (cmd == 's') + return sequencer_skip(the_repository, opts); return sequencer_pick_revisions(the_repository, opts); } diff --git a/sequencer.c b/sequencer.c index 70efe36ee8..f5e3d60878 100644 --- a/sequencer.c +++ b/sequencer.c @@ -2762,6 +2762,15 @@ static int rollback_single_pick(struct repository *r) return reset_merge(&head_oid); } +static int skip_single_pick(void) +{ + struct object_id head; + + if (read_ref_full("HEAD", 0, &head, NULL)) + return error(_("cannot resolve HEAD")); + return reset_merge(&head); +} + int sequencer_rollback(struct repository *r, struct replay_opts *opts) { FILE *f; @@ -2811,6 +2820,70 @@ int sequencer_rollback(struct repository *r, struct replay_opts *opts) return -1; } +int sequencer_skip(struct repository *r, struct replay_opts *opts) +{ + enum replay_action action = -1; + sequencer_get_last_command(r, &action); + + /* + * Check whether the subcommand requested to skip the commit is actually + * in progress and that it's safe to skip the commit. + * + * opts->action tells us which subcommand requested to skip the commit. + * If the corresponding .git/_HEAD exists, we know that the + * action is in progress and we can skip the commit. + * + * Otherwise we check that the last instruction was related to the + * particular subcommand we're trying to execute and barf if that's not + * the case. + * + * Finally we check that the rollback is "safe", i.e., has the HEAD + * moved? In this case, it doesn't make sense to "reset the merge" and + * "skip the commit" as the user already handled this by committing. But + * we'd not want to barf here, instead give advice on how to proceed. We + * only need to check that when .git/_HEAD doesn't exist because + * it gets removed when the user commits, so if it still exists we're + * sure the user can't have committed before. + */ + switch (opts->action) { + case REPLAY_REVERT: + if (!file_exists(git_path_revert_head(r))) { + if (action != REPLAY_REVERT) + return error(_("no revert in progress")); + if (!rollback_is_safe()) + goto give_advice; + } + break; + case REPLAY_PICK: + if (!file_exists(git_path_cherry_pick_head(r))) { + if (action != REPLAY_PICK) + return error(_("no cherry-pick in progress")); + if (!rollback_is_safe()) + goto give_advice; + } + break; + default: + BUG("unexpected action in sequencer_skip"); + } + + if (skip_single_pick()) + return error(_("failed to skip the commit")); + if (!is_directory(git_path_seq_dir())) + return 0; + + return sequencer_continue(r, opts); + +give_advice: + error(_("there is nothing to skip")); + + if (advice_resolve_conflict) { + advise(_("have you committed already?\n" + "try \"git %s --continue\""), + action == REPLAY_REVERT ? "revert" : "cherry-pick"); + } + return -1; +} + static int save_todo(struct todo_list *todo_list, struct replay_opts *opts) { struct lock_file todo_lock = LOCK_INIT; diff --git a/sequencer.h b/sequencer.h index 0c494b83d4..731b9853eb 100644 --- a/sequencer.h +++ b/sequencer.h @@ -129,6 +129,7 @@ int sequencer_pick_revisions(struct repository *repo, struct replay_opts *opts); int sequencer_continue(struct repository *repo, struct replay_opts *opts); int sequencer_rollback(struct repository *repo, struct replay_opts *opts); +int sequencer_skip(struct repository *repo, struct replay_opts *opts); int sequencer_remove_state(struct replay_opts *opts); #define TODO_LIST_KEEP_EMPTY (1U << 0) diff --git a/t/t3510-cherry-pick-sequence.sh b/t/t3510-cherry-pick-sequence.sh index 941d5026da..20515ea37b 100755 --- a/t/t3510-cherry-pick-sequence.sh +++ b/t/t3510-cherry-pick-sequence.sh @@ -93,6 +93,108 @@ test_expect_success 'cherry-pick cleans up sequencer state upon success' ' test_path_is_missing .git/sequencer ' +test_expect_success 'cherry-pick --skip requires cherry-pick in progress' ' + pristine_detach initial && + test_must_fail git cherry-pick --skip +' + +test_expect_success 'revert --skip requires revert in progress' ' + pristine_detach initial && + test_must_fail git revert --skip +' + +test_expect_success 'cherry-pick --skip to skip commit' ' + pristine_detach initial && + test_must_fail git cherry-pick anotherpick && + test_must_fail git revert --skip && + git cherry-pick --skip && + test_cmp_rev initial HEAD && + test_path_is_missing .git/CHERRY_PICK_HEAD +' + +test_expect_success 'revert --skip to skip commit' ' + pristine_detach anotherpick && + test_must_fail git revert anotherpick~1 && + test_must_fail git cherry-pick --skip && + git revert --skip && + test_cmp_rev anotherpick HEAD +' + +test_expect_success 'skip "empty" commit' ' + pristine_detach picked && + test_commit dummy foo d && + test_must_fail git cherry-pick anotherpick && + git cherry-pick --skip && + test_cmp_rev dummy HEAD +' + +test_expect_success 'skip a commit and check if rest of sequence is correct' ' + pristine_detach initial && + echo e >expect && + cat >expect.log <<-EOF && + OBJID + :100644 100644 OBJID OBJID M foo + OBJID + :100644 100644 OBJID OBJID M foo + OBJID + :100644 100644 OBJID OBJID M unrelated + OBJID + :000000 100644 OBJID OBJID A foo + :000000 100644 OBJID OBJID A unrelated + EOF + test_must_fail git cherry-pick base..yetanotherpick && + test_must_fail git cherry-pick --skip && + echo d >foo && + git add foo && + git cherry-pick --continue && + { + git rev-list HEAD | + git diff-tree --root --stdin | + sed "s/$OID_REGEX/OBJID/g" + } >actual.log && + test_cmp expect foo && + test_cmp expect.log actual.log +' + +test_expect_success 'check advice when we move HEAD by committing' ' + pristine_detach initial && + cat >expect <<-EOF && + error: there is nothing to skip + hint: have you committed already? + hint: try "git cherry-pick --continue" + fatal: cherry-pick failed + EOF + test_must_fail git cherry-pick base..yetanotherpick && + echo c >foo && + git commit -a && + test_path_is_missing .git/CHERRY_PICK_HEAD && + test_must_fail git cherry-pick --skip 2>advice && + test_i18ncmp expect advice +' + +test_expect_success 'allow skipping commit but not abort for a new history' ' + pristine_detach initial && + cat >expect <<-EOF && + error: cannot abort from a branch yet to be born + fatal: cherry-pick failed + EOF + git checkout --orphan new_disconnected && + git reset --hard && + test_must_fail git cherry-pick anotherpick && + test_must_fail git cherry-pick --abort 2>advice && + git cherry-pick --skip && + test_i18ncmp expect advice +' + +test_expect_success 'allow skipping stopped cherry-pick because of untracked file modifications' ' + pristine_detach initial && + git rm --cached unrelated && + git commit -m "untrack unrelated" && + test_must_fail git cherry-pick initial base && + test_path_is_missing .git/CHERRY_PICK_HEAD && + git cherry-pick --skip +' + test_expect_success '--quit does not complain when no cherry-pick is in progress' ' pristine_detach initial && git cherry-pick --quit From patchwork Sun Jun 23 20:03:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rohit Ashiwal X-Patchwork-Id: 11011927 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 A3DBE1922 for ; Sun, 23 Jun 2019 20:06:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9743328560 for ; Sun, 23 Jun 2019 20:06:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8C00828ABE; Sun, 23 Jun 2019 20:06:23 +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 1CECA28AC2 for ; Sun, 23 Jun 2019 20:06:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726416AbfFWUGV (ORCPT ); Sun, 23 Jun 2019 16:06:21 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:47099 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726285AbfFWUGV (ORCPT ); Sun, 23 Jun 2019 16:06:21 -0400 Received: by mail-pf1-f196.google.com with SMTP id 81so6227225pfy.13 for ; Sun, 23 Jun 2019 13:06:20 -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=hXlgn2RLQiB+pwvjujW1AIFhXcPY2wIhLojiaXmaZ0o=; b=IFT69nztQan4FvXo8GmED1MtAtF5svKNcAZ/6AtEvzMcogUQ4tWHcGEwo5HBhYEeF8 hcz7Dtc35/L05fmIg9gybGJorEAaMDKU4pQnpX0pLS+/mimK7NHA02BAxl/XWAPWOYB9 dfVz4k6UDqdkkzHC5+2kEqqUVCkttLBxS1788J7FmkzkakS+kWUwuI72rx/U8pVmqWiH IThyWGsxs8SQyUkag8TqtG2FEhbECvZI99S33q4dTso4++Wr59QHh3go2zHNK2w8LnQf xoJgoPtSIRYM3jzgKH8HH+jS6byGSzfwwAYFw1VLV1g4H3HUlxMI1/Ldgp+CjGKg/wSz jk1Q== 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=hXlgn2RLQiB+pwvjujW1AIFhXcPY2wIhLojiaXmaZ0o=; b=AwWApTty15ROwDtB8WT4Fz4lmqYjNlef1jVdBCC9kRPlIOKBODq7sSZpxwbFA+ihfS d/S+Q/3CDBQSkOeu9M/rjVNdZRQtL1pK/cMh2XIKvUBOAj/KyeHJ5DqYxa62/hxKSuA+ rdiK3Hlq7cUq8NAGEUWKtKkIMl9/ONXtaCTboVClZ6hncnRsAwePTzYUAoV5e5JBJSwG WnlJcDiV9Al5wN638VMtel0wfSkLPl5bcMbwUz1+4TasktnRVzCQV7YttLt0FPlIIwFj A9iYP8d0jyuovJRbVqSy/2aHkYpE55QeLj9dMT0QPIGA5sf6OaI1v0QZlojnXCEePPjq m++A== X-Gm-Message-State: APjAAAW74optLnqdgeAbePeLY9OSJwoCczxTe3lvp6CtyIAMrlKRvRQA mN8tFKn7tXhk/WRqbENfWWM= X-Google-Smtp-Source: APXvYqx7ybRSSKb92VIC0WMiI2Dz/2VL+5N0TFnddO5H/87NQTqJ+Xx4Lq1Sryh//JUFAM1DTd//hQ== X-Received: by 2002:a63:2249:: with SMTP id t9mr29704341pgm.149.1561320379893; Sun, 23 Jun 2019 13:06:19 -0700 (PDT) Received: from ar135.iitr.ac.in ([103.37.200.213]) by smtp.gmail.com with ESMTPSA id 27sm8621882pgt.6.2019.06.23.13.06.16 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 23 Jun 2019 13:06:19 -0700 (PDT) From: Rohit Ashiwal To: rohit.ashiwal265@gmail.com Cc: git@vger.kernel.org, newren@gmail.com, t.gummerer@gmail.com, phillip.wood123@gmail.com, gitster@pobox.com, martin.agren@gmail.com Subject: [GSoC][PATCH v7 6/6] cherry-pick/revert: advise using --skip Date: Mon, 24 Jun 2019 01:33:38 +0530 Message-Id: <20190623200338.17144-7-rohit.ashiwal265@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190623200338.17144-1-rohit.ashiwal265@gmail.com> References: <20190608191958.4593-1-rohit.ashiwal265@gmail.com> <20190623200338.17144-1-rohit.ashiwal265@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 previous commit introduced a --skip flag for cherry-pick and revert. Update the advice messages, to tell users about this less cumbersome way of skipping commits. Also add tests to ensure everything is working fine. Signed-off-by: Rohit Ashiwal --- builtin/commit.c | 13 ++++++++----- sequencer.c | 9 ++++++--- t/t3510-cherry-pick-sequence.sh | 20 ++++++++++++++++++++ 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/builtin/commit.c b/builtin/commit.c index 1c9e8e2228..1f47c51bdc 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -60,15 +60,18 @@ N_("The previous cherry-pick is now empty, possibly due to conflict resolution.\ "\n"); static const char empty_cherry_pick_advice_single[] = -N_("Otherwise, please use 'git reset'\n"); +N_("Otherwise, please use 'git cherry-pick --skip'\n"); static const char empty_cherry_pick_advice_multi[] = -N_("If you wish to skip this commit, use:\n" +N_("and then use:\n" "\n" -" git reset\n" +" git cherry-pick --continue\n" "\n" -"Then \"git cherry-pick --continue\" will resume cherry-picking\n" -"the remaining commits.\n"); +"to resume cherry-picking the remaining commits.\n" +"If you wish to skip this commit, use:\n" +"\n" +" git cherry-pick --skip\n" +"\n"); static const char *color_status_slots[] = { [WT_STATUS_HEADER] = "header", diff --git a/sequencer.c b/sequencer.c index f5e3d60878..2e7b16b75f 100644 --- a/sequencer.c +++ b/sequencer.c @@ -2655,18 +2655,20 @@ static int create_seq_dir(struct repository *r) enum replay_action action; const char *in_progress_error = NULL; const char *in_progress_advice = NULL; + unsigned int advise_skip = file_exists(git_path_revert_head(r)) || + file_exists(git_path_cherry_pick_head(r)); if (!sequencer_get_last_command(r, &action)) { switch (action) { case REPLAY_REVERT: in_progress_error = _("revert is already in progress"); in_progress_advice = - _("try \"git revert (--continue | --abort | --quit)\""); + _("try \"git revert (--continue | %s--abort | --quit)\""); break; case REPLAY_PICK: in_progress_error = _("cherry-pick is already in progress"); in_progress_advice = - _("try \"git cherry-pick (--continue | --abort | --quit)\""); + _("try \"git cherry-pick (--continue | %s--abort | --quit)\""); break; default: BUG("unexpected action in create_seq_dir"); @@ -2675,7 +2677,8 @@ static int create_seq_dir(struct repository *r) if (in_progress_error) { error("%s", in_progress_error); if (advice_sequencer_in_use) - advise("%s", in_progress_advice); + advise(in_progress_advice, + advise_skip ? "--skip | " : ""); return -1; } if (mkdir(git_path_seq_dir(), 0777) < 0) diff --git a/t/t3510-cherry-pick-sequence.sh b/t/t3510-cherry-pick-sequence.sh index 20515ea37b..793bcc7fe3 100755 --- a/t/t3510-cherry-pick-sequence.sh +++ b/t/t3510-cherry-pick-sequence.sh @@ -172,6 +172,26 @@ test_expect_success 'check advice when we move HEAD by committing' ' test_i18ncmp expect advice ' +test_expect_success 'selectively advise --skip while launching another sequence' ' + pristine_detach initial && + cat >expect <<-EOF && + error: cherry-pick is already in progress + hint: try "git cherry-pick (--continue | --skip | --abort | --quit)" + fatal: cherry-pick failed + EOF + test_must_fail git cherry-pick picked..yetanotherpick && + test_must_fail git cherry-pick picked..yetanotherpick 2>advice && + test_i18ncmp expect advice && + cat >expect <<-EOF && + error: cherry-pick is already in progress + hint: try "git cherry-pick (--continue | --abort | --quit)" + fatal: cherry-pick failed + EOF + git reset --merge && + test_must_fail git cherry-pick picked..yetanotherpick 2>advice && + test_i18ncmp expect advice +' + test_expect_success 'allow skipping commit but not abort for a new history' ' pristine_detach initial && cat >expect <<-EOF &&