From patchwork Mon Mar 11 03:42:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 10846649 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 3245218EC for ; Mon, 11 Mar 2019 03:42:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1C03028EF8 for ; Mon, 11 Mar 2019 03:42:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 102E128F21; Mon, 11 Mar 2019 03:42:37 +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 F26F928EF8 for ; Mon, 11 Mar 2019 03:42:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727330AbfCKDmf (ORCPT ); Sun, 10 Mar 2019 23:42:35 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:35219 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726933AbfCKDme (ORCPT ); Sun, 10 Mar 2019 23:42:34 -0400 Received: by mail-pg1-f193.google.com with SMTP id e17so2965125pgd.2 for ; Sun, 10 Mar 2019 20:42:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=tn5Kjz+CpnsYjAb/X8/zCWqi6dsaMkKGGIUH/uLWpBk=; b=mJUZZvteTlMNNPTPTI/NNE+W9UGJ7D3znE5SwpSfnhg8HIB7oZUAjBIhFf6cuLZ9SQ g0oPO3gXK7X3IgjKULaUKmyGHO5dVai2zkXC1/eF8kckUAHqd+DQr1ndKhEnP7iaRCGv lwsnzzeEPzejWI0OoOQ3An8Vr8XO4fA1+ndZTk20SwpY+1IFM1bJ081Cu3NeVMyJdHj1 tM8k4E5Gxf0BWlvhJZ+yp+XNRMh1KM/eqjDSRRHu5VMxgTeZZoAkhQeYzCnZUtF+Nqni FCLw8zcAlPsja/PQWwOuyQCVRPKUBNA/gpVPZBL2D4NydHb010nERe/d8H53DIIXhnMy iQdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=tn5Kjz+CpnsYjAb/X8/zCWqi6dsaMkKGGIUH/uLWpBk=; b=P2FHxbKocef88AEH3Kpf8Vlsy/e9MeFISxLbw61Lg1TiXscdDX9DyeSUyJ/7J5prRi vbf7Yswm/aq+Shaq9DXNQMm9IGtIrzUkX8jfSjmmT9VdPvyTyvtcs9nFLoM3lzMity45 /8aiVTHdZBGPI4kTziXC8NfJjZUF4U3qXDkYcefQewXkoBUScnAp3s9TdpzOW1/U7DBj SKyu1p0jPyaIr6DuL6dN+MbVcmXStSa6qDfweEMea6uJ6eg83KakIi5/cFV02cM/uJZg SzZnyiqJ/Uf2k2FxjMm2AnVMo9D00vsafxWa0SoFHvKhgjx/H+vSDkzTleOi6xDplly9 Q+Mg== X-Gm-Message-State: APjAAAV0gFo9xoTD/QhIabBIOj5JH1Sy9WGUzPYrhh1wme72mIRk1jyN n30vzgVHeab9ZoNFTUomCGSs99Cp X-Google-Smtp-Source: APXvYqyPCOT3/pR8PKUE/8hXwPuzmKsHM0iYKqvScCXa31eco7xF/iI9khitbrfMu199dG0GHnDW+Q== X-Received: by 2002:a62:d281:: with SMTP id c123mr30797235pfg.210.1552275753349; Sun, 10 Mar 2019 20:42:33 -0700 (PDT) Received: from archbookpro.localdomain (c-73-222-73-77.hsd1.ca.comcast.net. [73.222.73.77]) by smtp.gmail.com with ESMTPSA id c13sm11291259pfm.34.2019.03.10.20.42.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 10 Mar 2019 20:42:32 -0700 (PDT) Date: Sun, 10 Mar 2019 20:42:30 -0700 From: Denton Liu To: Git Mailing List Cc: Phillip Wood , Junio C Hamano Subject: [PATCH v7 1/8] t7600: clean up 'merge --squash c3 with c7' test Message-ID: <6716d28a5187c44c1d90f5ce840c44441f62352c.1552275703.git.liu.denton@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.3 (2019-02-01) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This cleans up the original test by removing some unnecessary braces and removing a pipe. Helped-by: SZEDER Gábor Signed-off-by: Denton Liu --- t/t7600-merge.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/t/t7600-merge.sh b/t/t7600-merge.sh index 106148254d..d879efd330 100755 --- a/t/t7600-merge.sh +++ b/t/t7600-merge.sh @@ -233,8 +233,7 @@ test_expect_success 'merge --squash c3 with c7' ' cat result.9z >file && git commit --no-edit -a && - { - cat <<-EOF + cat >expect <<-EOF && Squashed commit of the following: $(git show -s c7) @@ -242,8 +241,8 @@ test_expect_success 'merge --squash c3 with c7' ' # Conflicts: # file EOF - } >expect && - git cat-file commit HEAD | sed -e '1,/^$/d' >actual && + git cat-file commit HEAD >tmp && + sed -e '1,/^$/d' actual && test_cmp expect actual ' From patchwork Mon Mar 11 03:42:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 10846651 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 40EC16C2 for ; Mon, 11 Mar 2019 03:42:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 24E0128F20 for ; Mon, 11 Mar 2019 03:42:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 18E1F28EF8; Mon, 11 Mar 2019 03:42:39 +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 8AB2628EF8 for ; Mon, 11 Mar 2019 03:42:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727333AbfCKDmh (ORCPT ); Sun, 10 Mar 2019 23:42:37 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:37700 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726933AbfCKDmh (ORCPT ); Sun, 10 Mar 2019 23:42:37 -0400 Received: by mail-pg1-f196.google.com with SMTP id q206so2963355pgq.4 for ; Sun, 10 Mar 2019 20:42:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=RpDS5/0/di5rFf5vadj6lCJZy5mpsEbpelKVZGSvqsM=; b=mBE8+dNSxpwoYXOxWCku0otuWX5PonVOQTIr2LOVTxlygvSasxljuwoRO+w7BP49ap 2GqO7BXsrF/m80lNPXRW60WvYwUe/GcImvT4Y4NmGACcL9d7UF1OjzrJ4Lg1hxBPUmlN Zom6V26cdtcyNV/dlszp3CekszybP1qhaN1VIhWQGXMdKeROT2bubmbqEtlZkpdPl487 MKEw6nWTdh6dUTkdYq9kEJPoS0/U81X6XyjbQQoWJkxE83ku24dhtbfZw8BLX/MVB8lB vdt3bXewO9CIJ83b8pbrv3TZ61vZeRXCwfmTd0+UTXuf9IILLH3DY0QgfUrYs2jrOl/a Hxig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=RpDS5/0/di5rFf5vadj6lCJZy5mpsEbpelKVZGSvqsM=; b=i2geNrsi6Imovwn5qDoTZAH7YWfEclycngn+tLLn9/HqHHcrNX4BaPQ3ESxIuOK6dX 2X1GdoCp7UalF510+iqtlW8s9MIdKnrFdcCyz17tFRzSlaYDCFpbnRDZXkN/Liyy7u8p khhRe5YybWLRw5WaiH7nBdLSFQ0ZmRmtNze5X3FE47HQpn8HCpopKrhGEa8KHpFlhmtC a+6Mkm+WhMYJE41tHCvj4uC+khy6hW0TQrNNk3iKvc/qGCaPe5zkhzbMhPXB3sUvW0Lb 944k81SofFiVDH/BGZ3ydYF3o+X8diuyKjdRKp5rRUEYAzFfr1jRl7IINgtNVo3AEa3Q PQjw== X-Gm-Message-State: APjAAAVEAUJXap9UMjUhHCw9e+85fKrwNJeMEeba78v1gxbz5NIQmnqX LjePSA4a603Gw0Ri5Z+vNaKl8/KL X-Google-Smtp-Source: APXvYqx/Th23Dsv0Yvy52e+YjAzJRLd96n9BIGzxz4E5/amSX/Rvb/diBJNfB+0sC3f7+MvuG69QoA== X-Received: by 2002:a17:902:31c3:: with SMTP id x61mr31403563plb.113.1552275756038; Sun, 10 Mar 2019 20:42:36 -0700 (PDT) Received: from archbookpro.localdomain (c-73-222-73-77.hsd1.ca.comcast.net. [73.222.73.77]) by smtp.gmail.com with ESMTPSA id h9sm632591pgk.22.2019.03.10.20.42.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 10 Mar 2019 20:42:35 -0700 (PDT) Date: Sun, 10 Mar 2019 20:42:33 -0700 From: Denton Liu To: Git Mailing List Cc: Phillip Wood , Junio C Hamano Subject: [PATCH v7 2/8] t3507: cleanup space after redirection operators Message-ID: <0929ecc5493f666509903571304cdce81573a6fb.1552275703.git.liu.denton@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.3 (2019-02-01) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Denton Liu --- t/t3507-cherry-pick-conflict.sh | 34 ++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/t/t3507-cherry-pick-conflict.sh b/t/t3507-cherry-pick-conflict.sh index 0db166152a..74ff925526 100755 --- a/t/t3507-cherry-pick-conflict.sh +++ b/t/t3507-cherry-pick-conflict.sh @@ -88,7 +88,7 @@ test_expect_success 'cherry-pick --no-commit does not set CHERRY_PICK_HEAD' ' test_expect_success 'cherry-pick w/dirty tree does not set CHERRY_PICK_HEAD' ' pristine_detach initial && - echo foo > foo && + echo foo >foo && test_must_fail git cherry-pick base && test_must_fail git rev-parse --verify CHERRY_PICK_HEAD ' @@ -96,7 +96,7 @@ test_expect_success 'cherry-pick w/dirty tree does not set CHERRY_PICK_HEAD' ' test_expect_success \ 'cherry-pick --strategy=resolve w/dirty tree does not set CHERRY_PICK_HEAD' ' pristine_detach initial && - echo foo > foo && + echo foo >foo && test_must_fail git cherry-pick --strategy=resolve base && test_must_fail git rev-parse --verify CHERRY_PICK_HEAD ' @@ -175,23 +175,23 @@ test_expect_success 'failed cherry-pick registers participants in index' ' git ls-files --stage foo && git checkout picked -- foo && git ls-files --stage foo - } > stages && + } >stages && sed " 1 s/ 0 / 1 / 2 s/ 0 / 2 / 3 s/ 0 / 3 / - " < stages > expected && + " expected && git read-tree -u --reset HEAD && test_must_fail git cherry-pick picked && - git ls-files --stage --unmerged > actual && + git ls-files --stage --unmerged >actual && test_cmp expected actual ' test_expect_success 'failed cherry-pick describes conflict in work tree' ' pristine_detach initial && - cat <<-EOF > expected && + cat <<-EOF >expected && <<<<<<< HEAD a ======= @@ -201,14 +201,14 @@ test_expect_success 'failed cherry-pick describes conflict in work tree' ' test_must_fail git cherry-pick picked && - sed "s/[a-f0-9]*\.\.\./objid/" foo > actual && + sed "s/[a-f0-9]*\.\.\./objid/" foo >actual && test_cmp expected actual ' test_expect_success 'diff3 -m style' ' pristine_detach initial && git config merge.conflictstyle diff3 && - cat <<-EOF > expected && + cat <<-EOF >expected && <<<<<<< HEAD a ||||||| parent of objid picked @@ -220,14 +220,14 @@ test_expect_success 'diff3 -m style' ' test_must_fail git cherry-pick picked && - sed "s/[a-f0-9]*\.\.\./objid/" foo > actual && + sed "s/[a-f0-9]*\.\.\./objid/" foo >actual && test_cmp expected actual ' test_expect_success 'revert also handles conflicts sanely' ' git config --unset merge.conflictstyle && pristine_detach initial && - cat <<-EOF > expected && + cat <<-EOF >expected && <<<<<<< HEAD a ======= @@ -241,24 +241,24 @@ test_expect_success 'revert also handles conflicts sanely' ' git ls-files --stage foo && git checkout base -- foo && git ls-files --stage foo - } > stages && + } >stages && sed " 1 s/ 0 / 1 / 2 s/ 0 / 2 / 3 s/ 0 / 3 / - " < stages > expected-stages && + " expected-stages && git read-tree -u --reset HEAD && head=$(git rev-parse HEAD) && test_must_fail git revert picked && newhead=$(git rev-parse HEAD) && - git ls-files --stage --unmerged > actual-stages && + git ls-files --stage --unmerged >actual-stages && test "$head" = "$newhead" && test_must_fail git update-index --refresh -q && test_must_fail git diff-index --exit-code HEAD && test_cmp expected-stages actual-stages && - sed "s/[a-f0-9]*\.\.\./objid/" foo > actual && + sed "s/[a-f0-9]*\.\.\./objid/" foo >actual && test_cmp expected actual ' @@ -284,7 +284,7 @@ test_expect_success 'revert --no-commit sets REVERT_HEAD' ' test_expect_success 'revert w/dirty tree does not set REVERT_HEAD' ' pristine_detach base && - echo foo > foo && + echo foo >foo && test_must_fail git revert base && test_must_fail git rev-parse --verify CHERRY_PICK_HEAD && test_must_fail git rev-parse --verify REVERT_HEAD @@ -319,7 +319,7 @@ test_expect_success 'failed commit does not clear REVERT_HEAD' ' test_expect_success 'revert conflict, diff3 -m style' ' pristine_detach initial && git config merge.conflictstyle diff3 && - cat <<-EOF > expected && + cat <<-EOF >expected && <<<<<<< HEAD a ||||||| objid picked @@ -331,7 +331,7 @@ test_expect_success 'revert conflict, diff3 -m style' ' test_must_fail git revert picked && - sed "s/[a-f0-9]*\.\.\./objid/" foo > actual && + sed "s/[a-f0-9]*\.\.\./objid/" foo >actual && test_cmp expected actual ' From patchwork Mon Mar 11 03:42:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 10846653 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 038256C2 for ; Mon, 11 Mar 2019 03:42:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E1A0528EF8 for ; Mon, 11 Mar 2019 03:42:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D5A5D28F21; Mon, 11 Mar 2019 03:42:41 +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 65DFB28EF8 for ; Mon, 11 Mar 2019 03:42:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727336AbfCKDmk (ORCPT ); Sun, 10 Mar 2019 23:42:40 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:45797 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726933AbfCKDmj (ORCPT ); Sun, 10 Mar 2019 23:42:39 -0400 Received: by mail-pf1-f196.google.com with SMTP id v21so2671097pfm.12 for ; Sun, 10 Mar 2019 20:42:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=s9JDpsN+/VR9ShyIryOD4OP47xRyqsogbFPXFWGCh0I=; b=og8bqjDXv0Mh9c+BNEKQtHdUxGH/zonbNEmUBGHjeh18mUfCRolXmhSUA7A2UCQl6z qQC74nAu1eQwB71vM4zIQGHM9405B+6Sm56nCm9inyDoEAuOBpaE1cNOBEspD4tCdu81 BxEVA9CQmEv2aCh2D8HoyZsFq/0rxCwmdHNyYS4wmH6lSv5TRf8wwTJfwW+8OS81274O Q+3bis6tDocACVvkq+ftx64zWtOxhcvi6/fai3wrK32rNLccQqIU+yUWPHHNYIxjwkqU mOGirbz4JQkFiPOKr6QAaoly9ML/QfZCCBLAbKisznZsEGEZJM2sx++JldhVOIdU2M6q ApVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=s9JDpsN+/VR9ShyIryOD4OP47xRyqsogbFPXFWGCh0I=; b=qkvWPawZS+62Bq/Lp+MKbW6b/HPpgf1MIOhFMes944eHwxCeHyPlPBBV/AmutzLfgI nJcBsUVAoSYNpbIqOFzmXjyRKmuVfyRhMSj8eEYMR/GulTN+fabMLsxUhlOmSEjLsw2+ /p8OZx7MzjRsgZtY+lL7/qwlZZxEzlEVZoyNoginE1IPj5llWErY0v5kOrJqtk1jGYms AnN0vcbjQeItkABj6szV0sCq55Uy3N1nbw2BwovWCkfjpNpZ+P+ANhhKZTusCxxeS3fg +1LRwqlggv2EK4ew6qYi3CgzHb+8y//pw8w3nnJUYERxAgzNFq5Net/xCGPT2+EveqDQ e/+A== X-Gm-Message-State: APjAAAW2uixnsFE9Z1JGzJxMYaSSSRUpx3t0dJIOncDl+fy15OwaR40J tzsvZJeTUF01dQ+Qj+bDBdAk4MF6 X-Google-Smtp-Source: APXvYqyYWCprDYDNN7pbjK9/A9IPLL1lYRt1tlwpnNtcnQpm9Ga2UssLegkN899V/OFvN0n1n2qvDQ== X-Received: by 2002:a62:4389:: with SMTP id l9mr32249620pfi.170.1552275758562; Sun, 10 Mar 2019 20:42:38 -0700 (PDT) Received: from archbookpro.localdomain (c-73-222-73-77.hsd1.ca.comcast.net. [73.222.73.77]) by smtp.gmail.com with ESMTPSA id j9sm6769508pfc.67.2019.03.10.20.42.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 10 Mar 2019 20:42:38 -0700 (PDT) Date: Sun, 10 Mar 2019 20:42:36 -0700 From: Denton Liu To: Git Mailing List Cc: Phillip Wood , Junio C Hamano Subject: [PATCH v7 3/8] commit: extract cleanup_mode functions to sequencer Message-ID: <9a6ad0b890b3ad5169854122f5bd429ce5ce8324.1552275703.git.liu.denton@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.3 (2019-02-01) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Denton Liu --- builtin/commit.c | 25 ++----------------------- sequencer.c | 29 +++++++++++++++++++++++++++++ sequencer.h | 6 ++++++ 3 files changed, 37 insertions(+), 23 deletions(-) diff --git a/builtin/commit.c b/builtin/commit.c index f17537474a..0df15e4851 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -1172,24 +1172,7 @@ static int parse_and_validate_options(int argc, const char *argv[], die(_("Only one of --include/--only/--all/--interactive/--patch can be used.")); if (argc == 0 && (also || (only && !amend && !allow_empty))) die(_("No paths with --include/--only does not make sense.")); - if (!cleanup_arg || !strcmp(cleanup_arg, "default")) - cleanup_mode = use_editor ? COMMIT_MSG_CLEANUP_ALL : - COMMIT_MSG_CLEANUP_SPACE; - else if (!strcmp(cleanup_arg, "verbatim")) - cleanup_mode = COMMIT_MSG_CLEANUP_NONE; - else if (!strcmp(cleanup_arg, "whitespace")) - cleanup_mode = COMMIT_MSG_CLEANUP_SPACE; - else if (!strcmp(cleanup_arg, "strip")) - cleanup_mode = COMMIT_MSG_CLEANUP_ALL; - else if (!strcmp(cleanup_arg, "scissors")) - cleanup_mode = use_editor ? COMMIT_MSG_CLEANUP_SCISSORS : - COMMIT_MSG_CLEANUP_SPACE; - /* - * Please update _git_commit() in git-completion.bash when you - * add new options. - */ - else - die(_("Invalid cleanup mode %s"), cleanup_arg); + cleanup_mode = get_cleanup_mode(cleanup_arg, use_editor); handle_untracked_files_arg(s); @@ -1626,11 +1609,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix) die(_("could not read commit message: %s"), strerror(saved_errno)); } - if (verbose || /* Truncate the message just before the diff, if any. */ - cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS) - strbuf_setlen(&sb, wt_status_locate_end(sb.buf, sb.len)); - if (cleanup_mode != COMMIT_MSG_CLEANUP_NONE) - strbuf_stripspace(&sb, cleanup_mode == COMMIT_MSG_CLEANUP_ALL); + cleanup_message(&sb, cleanup_mode, verbose); if (message_is_empty(&sb, cleanup_mode) && !allow_empty_message) { rollback_index_files(); diff --git a/sequencer.c b/sequencer.c index 95dda23eee..224c823b43 100644 --- a/sequencer.c +++ b/sequencer.c @@ -511,6 +511,25 @@ static int fast_forward_to(struct repository *r, return 0; } +enum commit_msg_cleanup_mode get_cleanup_mode(const char *cleanup_arg, + int use_editor) +{ + if (!cleanup_arg || !strcmp(cleanup_arg, "default")) + return use_editor ? COMMIT_MSG_CLEANUP_ALL : + COMMIT_MSG_CLEANUP_SPACE; + else if (!strcmp(cleanup_arg, "verbatim")) + return COMMIT_MSG_CLEANUP_NONE; + else if (!strcmp(cleanup_arg, "whitespace")) + return COMMIT_MSG_CLEANUP_SPACE; + else if (!strcmp(cleanup_arg, "strip")) + return COMMIT_MSG_CLEANUP_ALL; + else if (!strcmp(cleanup_arg, "scissors")) + return use_editor ? COMMIT_MSG_CLEANUP_SCISSORS : + COMMIT_MSG_CLEANUP_SPACE; + else + die(_("Invalid cleanup mode %s"), cleanup_arg); +} + void append_conflicts_hint(struct index_state *istate, struct strbuf *msgbuf) { @@ -1013,6 +1032,16 @@ static int rest_is_empty(const struct strbuf *sb, int start) return 1; } +void cleanup_message(struct strbuf *msgbuf, + enum commit_msg_cleanup_mode cleanup_mode, int verbose) +{ + if (verbose || /* Truncate the message just before the diff, if any. */ + cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS) + strbuf_setlen(msgbuf, wt_status_locate_end(msgbuf->buf, msgbuf->len)); + if (cleanup_mode != COMMIT_MSG_CLEANUP_NONE) + strbuf_stripspace(msgbuf, cleanup_mode == COMMIT_MSG_CLEANUP_ALL); +} + /* * Find out if the message in the strbuf contains only whitespace and * Signed-off-by lines. diff --git a/sequencer.h b/sequencer.h index 4d505b3590..eb9bd97ef3 100644 --- a/sequencer.h +++ b/sequencer.h @@ -116,6 +116,12 @@ int rearrange_squash(struct repository *r); void append_signoff(struct strbuf *msgbuf, size_t ignore_footer, unsigned flag); void append_conflicts_hint(struct index_state *istate, struct strbuf *msgbuf); +enum commit_msg_cleanup_mode get_cleanup_mode(const char *cleanup_arg, + int use_editor); + +void cleanup_message(struct strbuf *msgbuf, + enum commit_msg_cleanup_mode cleanup_mode, int verbose); + int message_is_empty(const struct strbuf *sb, enum commit_msg_cleanup_mode cleanup_mode); int template_untouched(const struct strbuf *sb, const char *template_file, From patchwork Mon Mar 11 03:42:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 10846655 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 407D76C2 for ; Mon, 11 Mar 2019 03:42:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2A3A728EF8 for ; Mon, 11 Mar 2019 03:42:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1B2D628F21; Mon, 11 Mar 2019 03:42:44 +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 A2B7828EF8 for ; Mon, 11 Mar 2019 03:42:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727339AbfCKDmm (ORCPT ); Sun, 10 Mar 2019 23:42:42 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:38772 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726933AbfCKDmm (ORCPT ); Sun, 10 Mar 2019 23:42:42 -0400 Received: by mail-pg1-f193.google.com with SMTP id m2so2960567pgl.5 for ; Sun, 10 Mar 2019 20:42:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=bsd02n8xPECKi1/scXhJYBTSAoZKofufeyf8DYPbziA=; b=vKfPlc/43X1wpqa+seVvTAY6EwQMGsoUCiWXO9F03+Xx3F4nn53pOF4enE7fKGbD7m JTfzg1k64DdTQyXGh94rAuwy/gtIjv+QY4+p3L+wzQpuSn4gKdT/ZPaZMvb01lEjh5rE Dh6/QZEd4YiQztnzlXi4KBt4+HPjPA2p9gJq/UNwj7aDv2XzHMJRVtd0bCpfLcSNldkp TEUcm9voPd+iWFSH4rH6gLOwpaB3O+24s46/IKVJJbKSpsoieh56wjoPoGo3PYI0q4qq +Qwa0DOmy+cHiMns70wM/gcXbeMCJb1ywEE7GLqoNe3D7dl18tgIZBVn2hlFmm3CVV4J MmWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=bsd02n8xPECKi1/scXhJYBTSAoZKofufeyf8DYPbziA=; b=gHWLl0dcM47TWMPrJg1zSVuE8n3R3TzfyeCrbR0cgfUWz+P2QVIEWgEL8RCbUGiXW3 0BgKTpD2e39NYyrBl/c+WE8dBRRqlQrJBY0zkNkRyDoUEwai7iAzsKlhaUdBu6j1WjmT 9yXwpeLda3Hc3PzXiNAhER058wLrBsA0qjON+qqKRwOyvXKf+JPOTfPGzWPyZtuRFOKe y5ZuHn+HgkPHleoIJB9ZMOOLJ06LfZ/KU92UjnNMjpHvhwn7b63GHG1Cq24tj8eemDsH lcGX3akQyY+RSOThSQKo2uTQCBH8KIs0y9XRXpZW8FiYzovsE5xl6IFU3xpj8s4zkzvp bA9Q== X-Gm-Message-State: APjAAAWOgo77dF7ScnXfm6aPnwXCGeZ+OJvv4q/qHuw8GQ5/MzMVDDet qBidRnMR94aZQYDOKl0gB6RoszDd X-Google-Smtp-Source: APXvYqzWtL/+4jaoNII10v8UBBSwIytkqYYqJDjjQzn+eunp2L4Chg41gikei4QEM2ExpQKJf8O+mw== X-Received: by 2002:a63:5b43:: with SMTP id l3mr27980656pgm.298.1552275760997; Sun, 10 Mar 2019 20:42:40 -0700 (PDT) Received: from archbookpro.localdomain (c-73-222-73-77.hsd1.ca.comcast.net. [73.222.73.77]) by smtp.gmail.com with ESMTPSA id g80sm6861367pfd.72.2019.03.10.20.42.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 10 Mar 2019 20:42:40 -0700 (PDT) Date: Sun, 10 Mar 2019 20:42:38 -0700 From: Denton Liu To: Git Mailing List Cc: Phillip Wood , Junio C Hamano Subject: [PATCH v7 4/8] sequencer.c: remove duplicate code Message-ID: <6d5ce3ffffe5ef6c23b12538650b2cdf86e4cac9.1552275703.git.liu.denton@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.3 (2019-02-01) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Since we implemented get_cleanup_mode, we had some duplicate code in git_sequencer_config which essentially performed the same operations. Refactor git_sequencer_config to take advantage of the logic already in get_cleanup_mode. Note that we had to introduce a separate argument to get_cleanup_mode indicating whether to die or not on an invalid value. This is because if we are parsing a config, we do not want to die but instead, we only want to warn the user, whereas if we are parsing a command-line option, we would like to actually die. Finally, this is almost a no-op refactor but not quite. Previously, in the case that an invalid value is presented, default_msg_cleanup would not be set. We change the behaviour so that default_msg_cleanup will now take on the value as if "default" were provided as the cleanup_arg. Signed-off-by: Denton Liu --- builtin/commit.c | 2 +- sequencer.c | 20 +++++++------------- sequencer.h | 2 +- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/builtin/commit.c b/builtin/commit.c index 0df15e4851..81e3bd21ca 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -1172,7 +1172,7 @@ static int parse_and_validate_options(int argc, const char *argv[], die(_("Only one of --include/--only/--all/--interactive/--patch can be used.")); if (argc == 0 && (also || (only && !amend && !allow_empty))) die(_("No paths with --include/--only does not make sense.")); - cleanup_mode = get_cleanup_mode(cleanup_arg, use_editor); + cleanup_mode = get_cleanup_mode(cleanup_arg, use_editor, 1); handle_untracked_files_arg(s); diff --git a/sequencer.c b/sequencer.c index 224c823b43..612621f221 100644 --- a/sequencer.c +++ b/sequencer.c @@ -172,17 +172,7 @@ static int git_sequencer_config(const char *k, const char *v, void *cb) if (status) return status; - if (!strcmp(s, "verbatim")) - opts->default_msg_cleanup = COMMIT_MSG_CLEANUP_NONE; - else if (!strcmp(s, "whitespace")) - opts->default_msg_cleanup = COMMIT_MSG_CLEANUP_SPACE; - else if (!strcmp(s, "strip")) - opts->default_msg_cleanup = COMMIT_MSG_CLEANUP_ALL; - else if (!strcmp(s, "scissors")) - opts->default_msg_cleanup = COMMIT_MSG_CLEANUP_SPACE; - else - warning(_("invalid commit message cleanup mode '%s'"), - s); + opts->default_msg_cleanup = get_cleanup_mode(s, 0, 0); free((char *)s); return status; @@ -512,7 +502,7 @@ static int fast_forward_to(struct repository *r, } enum commit_msg_cleanup_mode get_cleanup_mode(const char *cleanup_arg, - int use_editor) + int use_editor, int die_on_error) { if (!cleanup_arg || !strcmp(cleanup_arg, "default")) return use_editor ? COMMIT_MSG_CLEANUP_ALL : @@ -526,7 +516,11 @@ enum commit_msg_cleanup_mode get_cleanup_mode(const char *cleanup_arg, else if (!strcmp(cleanup_arg, "scissors")) return use_editor ? COMMIT_MSG_CLEANUP_SCISSORS : COMMIT_MSG_CLEANUP_SPACE; - else + else if (!die_on_error) { + warning(_("Invalid cleanup mode %s, falling back to default"), cleanup_arg); + return use_editor ? COMMIT_MSG_CLEANUP_ALL : + COMMIT_MSG_CLEANUP_SPACE; + } else die(_("Invalid cleanup mode %s"), cleanup_arg); } diff --git a/sequencer.h b/sequencer.h index eb9bd97ef3..e7908f558e 100644 --- a/sequencer.h +++ b/sequencer.h @@ -117,7 +117,7 @@ void append_signoff(struct strbuf *msgbuf, size_t ignore_footer, unsigned flag); void append_conflicts_hint(struct index_state *istate, struct strbuf *msgbuf); enum commit_msg_cleanup_mode get_cleanup_mode(const char *cleanup_arg, - int use_editor); + int use_editor, int die_on_error); void cleanup_message(struct strbuf *msgbuf, enum commit_msg_cleanup_mode cleanup_mode, int verbose); From patchwork Mon Mar 11 03:42:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 10846657 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 75F511390 for ; Mon, 11 Mar 2019 03:42:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F02128EF8 for ; Mon, 11 Mar 2019 03:42:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 535DF28F21; Mon, 11 Mar 2019 03:42:47 +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 7613728EF8 for ; Mon, 11 Mar 2019 03:42:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727342AbfCKDmp (ORCPT ); Sun, 10 Mar 2019 23:42:45 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:45807 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726933AbfCKDmp (ORCPT ); Sun, 10 Mar 2019 23:42:45 -0400 Received: by mail-pf1-f194.google.com with SMTP id v21so2671206pfm.12 for ; Sun, 10 Mar 2019 20:42:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=gMKA5R+Sm1GGYtPw/lmyNSNvVlUsbscM+EbboDwLjOQ=; b=lwOhVNGkjc2MQYlePEwPCnQs2ae6MuYH+Q60BaVeS0iF7EYeq1uOXeGtN5qnGuSd1P f6I7Ao4ERqBnFCze4MkY11XBunxkQJS9103KLxZ229cWVHXcgXqXVGwffdL5VtNVGPEm mahorfiv/xTV1oCMfyknmuO+Eu0wmaMr/1/qXInAfFkF5RAWMmP4GgKca0uLOpIMxYAD lgQI5NxjJGR0jbeoRiCfJ/knc96EJR4cRHu7dlwYTDcwaFJhnw0cB4t5thghARc23BNq 2eSFYu8Bg7wO0sMrXdTRLBc8almtN+9HK1bogo2Um9gatkNzJ8uhuRIAL+3r/aLOFhjR 7R8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=gMKA5R+Sm1GGYtPw/lmyNSNvVlUsbscM+EbboDwLjOQ=; b=R8d9M1lENEITWomWjM3WaIhQWYzUCaBkfvD+b7Z1B3Ze3w+LpBl4GPvddtMx5I9Hm6 K+Txz+Yd3C23S6DBuR22uHggf/wrw1PbBozcA8+I47b791dB/nP3CueWLPzbHXD3+rkV ieWau9fNuBKygNKWaezVtXvxQwWmHeNMUBWd9sTxi6qfkK3m73H6mYU90JEDqHOslNC+ LjfM77qR8CMfpG/6RPbQx8IZl6GKUgV+ywMAv+tojls08QFLlOnAzqbE7Bv5/oXr0YhT 30DJog3MWQGBr7wE76zUo/cxBcuPQN1gZI8hXNpuiN8yoJ3YC8DKxDLQx5fk2xEAikT1 jYiA== X-Gm-Message-State: APjAAAWlXtfX4YQF0TBaY86lRBQhaJFyCklRDdKxCrj4zKW1JnzoqKsL W0Yd6ytvjGkaKyUWPE0Fc75eMHVe X-Google-Smtp-Source: APXvYqwwKeZ9ZCij/vPEcr3cWuUFASSpbnbkixxPlT4DgOlp9QueQvdRsoG2+py8emyS0JJeFTDfzw== X-Received: by 2002:a17:902:8f81:: with SMTP id z1mr32588845plo.265.1552275763470; Sun, 10 Mar 2019 20:42:43 -0700 (PDT) Received: from archbookpro.localdomain (c-73-222-73-77.hsd1.ca.comcast.net. [73.222.73.77]) by smtp.gmail.com with ESMTPSA id 11sm5753832pfh.131.2019.03.10.20.42.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 10 Mar 2019 20:42:43 -0700 (PDT) Date: Sun, 10 Mar 2019 20:42:41 -0700 From: Denton Liu To: Git Mailing List Cc: Phillip Wood , Junio C Hamano Subject: [PATCH v7 5/8] merge: cleanup messages like commit Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.3 (2019-02-01) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This change allows git-merge messages to be cleaned up with the commit.cleanup configuration or --cleanup option, just like how git-commit does it. We also give git-pull the passthrough option of --cleanup so that it can also take advantage of this change. Finally, add testing to ensure that messages are properly cleaned up. Note that some newlines that were added to the commit message were removed so that if a file were read via -F, it would be copied faithfully. Signed-off-by: Denton Liu --- Documentation/merge-options.txt | 5 +++ builtin/merge.c | 31 +++++++++++++---- builtin/pull.c | 6 ++++ t/t7604-merge-custom-message.sh | 61 +++++++++++++++++++++++++++++++++ wt-status.c | 12 +++++-- wt-status.h | 1 + 6 files changed, 106 insertions(+), 10 deletions(-) diff --git a/Documentation/merge-options.txt b/Documentation/merge-options.txt index 92a7d936c1..646100ea9a 100644 --- a/Documentation/merge-options.txt +++ b/Documentation/merge-options.txt @@ -32,6 +32,11 @@ they run `git merge`. To make it easier to adjust such scripts to the updated behaviour, the environment variable `GIT_MERGE_AUTOEDIT` can be set to `no` at the beginning of them. +--cleanup=:: + This option determines how the merge message will be cleaned up + before commiting or being passed on. See linkgit:git-commit[1] for more + details. + --ff:: When the merge resolves as a fast-forward, only update the branch pointer, without creating a merge commit. This is the default diff --git a/builtin/merge.c b/builtin/merge.c index 5ce8946d39..4f5fcf5ce9 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -38,6 +38,7 @@ #include "tag.h" #include "alias.h" #include "commit-reach.h" +#include "wt-status.h" #define DEFAULT_TWOHEAD (1<<0) #define DEFAULT_OCTOPUS (1<<1) @@ -98,6 +99,9 @@ enum ff_type { static enum ff_type fast_forward = FF_ALLOW; +static const char *cleanup_arg; +static enum commit_msg_cleanup_mode cleanup_mode; + static int option_parse_message(const struct option *opt, const char *arg, int unset) { @@ -249,6 +253,7 @@ static struct option builtin_merge_options[] = { N_("perform a commit if the merge succeeds (default)")), OPT_BOOL('e', "edit", &option_edit, N_("edit message before committing")), + OPT_STRING(0, "cleanup", &cleanup_arg, N_("default"), N_("how to strip spaces and #comments from message")), OPT_SET_INT(0, "ff", &fast_forward, N_("allow fast-forward (default)"), FF_ALLOW), OPT_SET_INT_F(0, "ff-only", &fast_forward, N_("abort if fast-forward is not possible"), @@ -612,6 +617,8 @@ static int git_merge_config(const char *k, const char *v, void *cb) return git_config_string(&pull_twohead, k, v); else if (!strcmp(k, "pull.octopus")) return git_config_string(&pull_octopus, k, v); + else if (!strcmp(k, "commit.cleanup")) + return git_config_string(&cleanup_arg, k, v); else if (!strcmp(k, "merge.renormalize")) option_renormalize = git_config_bool(k, v); else if (!strcmp(k, "merge.ff")) { @@ -797,23 +804,32 @@ static void abort_commit(struct commit_list *remoteheads, const char *err_msg) exit(1); } +static const char comment_line_explanation[] = +N_("Lines starting with '%c' will be ignored.\n"); + static const char merge_editor_comment[] = N_("Please enter a commit message to explain why this merge is necessary,\n" "especially if it merges an updated upstream into a topic branch.\n" "\n" - "Lines starting with '%c' will be ignored, and an empty message aborts\n" - "the commit.\n"); + "An empty message aborts the commit.\n"); static void write_merge_heads(struct commit_list *); static void prepare_to_commit(struct commit_list *remoteheads) { struct strbuf msg = STRBUF_INIT; strbuf_addbuf(&msg, &merge_msg); - strbuf_addch(&msg, '\n'); if (squash) BUG("the control must not reach here under --squash"); - if (0 < option_edit) - strbuf_commented_addf(&msg, _(merge_editor_comment), comment_line_char); + if (0 < option_edit) { + strbuf_addch(&msg, '\n'); + if (cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS) + wt_status_append_cut_line(&msg); + else + strbuf_commented_addf(&msg, _(comment_line_explanation), comment_line_char); + + strbuf_commented_addf(&msg, "\n"); + strbuf_commented_addf(&msg, _(merge_editor_comment)); + } if (signoff) append_signoff(&msg, ignore_non_trailer(msg.buf, msg.len), 0); write_merge_heads(remoteheads); @@ -832,7 +848,7 @@ static void prepare_to_commit(struct commit_list *remoteheads) abort_commit(remoteheads, NULL); read_merge_msg(&msg); - strbuf_stripspace(&msg, 0 < option_edit); + cleanup_message(&msg, cleanup_mode, 0); if (!msg.len) abort_commit(remoteheads, _("Empty commit message.")); strbuf_release(&merge_msg); @@ -880,7 +896,6 @@ static int finish_automerge(struct commit *head, parents = remoteheads; if (!head_subsumed || fast_forward == FF_NO) commit_list_insert(head, &parents); - strbuf_addch(&merge_msg, '\n'); prepare_to_commit(remoteheads); if (commit_tree(merge_msg.buf, merge_msg.len, result_tree, parents, &result_commit, NULL, sign_commit)) @@ -1389,6 +1404,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix) if (option_edit < 0) option_edit = default_edit_option(); + cleanup_mode = get_cleanup_mode(cleanup_arg, 0 < option_edit, 1); + if (!use_strategies) { if (!remoteheads) ; /* already up-to-date */ diff --git a/builtin/pull.c b/builtin/pull.c index 33db889955..3ec7882375 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -101,6 +101,7 @@ static char *opt_signoff; static char *opt_squash; static char *opt_commit; static char *opt_edit; +static char *opt_cleanup; static char *opt_ff; static char *opt_verify_signatures; static int opt_autostash = -1; @@ -168,6 +169,9 @@ static struct option pull_options[] = { OPT_PASSTHRU(0, "edit", &opt_edit, NULL, N_("edit message before committing"), PARSE_OPT_NOARG), + OPT_PASSTHRU(0, "cleanup", &opt_cleanup, NULL, + N_("how to strip spaces and #comments from message"), + PARSE_OPT_NOARG), OPT_PASSTHRU(0, "ff", &opt_ff, NULL, N_("allow fast-forward"), PARSE_OPT_NOARG), @@ -644,6 +648,8 @@ static int run_merge(void) argv_array_push(&args, opt_commit); if (opt_edit) argv_array_push(&args, opt_edit); + if (opt_cleanup) + argv_array_push(&args, opt_cleanup); if (opt_ff) argv_array_push(&args, opt_ff); if (opt_verify_signatures) diff --git a/t/t7604-merge-custom-message.sh b/t/t7604-merge-custom-message.sh index 89619cf446..3fcd58eb2c 100755 --- a/t/t7604-merge-custom-message.sh +++ b/t/t7604-merge-custom-message.sh @@ -47,4 +47,65 @@ test_expect_success 'merge --log appends to custom message' ' test_cmp exp.log actual ' +mesg_with_comment_and_newlines=' +# text + +' + +test_expect_success 'prepare file with comment line and trailing newlines' ' + printf "%s" "$mesg_with_comment_and_newlines" >expect +' + +test_expect_success 'cleanup commit messages (verbatim option)' ' + git reset --hard c1 && + git merge --cleanup=verbatim -F expect c2 && + git cat-file -p HEAD |sed -e "1,/^\$/d" >actual && + test_cmp expect actual +' + +test_expect_success 'cleanup commit messages (whitespace option)' ' + git reset --hard c1 && + { echo;echo "# text";echo; } >text && + echo "# text" >expect && + git merge --cleanup=whitespace -F text c2 && + git cat-file -p HEAD |sed -e "1,/^\$/d">actual && + test_cmp expect actual + +' + +test_expect_success 'cleanup merge messages (scissors option)' ' + git reset --hard c1 && + cat >text <8 ------------------------ +# to be kept, too +# ------------------------ >8 ------------------------ +to be removed +# ------------------------ >8 ------------------------ +to be removed, too +EOF + + cat >expect <8 ------------------------ +# to be kept, too +EOF + git merge --cleanup=scissors -e -F text c2 && + git cat-file -p HEAD |sed -e "1,/^\$/d">actual && + test_cmp expect actual +' + +test_expect_success 'cleanup commit messages (strip option)' ' + git reset --hard c1 && + { echo;echo "# text";echo sample;echo; } >text && + echo sample >expect && + git merge --cleanup=strip -F text c2 && + git cat-file -p HEAD |sed -e "1,/^\$/d">actual && + test_cmp expect actual + +' + test_done diff --git a/wt-status.c b/wt-status.c index 445a36204a..b81fcd428d 100644 --- a/wt-status.c +++ b/wt-status.c @@ -1006,13 +1006,19 @@ size_t wt_status_locate_end(const char *s, size_t len) return len; } -void wt_status_add_cut_line(FILE *fp) +void wt_status_append_cut_line(struct strbuf *buf) { const char *explanation = _("Do not modify or remove the line above.\nEverything below it will be ignored."); + + strbuf_commented_addf(buf, "%s", cut_line); + strbuf_add_commented_lines(buf, explanation, strlen(explanation)); +} + +void wt_status_add_cut_line(FILE *fp) +{ struct strbuf buf = STRBUF_INIT; - fprintf(fp, "%c %s", comment_line_char, cut_line); - strbuf_add_commented_lines(&buf, explanation, strlen(explanation)); + wt_status_append_cut_line(&buf); fputs(buf.buf, fp); strbuf_release(&buf); } diff --git a/wt-status.h b/wt-status.h index 3a95975032..64f1ddc9fd 100644 --- a/wt-status.h +++ b/wt-status.h @@ -129,6 +129,7 @@ struct wt_status { }; size_t wt_status_locate_end(const char *s, size_t len); +void wt_status_append_cut_line(struct strbuf *buf); void wt_status_add_cut_line(FILE *fp); void wt_status_prepare(struct repository *r, struct wt_status *s); void wt_status_print(struct wt_status *s); From patchwork Mon Mar 11 03:42:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 10846659 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 981C61390 for ; Mon, 11 Mar 2019 03:42:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8169A28EF8 for ; Mon, 11 Mar 2019 03:42:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 75C6A28F21; Mon, 11 Mar 2019 03:42:49 +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 D535928EF8 for ; Mon, 11 Mar 2019 03:42:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727345AbfCKDmr (ORCPT ); Sun, 10 Mar 2019 23:42:47 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:43307 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726933AbfCKDmr (ORCPT ); Sun, 10 Mar 2019 23:42:47 -0400 Received: by mail-pf1-f196.google.com with SMTP id q17so2677158pfh.10 for ; Sun, 10 Mar 2019 20:42:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=kwq4bRCS12E0pwS24n4DF6fH8vCgV1gHSX9jQZdeS6s=; b=YrbNdNeLt89h1Yz6weE66wRvwrbhZnMRAn68ewwrifOj1feyzsk/YlDHDI6Ex6naVz xIMFKs402OahErhm2bM4YqI9qB2/q9FYWuIRU5Shtn+DJ2/JC16wtlovwkPB2F4vJZa8 FgBt5heeMox6b6gxBTNYk6wGkvlQuFnQqV6uB/m6TqucRJ2ujnmvTzuUpgH0/zRcDemy o687zwA37dObz1H6vqFgNdclpYp1FSCT7eWPvn1OJRFcMNEMLnnkvs4sC51M2ENWVYGr mICHSwZTdAhdO+TjtSjBOcF91gkBE0FZ3pp4f3N9LQnEHkL0Mc7lU/o9TIcyD36cTkHY lixQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=kwq4bRCS12E0pwS24n4DF6fH8vCgV1gHSX9jQZdeS6s=; b=dtEfwBFDo5bDeQm0JhEO59xw/T31fyKZWoJlL0HSv1IKfHhQLkQhdWo2LyGmAhKGBG 8AVw1ZfoIL3zs6SV+0sz693aJTOZ8eNs/j3YyaLjw5PtZapPWHi6/QpTdN/cjeItG/VP SjO3wgS9lNOUHIeLC1A/+gHVlp4kOz/dTAvziS7IdkyZNwnXwEYM2gsDJLONqEA5BBan w15xlHA4eQVusFJ00depK1c2ZoAZAm0c1O+KGEqS09zI3AMK5C6CHX35i/PIpEVgROkP Av2R7Vm4vXIvlzxgTgX13XbRZnybopZbp7eeJQOOl6+sANZMwDLeDTR3NHM9VNq0s85o p3wQ== X-Gm-Message-State: APjAAAVN3UF33TYqkRMIlgQ9+2NBBdn3DHlwNX7dobnK2mjNg67J+cdS o8x8/tgg6DCbfrmsbdsBb/+6887B X-Google-Smtp-Source: APXvYqyxjivgvv73zW96VtSZxI22yvnDHc7cCN4ASChPKXooXyPhPA/WIc/rEhioFDy7noCqRiA47w== X-Received: by 2002:a62:1752:: with SMTP id 79mr30867645pfx.127.1552275765952; Sun, 10 Mar 2019 20:42:45 -0700 (PDT) Received: from archbookpro.localdomain (c-73-222-73-77.hsd1.ca.comcast.net. [73.222.73.77]) by smtp.gmail.com with ESMTPSA id v7sm6371764pga.50.2019.03.10.20.42.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 10 Mar 2019 20:42:45 -0700 (PDT) Date: Sun, 10 Mar 2019 20:42:43 -0700 From: Denton Liu To: Git Mailing List Cc: Phillip Wood , Junio C Hamano Subject: [PATCH v7 6/8] merge: add scissors line on merge conflict Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.3 (2019-02-01) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This fixes a bug where the scissors line is placed after the Conflicts: section, in the case where a merge conflict occurs and commit.cleanup = scissors. Next, if commit.cleanup = scissors is specified, don't produce a scissors line in commit if one already exists in the MERGE_MSG file. Signed-off-by: Denton Liu --- Documentation/merge-options.txt | 4 ++- builtin/commit.c | 20 ++++++++++---- builtin/merge.c | 14 ++++++++++ t/t7600-merge.sh | 46 +++++++++++++++++++++++++++++++++ 4 files changed, 78 insertions(+), 6 deletions(-) diff --git a/Documentation/merge-options.txt b/Documentation/merge-options.txt index 646100ea9a..c7b889d6f5 100644 --- a/Documentation/merge-options.txt +++ b/Documentation/merge-options.txt @@ -35,7 +35,9 @@ set to `no` at the beginning of them. --cleanup=:: This option determines how the merge message will be cleaned up before commiting or being passed on. See linkgit:git-commit[1] for more - details. + details. In addition, if the '' is given a value of `scissors`, + scissors will be appended to MERGE_MSG before being passed on in the + case of a merge conflict. --ff:: When the merge resolves as a fast-forward, only update the branch diff --git a/builtin/commit.c b/builtin/commit.c index 81e3bd21ca..d8c4626a68 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -668,6 +668,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix, const char *hook_arg2 = NULL; int clean_message_contents = (cleanup_mode != COMMIT_MSG_CLEANUP_NONE); int old_display_comment_prefix; + int merge_contains_scissors = 0; /* This checks and barfs if author is badly specified */ determine_author_info(author_ident); @@ -728,6 +729,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix, strbuf_addbuf(&sb, &message); hook_arg1 = "message"; } else if (!stat(git_path_merge_msg(the_repository), &statbuf)) { + size_t merge_msg_start; + /* * prepend SQUASH_MSG here if it exists and a * "merge --squash" was originally performed @@ -738,8 +741,14 @@ static int prepare_to_commit(const char *index_file, const char *prefix, hook_arg1 = "squash"; } else hook_arg1 = "merge"; + + merge_msg_start = sb.len; if (strbuf_read_file(&sb, git_path_merge_msg(the_repository), 0) < 0) die_errno(_("could not read MERGE_MSG")); + + if (cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS && + wt_status_locate_end(sb.buf + merge_msg_start, sb.len - merge_msg_start) < sb.len - merge_msg_start) + merge_contains_scissors = 1; } else if (!stat(git_path_squash_msg(the_repository), &statbuf)) { if (strbuf_read_file(&sb, git_path_squash_msg(the_repository), 0) < 0) die_errno(_("could not read SQUASH_MSG")); @@ -807,7 +816,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix, struct ident_split ci, ai; if (whence != FROM_COMMIT) { - if (cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS) + if (cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS && + !merge_contains_scissors) wt_status_add_cut_line(s->fp); status_printf_ln(s, GIT_COLOR_NORMAL, whence == FROM_MERGE @@ -832,10 +842,10 @@ static int prepare_to_commit(const char *index_file, const char *prefix, _("Please enter the commit message for your changes." " Lines starting\nwith '%c' will be ignored, and an empty" " message aborts the commit.\n"), comment_line_char); - else if (cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS && - whence == FROM_COMMIT) - wt_status_add_cut_line(s->fp); - else /* COMMIT_MSG_CLEANUP_SPACE, that is. */ + else if (cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS) { + if (whence == FROM_COMMIT && !merge_contains_scissors) + wt_status_add_cut_line(s->fp); + } else /* COMMIT_MSG_CLEANUP_SPACE, that is. */ status_printf(s, GIT_COLOR_NORMAL, _("Please enter the commit message for your changes." " Lines starting\n" diff --git a/builtin/merge.c b/builtin/merge.c index 4f5fcf5ce9..b620d4bfcb 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -916,6 +916,20 @@ static int suggest_conflicts(void) filename = git_path_merge_msg(the_repository); fp = xfopen(filename, "a"); + /* + * We can't use cleanup_mode because if we're not using the editor, + * get_cleanup_mode will return COMMIT_MSG_CLEANUP_SPACE instead, even + * though the message is meant to be processed later by git-commit. + * Thus, we will get the cleanup mode which is returned when we _are_ using + * an editor. + */ + if (get_cleanup_mode(cleanup_arg, 1, 1) == COMMIT_MSG_CLEANUP_SCISSORS) { + fputc('\n', fp); + wt_status_add_cut_line(fp); + /* comments out the newline from append_conflicts_hint */ + fputc(comment_line_char, fp); + } + append_conflicts_hint(&the_index, &msgbuf); fputs(msgbuf.buf, fp); strbuf_release(&msgbuf); diff --git a/t/t7600-merge.sh b/t/t7600-merge.sh index d879efd330..2cb57e5878 100755 --- a/t/t7600-merge.sh +++ b/t/t7600-merge.sh @@ -246,6 +246,52 @@ test_expect_success 'merge --squash c3 with c7' ' test_cmp expect actual ' +test_expect_success 'merge c3 with c7 with commit.cleanup = scissors' ' + git config commit.cleanup scissors && + git reset --hard c3 && + test_must_fail git merge c7 && + cat result.9z >file && + git commit --no-edit -a && + + cat >expect <<-EOF && + Merge tag '"'"'c7'"'"' + + # ------------------------ >8 ------------------------ + # Do not modify or remove the line above. + # Everything below it will be ignored. + # + # Conflicts: + # file + EOF + git cat-file commit HEAD >tmp && + sed -e '1,/^$/d' actual && + test_i18ncmp expect actual +' + +test_expect_success 'merge c3 with c7 with --squash commit.cleanup = scissors' ' + git config commit.cleanup scissors && + git reset --hard c3 && + test_must_fail git merge --squash c7 && + cat result.9z >file && + git commit --no-edit -a && + + cat >expect <<-EOF && + Squashed commit of the following: + + $(git show -s c7) + + # ------------------------ >8 ------------------------ + # Do not modify or remove the line above. + # Everything below it will be ignored. + # + # Conflicts: + # file + EOF + git cat-file commit HEAD >tmp && + sed -e '1,/^$/d' actual && + test_i18ncmp expect actual +' + test_debug 'git log --graph --decorate --oneline --all' test_expect_success 'merge c1 with c2 and c3' ' From patchwork Mon Mar 11 03:42:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 10846661 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 4A7D46C2 for ; Mon, 11 Mar 2019 03:42:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3440828EF8 for ; Mon, 11 Mar 2019 03:42:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2875428F21; Mon, 11 Mar 2019 03:42:52 +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 A347B28EF8 for ; Mon, 11 Mar 2019 03:42:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727346AbfCKDmu (ORCPT ); Sun, 10 Mar 2019 23:42:50 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:34362 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726933AbfCKDmu (ORCPT ); Sun, 10 Mar 2019 23:42:50 -0400 Received: by mail-pg1-f193.google.com with SMTP id u65so2973655pgc.1 for ; Sun, 10 Mar 2019 20:42:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=COQBjWuta7+SEoo8IPZ/H5mlXXdjS66poQogYpgwd5w=; b=MYZURh4XAfnS2DRSWlsX4yzbmIxs5QweJIfJtBpFquSA6vdRtJviplDFlXTtK6l2cn nciJ0p6enahLNFtxtitKXqbhJgr40Hw6jV0uvlCoSXOlR4ct3wRrboQHVFCcrurlEPGV sXtoUMG8Q+eJr1V988tnTWG55hQpZImSJnAYEvRBiQl5nOS90BYpNxp6YBF6NtAHUIJc hrmQg0UYfmBUS5LKegI22+BHHuuBAO0hke9akbZYR+F5eiEF/wva2hfp86Ex9WR5Ytcw ws8RHMJtLA8irb+0d2/TWswt8gikK6NdnMxPohrNYGxlaE+SkKcWbET4mDIlPGwjK9Zq DwnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=COQBjWuta7+SEoo8IPZ/H5mlXXdjS66poQogYpgwd5w=; b=f7RwsvFRCOYF6oMPsgBO6nmzhxxXJHg1Lwsw6oILDwZ22GYA5c2N31WAqotb3DDkn4 kl2kNRybpvhTa/nqbK+m4fCLLyeMoqBPZJL3K3sVDNCgT/rLdGvKBvSE/pKV9eaTCgun BY3x/SAZjYQ8GIWyisf1yrminRa8+qpe9qYsrUCMQgYnWgnQiKXwnbbpHaB7W12kyiSo MytGPJLqWhtDFzKUxe5AJDhrWtwFSIsoz4u7T/slBoGO6XOimKlyCp6s9MbhkYq7bC9O 63g6UI/7J3UWR9jb0KIhOjZUMUvsUqOEoxPmgP8SMRrS+adeBSRrRznk+4XcJZNs7vJy H0sw== X-Gm-Message-State: APjAAAX/VjnrmNdi2EHVThHGddM7m0lrXv1EpU0BV10FC6r295Mw8YiE PNgEwALVwc45W/R+FGERtnMD+Z1o X-Google-Smtp-Source: APXvYqzjHzXZ1vR81sss1M2afVLkm0ch21C1DbDMIbqK3MbZnwZpXu186MgguC1eMCQsAuRfwAwGLw== X-Received: by 2002:a17:902:2a48:: with SMTP id i66mr30899164plb.14.1552275768777; Sun, 10 Mar 2019 20:42:48 -0700 (PDT) Received: from archbookpro.localdomain (c-73-222-73-77.hsd1.ca.comcast.net. [73.222.73.77]) by smtp.gmail.com with ESMTPSA id v9sm6529380pfg.130.2019.03.10.20.42.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 10 Mar 2019 20:42:48 -0700 (PDT) Date: Sun, 10 Mar 2019 20:42:46 -0700 From: Denton Liu To: Git Mailing List Cc: Phillip Wood , Junio C Hamano Subject: [PATCH v7 7/8] sequencer.c: define get_config_from_cleanup Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.3 (2019-02-01) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Define a function which allows us to get the string configuration value of a enum commit_msg_cleanup_mode. This is done by refactoring get_cleanup_mode such that it uses a lookup table to find the mappings between string and enum and then using the same LUT in reverse to define get_config_from_cleanup. Signed-off-by: Denton Liu --- sequencer.c | 67 +++++++++++++++++++++++++++++++++++++++++------------ sequencer.h | 1 + 2 files changed, 53 insertions(+), 15 deletions(-) diff --git a/sequencer.c b/sequencer.c index 612621f221..5d94e2c865 100644 --- a/sequencer.c +++ b/sequencer.c @@ -160,6 +160,22 @@ static GIT_PATH_FUNC(rebase_path_strategy_opts, "rebase-merge/strategy_opts") static GIT_PATH_FUNC(rebase_path_allow_rerere_autoupdate, "rebase-merge/allow_rerere_autoupdate") static GIT_PATH_FUNC(rebase_path_reschedule_failed_exec, "rebase-merge/reschedule-failed-exec") +struct cleanup_config_mapping { + const char *config_value; + enum commit_msg_cleanup_mode editor_cleanup; + enum commit_msg_cleanup_mode no_editor_cleanup; +}; + +/* note that we assume that cleanup_config_mapping[0] contains the default settings */ +struct cleanup_config_mapping cleanup_config_mappings[] = { + { "default", COMMIT_MSG_CLEANUP_ALL, COMMIT_MSG_CLEANUP_SPACE }, + { "verbatim", COMMIT_MSG_CLEANUP_NONE, COMMIT_MSG_CLEANUP_NONE }, + { "whitespace", COMMIT_MSG_CLEANUP_SPACE, COMMIT_MSG_CLEANUP_SPACE }, + { "strip", COMMIT_MSG_CLEANUP_ALL, COMMIT_MSG_CLEANUP_ALL }, + { "scissors", COMMIT_MSG_CLEANUP_SCISSORS, COMMIT_MSG_CLEANUP_SPACE }, + { NULL, 0, 0 } +}; + static int git_sequencer_config(const char *k, const char *v, void *cb) { struct replay_opts *opts = cb; @@ -504,26 +520,42 @@ static int fast_forward_to(struct repository *r, enum commit_msg_cleanup_mode get_cleanup_mode(const char *cleanup_arg, int use_editor, int die_on_error) { - if (!cleanup_arg || !strcmp(cleanup_arg, "default")) - return use_editor ? COMMIT_MSG_CLEANUP_ALL : - COMMIT_MSG_CLEANUP_SPACE; - else if (!strcmp(cleanup_arg, "verbatim")) - return COMMIT_MSG_CLEANUP_NONE; - else if (!strcmp(cleanup_arg, "whitespace")) - return COMMIT_MSG_CLEANUP_SPACE; - else if (!strcmp(cleanup_arg, "strip")) - return COMMIT_MSG_CLEANUP_ALL; - else if (!strcmp(cleanup_arg, "scissors")) - return use_editor ? COMMIT_MSG_CLEANUP_SCISSORS : - COMMIT_MSG_CLEANUP_SPACE; - else if (!die_on_error) { + struct cleanup_config_mapping *default_mapping = &cleanup_config_mappings[0]; + struct cleanup_config_mapping *current_mapping; + + if (!cleanup_arg) { + return use_editor ? default_mapping->editor_cleanup : + default_mapping->no_editor_cleanup; + } + + for (current_mapping = cleanup_config_mappings; current_mapping->config_value; current_mapping++) { + if (!strcmp(cleanup_arg, current_mapping->config_value)) { + return use_editor ? current_mapping->editor_cleanup : + current_mapping->no_editor_cleanup; + } + } + + if (!die_on_error) { warning(_("Invalid cleanup mode %s, falling back to default"), cleanup_arg); - return use_editor ? COMMIT_MSG_CLEANUP_ALL : - COMMIT_MSG_CLEANUP_SPACE; + return use_editor ? default_mapping->editor_cleanup : + default_mapping->no_editor_cleanup; } else die(_("Invalid cleanup mode %s"), cleanup_arg); } +const char *get_config_from_cleanup(enum commit_msg_cleanup_mode cleanup_mode) +{ + struct cleanup_config_mapping *current_mapping; + + for (current_mapping = &cleanup_config_mappings[1]; current_mapping->config_value; current_mapping++) { + if (cleanup_mode == current_mapping->editor_cleanup) { + return current_mapping->config_value; + } + } + + BUG(_("invalid cleanup_mode provided")); +} + void append_conflicts_hint(struct index_state *istate, struct strbuf *msgbuf) { @@ -2350,6 +2382,8 @@ static int populate_opts_cb(const char *key, const char *value, void *data) opts->allow_rerere_auto = git_config_bool_or_int(key, value, &error_flag) ? RERERE_AUTOUPDATE : RERERE_NOAUTOUPDATE; + else if (!strcmp(key, "options.default-msg-cleanup")) + opts->default_msg_cleanup = get_cleanup_mode(value, 1, 1); else return error(_("invalid key: %s"), key); @@ -2754,6 +2788,9 @@ static int save_opts(struct replay_opts *opts) res |= git_config_set_in_file_gently(opts_file, "options.allow-rerere-auto", opts->allow_rerere_auto == RERERE_AUTOUPDATE ? "true" : "false"); + + res |= git_config_set_in_file_gently(opts_file, "options.default-msg-cleanup", + get_config_from_cleanup(opts->default_msg_cleanup)); return res; } diff --git a/sequencer.h b/sequencer.h index e7908f558e..e3c1f44807 100644 --- a/sequencer.h +++ b/sequencer.h @@ -118,6 +118,7 @@ void append_signoff(struct strbuf *msgbuf, size_t ignore_footer, unsigned flag); void append_conflicts_hint(struct index_state *istate, struct strbuf *msgbuf); enum commit_msg_cleanup_mode get_cleanup_mode(const char *cleanup_arg, int use_editor, int die_on_error); +const char *get_config_from_cleanup(enum commit_msg_cleanup_mode cleanup_mode); void cleanup_message(struct strbuf *msgbuf, enum commit_msg_cleanup_mode cleanup_mode, int verbose); From patchwork Mon Mar 11 03:42:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 10846663 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 0B1D21390 for ; Mon, 11 Mar 2019 03:42:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E4B4428EF8 for ; Mon, 11 Mar 2019 03:42:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D669128F21; Mon, 11 Mar 2019 03:42:55 +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 F212F28EF8 for ; Mon, 11 Mar 2019 03:42:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727349AbfCKDmx (ORCPT ); Sun, 10 Mar 2019 23:42:53 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:40232 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726933AbfCKDmx (ORCPT ); Sun, 10 Mar 2019 23:42:53 -0400 Received: by mail-pf1-f195.google.com with SMTP id h1so2682157pfo.7 for ; Sun, 10 Mar 2019 20:42:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=H1LWfN6vl2Eba+GE65H81XSPwWjJOnQdeaN4Wu74MPU=; b=obeXSDZBg22SLlw/DRq50jh19dmaf1hcugtOYR3eWYg/JyxudtrdYKqSOdDAHwyEZc Wg1bY1OZLDyLvqSWn07ha+cDFXe2zDFmUfO8Wq32xhcuhfF7S7WAGYMQl7WTj/neDzks FzNk+YNmLfgsIbgDn6F1jrJBBCKAHtk01Ee2vXyv7rpjZX655d8piVh2jxUbgSvM9ppe x67yBtAwB1hPkaQpJZMO3Zjd/YxXSPpVdI75ESuJj/BP36VypZppsi9RO69+BwAIsaaD b1465uHl82gX+npF8y7dmj3KgDIxAGrV6JCzv8HQu5qvdRSujmxQYRrhXTBYP0F1aLaA 17Qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=H1LWfN6vl2Eba+GE65H81XSPwWjJOnQdeaN4Wu74MPU=; b=E5DYbPuzTyUMEgMQjUPNu21SNERT0FIxOVd9mjno1TLsG5F5z85Bnu490B6oujeLWc HnkkyRSxbUf/ssHXhNmGl7CsHNA/UN48w5jAFC/w8EqKzawkJ1va+vSQqavV5y/jEiEe CC/X/l1EN4AFM7d8uVD5S9tBly0JGHirQBNZdbV3E8CzTTB33ZgYiJGMOJjvw8VklqDX tZnG7qzGe9UqcCbvho9mEZSi1AwpaIH6X+UpBl4VlhUH3E0F7lLjDrlH6AgNlFELkD2P 5o0e8vZn2T6p9nj72yxcOzvQWkPf/w0aylx4S7+Z+DwPJkD0NzpfgA/y2XOlnjog+dgW EMxQ== X-Gm-Message-State: APjAAAUEJ4ChNhNr/wCxtiKt1J7qQ2YE8HAuxXVSp8tgpYXX071afA4u OEt7S1TeVPtAZkFULIdYQ57Iroqk X-Google-Smtp-Source: APXvYqxYlExQFIYbKoCKB7zcynGSM7pgf5MNFyQyXhzE24AawP8JCv+e5U2bOeTlLf7EgNh4cToc2w== X-Received: by 2002:a63:d4f:: with SMTP id 15mr28293144pgn.162.1552275771439; Sun, 10 Mar 2019 20:42:51 -0700 (PDT) Received: from archbookpro.localdomain (c-73-222-73-77.hsd1.ca.comcast.net. [73.222.73.77]) by smtp.gmail.com with ESMTPSA id t23sm7079695pfa.111.2019.03.10.20.42.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 10 Mar 2019 20:42:50 -0700 (PDT) Date: Sun, 10 Mar 2019 20:42:49 -0700 From: Denton Liu To: Git Mailing List Cc: Phillip Wood , Junio C Hamano Subject: [PATCH v7 8/8] cherry-pick/revert: add scissors line on merge conflict Message-ID: <5b30d939674542b2cfeeeef8341ab25c7d6c0543.1552275703.git.liu.denton@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.3 (2019-02-01) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Fix a bug where the scissors line is placed after the Conflicts: section, in the case where a merge conflict occurs and commit.cleanup = scissors. Signed-off-by: Denton Liu --- Documentation/git-cherry-pick.txt | 7 +++ Documentation/git-revert.txt | 7 +++ builtin/merge.c | 9 +--- builtin/rebase--interactive.c | 2 +- builtin/revert.c | 5 ++ sequencer.c | 22 +++++--- sequencer.h | 3 +- t/t3507-cherry-pick-conflict.sh | 86 +++++++++++++++++++++++++++++++ 8 files changed, 123 insertions(+), 18 deletions(-) diff --git a/Documentation/git-cherry-pick.txt b/Documentation/git-cherry-pick.txt index b8cfeec67e..b4ff8e136d 100644 --- a/Documentation/git-cherry-pick.txt +++ b/Documentation/git-cherry-pick.txt @@ -57,6 +57,13 @@ OPTIONS With this option, 'git cherry-pick' will let you edit the commit message prior to committing. +--cleanup=:: + This option determines how the commit message will be cleaned up before + being passed on. See linkgit:git-commit[1] for more details. In + addition, if the '' is given a value of `scissors`, scissors will + be appended to MERGE_MSG before being passed on in the case of a + conflict. + -x:: When recording the commit, append a line that says "(cherry picked from commit ...)" to the original commit diff --git a/Documentation/git-revert.txt b/Documentation/git-revert.txt index 837707a8fd..bd4ad395a9 100644 --- a/Documentation/git-revert.txt +++ b/Documentation/git-revert.txt @@ -66,6 +66,13 @@ more details. With this option, 'git revert' will not start the commit message editor. +--cleanup=:: + This option determines how the commit message will be cleaned up before + being passed on. See linkgit:git-commit[1] for more details. In + addition, if the '' is given a value of `scissors`, scissors will + be appended to MERGE_MSG before being passed on in the case of a + conflict. + -n:: --no-commit:: Usually the command automatically creates some commits with diff --git a/builtin/merge.c b/builtin/merge.c index b620d4bfcb..671d6a19a4 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -923,14 +923,7 @@ static int suggest_conflicts(void) * Thus, we will get the cleanup mode which is returned when we _are_ using * an editor. */ - if (get_cleanup_mode(cleanup_arg, 1, 1) == COMMIT_MSG_CLEANUP_SCISSORS) { - fputc('\n', fp); - wt_status_add_cut_line(fp); - /* comments out the newline from append_conflicts_hint */ - fputc(comment_line_char, fp); - } - - append_conflicts_hint(&the_index, &msgbuf); + append_conflicts_hint(&the_index, &msgbuf, get_cleanup_mode(cleanup_arg, 1, 1)); fputs(msgbuf.buf, fp); strbuf_release(&msgbuf); fclose(fp); diff --git a/builtin/rebase--interactive.c b/builtin/rebase--interactive.c index 888390f911..cf2151b271 100644 --- a/builtin/rebase--interactive.c +++ b/builtin/rebase--interactive.c @@ -199,10 +199,10 @@ int cmd_rebase__interactive(int argc, const char **argv, const char *prefix) OPT_END() }; + opts.action = REPLAY_INTERACTIVE_REBASE; sequencer_init_config(&opts); git_config_get_bool("rebase.abbreviatecommands", &abbreviate_commands); - opts.action = REPLAY_INTERACTIVE_REBASE; opts.allow_ff = 1; opts.allow_empty = 1; diff --git a/builtin/revert.c b/builtin/revert.c index a47b53ceaf..e8168e0214 100644 --- a/builtin/revert.c +++ b/builtin/revert.c @@ -96,11 +96,13 @@ static int run_sequencer(int argc, const char **argv, struct replay_opts *opts) { const char * const * usage_str = revert_or_cherry_pick_usage(opts); const char *me = action_name(opts); + const char *cleanup_arg = NULL; int cmd = 0; struct option base_options[] = { 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_STRING(0, "cleanup", &cleanup_arg, N_("default"), N_("how to strip spaces and #comments from message")), OPT_BOOL('n', "no-commit", &opts->no_commit, N_("don't automatically commit")), OPT_BOOL('e', "edit", &opts->edit, N_("edit the commit message")), OPT_NOOP_NOARG('r', NULL), @@ -137,6 +139,9 @@ static int run_sequencer(int argc, const char **argv, struct replay_opts *opts) if (opts->keep_redundant_commits) opts->allow_empty = 1; + if (cleanup_arg) + opts->default_msg_cleanup = get_cleanup_mode(cleanup_arg, 1, 1); + /* Check for incompatible command line arguments */ if (cmd) { char *this_operation; diff --git a/sequencer.c b/sequencer.c index 5d94e2c865..496554a474 100644 --- a/sequencer.c +++ b/sequencer.c @@ -176,6 +176,11 @@ struct cleanup_config_mapping cleanup_config_mappings[] = { { NULL, 0, 0 } }; +static inline int is_rebase_i(const struct replay_opts *opts) +{ + return opts->action == REPLAY_INTERACTIVE_REBASE; +} + static int git_sequencer_config(const char *k, const char *v, void *cb) { struct replay_opts *opts = cb; @@ -188,7 +193,7 @@ static int git_sequencer_config(const char *k, const char *v, void *cb) if (status) return status; - opts->default_msg_cleanup = get_cleanup_mode(s, 0, 0); + opts->default_msg_cleanup = get_cleanup_mode(s, !is_rebase_i(opts), 0); free((char *)s); return status; @@ -212,11 +217,6 @@ void sequencer_init_config(struct replay_opts *opts) git_config(git_sequencer_config, opts); } -static inline int is_rebase_i(const struct replay_opts *opts) -{ - return opts->action == REPLAY_INTERACTIVE_REBASE; -} - static const char *get_dir(const struct replay_opts *opts) { if (is_rebase_i(opts)) @@ -557,10 +557,16 @@ const char *get_config_from_cleanup(enum commit_msg_cleanup_mode cleanup_mode) } void append_conflicts_hint(struct index_state *istate, - struct strbuf *msgbuf) + struct strbuf *msgbuf, enum commit_msg_cleanup_mode cleanup_mode) { int i; + if (cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS) { + strbuf_addch(msgbuf, '\n'); + wt_status_append_cut_line(msgbuf); + strbuf_addch(msgbuf, comment_line_char); + } + strbuf_addch(msgbuf, '\n'); strbuf_commented_addf(msgbuf, "Conflicts:\n"); for (i = 0; i < istate->cache_nr;) { @@ -628,7 +634,7 @@ static int do_recursive_merge(struct repository *r, _(action_name(opts))); if (!clean) - append_conflicts_hint(r->index, msgbuf); + append_conflicts_hint(r->index, msgbuf, opts->default_msg_cleanup); return !clean; } diff --git a/sequencer.h b/sequencer.h index e3c1f44807..95ff9db508 100644 --- a/sequencer.h +++ b/sequencer.h @@ -115,7 +115,8 @@ int rearrange_squash(struct repository *r); */ void append_signoff(struct strbuf *msgbuf, size_t ignore_footer, unsigned flag); -void append_conflicts_hint(struct index_state *istate, struct strbuf *msgbuf); +void append_conflicts_hint(struct index_state *istate, + struct strbuf *msgbuf, enum commit_msg_cleanup_mode cleanup_mode); enum commit_msg_cleanup_mode get_cleanup_mode(const char *cleanup_arg, int use_editor, int die_on_error); const char *get_config_from_cleanup(enum commit_msg_cleanup_mode cleanup_mode); diff --git a/t/t3507-cherry-pick-conflict.sh b/t/t3507-cherry-pick-conflict.sh index 74ff925526..c3894ca9d6 100755 --- a/t/t3507-cherry-pick-conflict.sh +++ b/t/t3507-cherry-pick-conflict.sh @@ -189,6 +189,46 @@ test_expect_success 'failed cherry-pick registers participants in index' ' test_cmp expected actual ' +test_expect_success \ + 'cherry-pick conflict, ensure commit.cleanup = scissors places scissors line properly' ' + pristine_detach initial && + git config commit.cleanup scissors && + cat <<-EOF >expected && + picked + + # ------------------------ >8 ------------------------ + # Do not modify or remove the line above. + # Everything below it will be ignored. + # + # Conflicts: + # foo + EOF + + test_must_fail git cherry-pick picked && + + test_i18ncmp expected .git/MERGE_MSG +' + +test_expect_success \ + 'cherry-pick conflict, ensure cleanup=scissors places scissors line properly' ' + pristine_detach initial && + git config --unset commit.cleanup && + cat <<-EOF >expected && + picked + + # ------------------------ >8 ------------------------ + # Do not modify or remove the line above. + # Everything below it will be ignored. + # + # Conflicts: + # foo + EOF + + test_must_fail git cherry-pick --cleanup=scissors picked && + + test_i18ncmp expected .git/MERGE_MSG +' + test_expect_success 'failed cherry-pick describes conflict in work tree' ' pristine_detach initial && cat <<-EOF >expected && @@ -335,6 +375,52 @@ test_expect_success 'revert conflict, diff3 -m style' ' test_cmp expected actual ' +test_expect_success \ + 'revert conflict, ensure commit.cleanup = scissors places scissors line properly' ' + pristine_detach initial && + git config commit.cleanup scissors && + cat >expected <<-EOF && + Revert "picked" + + This reverts commit OBJID. + + # ------------------------ >8 ------------------------ + # Do not modify or remove the line above. + # Everything below it will be ignored. + # + # Conflicts: + # foo + EOF + + test_must_fail git revert picked && + + sed "s/$OID_REGEX/OBJID/" .git/MERGE_MSG >actual && + test_i18ncmp expected actual +' + +test_expect_success \ + 'revert conflict, ensure cleanup=scissors places scissors line properly' ' + pristine_detach initial && + git config --unset commit.cleanup && + cat >expected <<-EOF && + Revert "picked" + + This reverts commit OBJID. + + # ------------------------ >8 ------------------------ + # Do not modify or remove the line above. + # Everything below it will be ignored. + # + # Conflicts: + # foo + EOF + + test_must_fail git revert --cleanup=scissors picked && + + sed "s/$OID_REGEX/OBJID/" .git/MERGE_MSG >actual && + test_i18ncmp expected actual +' + test_expect_success 'failed cherry-pick does not forget -s' ' pristine_detach initial && test_must_fail git cherry-pick -s picked &&