From patchwork Sun Jan 24 17:03:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charvi Mendiratta X-Patchwork-Id: 12042535 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EF892C433E6 for ; Sun, 24 Jan 2021 17:06:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BBFB322CF6 for ; Sun, 24 Jan 2021 17:06:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726468AbhAXRGm (ORCPT ); Sun, 24 Jan 2021 12:06:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726408AbhAXRGi (ORCPT ); Sun, 24 Jan 2021 12:06:38 -0500 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E41DAC061573 for ; Sun, 24 Jan 2021 09:05:57 -0800 (PST) Received: by mail-pf1-x42f.google.com with SMTP id i63so7004853pfg.7 for ; Sun, 24 Jan 2021 09:05:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cVwqRHiCPVOdFvi8BGeDd6ox9vceEwe8HnBQfQjgJgU=; b=MVaCjdDnyU6jGBB8USEBY+s2Yb65gUuMGYSRsxRglGVJ/WdLzl3SJrhihAS26EOYJD 4InSWvERPpzNr02qD/RuoFm0dY1c9sH7XgH7p9blQAI9F1VARc4Dxc5g1bv9m6UCdrlS /MKigCTqTL3sX1d917YDhtV/5huEJzAtJQSFJIFgRnjO2RpetHEUL7MhrPc5OpxdPNqD EcZwYby933brmvd+qMBDyMTfz9cMKn6fMo2FkBOXKUvYUSibH8bG61A+2IN87tpdHszM hlCq2vIy5kIyoyTfw34kgd6hLX2A82tOM0rer+QLcB7ooYuD82F1uTA9TU2BWLY740p5 gadg== 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=cVwqRHiCPVOdFvi8BGeDd6ox9vceEwe8HnBQfQjgJgU=; b=jLC3NzbFwP1WMmjPwrXbc5zvw6rtsg40LoQcqbgE+wNLws9S0BTL7nx2HdKN/x5xKj xmdPXqq+lfyT+YtXnkhp1AgA6cHGlDOeVtw3LJL6HlUfhB8SQzMXVfJgnKIdgJlBR5AP 8/y8DfwfPb+cocTGgGk7AQEcSToAqh8jBgV6GpZK+p5AdjzxBWcsAbk8CQgBgPw44+2/ 7cHaxv7wbHJMl2mt7qeXiXv/y3DdldwNXH9BDEFqFdZgUzzb7R2pGk+1LbKk5ziqoAqG /9NGC5n/CPPHDC4WjyE1N1H1azp0wo1oJrmQxdtewSxDDAfzPzLjdp29mQDGkWmbNGlr BuPQ== X-Gm-Message-State: AOAM533BEgybM0Wg2gaExbwm6o5+O3V6BNcku9hHBOm33HyXFUDWKGx8 wVyDwmKIRLwoiNkJ6jiXtxkCZTa++lhkHg== X-Google-Smtp-Source: ABdhPJyVCGjI1Ot2Bt6lDEphrzd7mrL2MrYRH47Q450JyriDG4IbRaqZWPna0mdRKr1yahsp/7RCxQ== X-Received: by 2002:a63:af05:: with SMTP id w5mr3929795pge.22.1611507957276; Sun, 24 Jan 2021 09:05:57 -0800 (PST) Received: from localhost.localdomain ([2409:4050:2d0e:58a:f516:739c:ea0e:a6ba]) by smtp.googlemail.com with ESMTPSA id r30sm16283308pjg.43.2021.01.24.09.05.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Jan 2021 09:05:55 -0800 (PST) From: Charvi Mendiratta To: git@vger.kernel.org Cc: gitster@pobox.com, christian.couder@gmail.com, marcnarc@xiplink.com, phillip.wood123@gmail.com, Phillip Wood , Taylor Blau , Charvi Mendiratta Subject: [PATCH v3 1/9] rebase -i: only write fixup-message when it's needed Date: Sun, 24 Jan 2021 22:33:59 +0530 Message-Id: <20210124170405.30583-2-charvi077@gmail.com> X-Mailer: git-send-email 2.29.0.rc1 In-Reply-To: <20210124170405.30583-1-charvi077@gmail.com> References: <20210119074102.21598-1-charvi077@gmail.com> <20210124170405.30583-1-charvi077@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Phillip Wood The file "$GIT_DIR/rebase-merge/fixup-message" is only used for fixup commands, there's no point in writing it for squash commands as it is immediately deleted. Signed-off-by: Phillip Wood Reviewed-by: Taylor Blau Signed-off-by: Charvi Mendiratta --- sequencer.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sequencer.c b/sequencer.c index 8909a46770..a59e0c84af 100644 --- a/sequencer.c +++ b/sequencer.c @@ -1757,11 +1757,10 @@ static int update_squash_messages(struct repository *r, return error(_("could not read HEAD's commit message")); find_commit_subject(head_message, &body); - if (write_message(body, strlen(body), - rebase_path_fixup_msg(), 0)) { + if (command == TODO_FIXUP && write_message(body, strlen(body), + rebase_path_fixup_msg(), 0) < 0) { unuse_commit_buffer(head_commit, head_message); - return error(_("cannot write '%s'"), - rebase_path_fixup_msg()); + return error(_("cannot write '%s'"), rebase_path_fixup_msg()); } strbuf_addf(&buf, "%c ", comment_line_char); From patchwork Sun Jan 24 17:04:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charvi Mendiratta X-Patchwork-Id: 12042537 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 377F6C433E0 for ; Sun, 24 Jan 2021 17:07:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F402D22D50 for ; Sun, 24 Jan 2021 17:07:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726498AbhAXRG7 (ORCPT ); Sun, 24 Jan 2021 12:06:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726496AbhAXRG5 (ORCPT ); Sun, 24 Jan 2021 12:06:57 -0500 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FAC9C061574 for ; Sun, 24 Jan 2021 09:06:14 -0800 (PST) Received: by mail-pj1-x1033.google.com with SMTP id cq1so6855193pjb.4 for ; Sun, 24 Jan 2021 09:06:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wq7AT0GeWUiw6/y3jlwDs7feIY/g4Gw8ax680CWXrw4=; b=cmFZwvsGWKeLU3WEsrm+YyeT6TSkRvK462oJztaL5hyUGUfJ/KuNOEofYkf+VZgtcC vK6yBQ+zLnhu7EBMNlBGgohlkxe63LyfDiUy+ubWJMS3d9M2xNj2oFo+3H10mjuX5cxI om9Jw0FJSO3RfQ8S7kTb1eYfv0VPEVDUrUKzwD/dFCR5ZuwLnzerGvygqYATvZiXy8TT xJZM1upsVK1iC/RYec7KufVP1KeqxKT0lvQvTAIwh5tWkxyxdAX6D/Loy0mke7ufkBOo ENA0S3IVoM+7xtRoUQ97toloAAvIAao4pxIh05QsMOtsnOFMZkugLDIFr74PRVFCOpVT peUg== 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=wq7AT0GeWUiw6/y3jlwDs7feIY/g4Gw8ax680CWXrw4=; b=ZZ/4Yo6UWoRViWE2mZRmfrxJuX5028jjDxTghLGISQqfGOykFrvwWFj8uLvAUlkTPy KXIuvL/H5svRYXOjgVdUrnPvbYPIqjv3pYqAyvbHuooLmpow5LPrCVH6MtrhpQcOEOax ipIKS97MuZWvF3WrDxBJZCc+y2L5NTTgwc0ahOUJfjoTF6nd+bEgpJgM73khOMsjO9u2 GmgTcSH2mxwtCWyS6p+zAtXg5ertKz1NNxjGpbIJ+XcTa061OOn3psJjkOQ+GsVzombT M9VIQ4VQy5LcbXrTEHeZFUiY87uE45ykNGxywJj8Y+y4iVzavE20MG2ps5rqH1vTC9yq sp8w== X-Gm-Message-State: AOAM533WojUkXpGhr4vDV1T5w4KDVE5cbgbS9TwN4C8O/cFiB/+/bOSh Tyt+S06v+OBdsGshZH8XOSf5SFmUBT5vnA== X-Google-Smtp-Source: ABdhPJyO3fQTjtG8R3pzaVnriRr+uxhNOx6Gvkjx8rwkWDhQVLXC+olu/WvNVSwbc1FtIP8SlJ+rqQ== X-Received: by 2002:a17:902:ecca:b029:de:b5bc:c852 with SMTP id a10-20020a170902eccab02900deb5bcc852mr15232806plh.59.1611507973801; Sun, 24 Jan 2021 09:06:13 -0800 (PST) Received: from localhost.localdomain ([2409:4050:2d0e:58a:f516:739c:ea0e:a6ba]) by smtp.googlemail.com with ESMTPSA id r30sm16283308pjg.43.2021.01.24.09.06.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Jan 2021 09:06:13 -0800 (PST) From: Charvi Mendiratta To: git@vger.kernel.org Cc: gitster@pobox.com, christian.couder@gmail.com, marcnarc@xiplink.com, phillip.wood123@gmail.com, Phillip Wood , Charvi Mendiratta Subject: [PATCH v3 2/9] sequencer: factor out code to append squash message Date: Sun, 24 Jan 2021 22:34:00 +0530 Message-Id: <20210124170405.30583-3-charvi077@gmail.com> X-Mailer: git-send-email 2.29.0.rc1 In-Reply-To: <20210124170405.30583-1-charvi077@gmail.com> References: <20210119074102.21598-1-charvi077@gmail.com> <20210124170405.30583-1-charvi077@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Phillip Wood This code is going to grow over the next two commits so move it to its own function. Signed-off-by: Phillip Wood Signed-off-by: Charvi Mendiratta --- sequencer.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/sequencer.c b/sequencer.c index a59e0c84af..08cce40834 100644 --- a/sequencer.c +++ b/sequencer.c @@ -1718,6 +1718,17 @@ static int is_pick_or_similar(enum todo_command command) } } +static void append_squash_message(struct strbuf *buf, const char *body, + struct replay_opts *opts) +{ + unlink(rebase_path_fixup_msg()); + strbuf_addf(buf, "\n%c ", comment_line_char); + strbuf_addf(buf, _("This is the commit message #%d:"), + ++opts->current_fixup_count + 1); + strbuf_addstr(buf, "\n\n"); + strbuf_addstr(buf, body); +} + static int update_squash_messages(struct repository *r, enum todo_command command, struct commit *commit, @@ -1779,12 +1790,7 @@ static int update_squash_messages(struct repository *r, find_commit_subject(message, &body); if (command == TODO_SQUASH) { - unlink(rebase_path_fixup_msg()); - strbuf_addf(&buf, "\n%c ", comment_line_char); - strbuf_addf(&buf, _("This is the commit message #%d:"), - ++opts->current_fixup_count + 1); - strbuf_addstr(&buf, "\n\n"); - strbuf_addstr(&buf, body); + append_squash_message(&buf, body, opts); } else if (command == TODO_FIXUP) { strbuf_addf(&buf, "\n%c ", comment_line_char); strbuf_addf(&buf, _("The commit message #%d will be skipped:"), From patchwork Sun Jan 24 17:04:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charvi Mendiratta X-Patchwork-Id: 12042539 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47801C433DB for ; Sun, 24 Jan 2021 17:07:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1814522D57 for ; Sun, 24 Jan 2021 17:07:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726510AbhAXRHH (ORCPT ); Sun, 24 Jan 2021 12:07:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726496AbhAXRHE (ORCPT ); Sun, 24 Jan 2021 12:07:04 -0500 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E80B2C06174A for ; Sun, 24 Jan 2021 09:06:23 -0800 (PST) Received: by mail-pl1-x630.google.com with SMTP id j21so1527913pls.7 for ; Sun, 24 Jan 2021 09:06:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WFSvJI4HWdlqPsuyHfJaHF6gCnCek3dG5CYQpyo/Mc0=; b=WJ69N8y9qTeeeCngsygB5ULxaazNNQB47/i55zbwXdCXeQN3zuhoNYOMoKFYhNfMJv E9hVY6hgtrIHYuGxAv3n0TqvDP9dvbS6RrKF2n9+1cV9jgpg63cnFtodRqKVPUqUDgQ9 PIDu540lxIjztgVucFTcE3XABp1qEgFKRRoavPy6csdkg38HOQlsc7OPsXoPziqUy2m9 X/PkuOGRRtZLIlxD+V3HB0urC8yXWSQbWQCPng66X6jUavV9WhzkUlX0iCSP1wFE6wvq Lc4AILOoMdGBmImYXYfTYIylTIRyVa3owV6hFqs6eWGmwyI/wY1b2I2bGIHdqeFlvoKK t0ZA== 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=WFSvJI4HWdlqPsuyHfJaHF6gCnCek3dG5CYQpyo/Mc0=; b=VEuPMpem6mLhuXECB1G1ri9FsS4g+Y4eSj9Aj+8w3tHZqNOkiRev6WkKUp6LCXrbZq cucRC6sPdgioFMUKE6mrNU+T09gWrc4GRH4ethNWdy4euHFId7Y3Cna4A2XehR3N0Tda fr0HldN2cmrEHTwOG/XfYGpQ4uvFlmayhE0tnI112IDAkrfqxBMfZXt9E1MLf0w1ZjIf Q/6LtX4E4fLGKaw6UHnKPZGv+RlCY333Yx8Glu0yrJFd3LIiqUfmxzEtV7DMXXGunV+8 +XhVUuwrBvIZggdjcpmst8+I8Tvd1tvrpXcjGuHRo7XHDM8eeVGo/EPT+A5BQmPHVlSx 8I1w== X-Gm-Message-State: AOAM530LYFEOSYhQ0hP9C4K8wZXSfRcL0n8mi9nKMbhrd3Op+/X4B2+B HSBrnesIPJ5QCzNy7pAzFXXTcIQ2ME0hdA== X-Google-Smtp-Source: ABdhPJxkiootP5gSiCcCrQ7E8Si5HtwQgZbOPZVsCCOIl0tJz8h8grSwsoaMrkFomMkW0MuD+d3dZQ== X-Received: by 2002:a17:90a:4314:: with SMTP id q20mr9387988pjg.87.1611507983218; Sun, 24 Jan 2021 09:06:23 -0800 (PST) Received: from localhost.localdomain ([2409:4050:2d0e:58a:f516:739c:ea0e:a6ba]) by smtp.googlemail.com with ESMTPSA id r30sm16283308pjg.43.2021.01.24.09.06.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Jan 2021 09:06:22 -0800 (PST) From: Charvi Mendiratta To: git@vger.kernel.org Cc: gitster@pobox.com, christian.couder@gmail.com, marcnarc@xiplink.com, phillip.wood123@gmail.com, Phillip Wood , Taylor Blau , Charvi Mendiratta Subject: [PATCH v3 3/9] rebase -i: comment out squash!/fixup! subjects from squash message Date: Sun, 24 Jan 2021 22:34:01 +0530 Message-Id: <20210124170405.30583-4-charvi077@gmail.com> X-Mailer: git-send-email 2.29.0.rc1 In-Reply-To: <20210124170405.30583-1-charvi077@gmail.com> References: <20210119074102.21598-1-charvi077@gmail.com> <20210124170405.30583-1-charvi077@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Phillip Wood When squashing commit messages the squash!/fixup! subjects are not of interest so comment them out to stop them becoming part of the final message. This change breaks a bunch of --autosquash tests which rely on the "squash! " line appearing in the final commit message. This is addressed by adding a second line to the commit message of the "squash! ..." commits and testing for that. Signed-off-by: Phillip Wood Reviewed-by: Taylor Blau Signed-off-by: Charvi Mendiratta --- sequencer.c | 21 ++++++++++++++++++++- t/t3415-rebase-autosquash.sh | 30 ++++++++++++++++-------------- t/t3900-i18n-commit.sh | 4 ---- 3 files changed, 36 insertions(+), 19 deletions(-) diff --git a/sequencer.c b/sequencer.c index 08cce40834..034149f24d 100644 --- a/sequencer.c +++ b/sequencer.c @@ -1718,15 +1718,34 @@ static int is_pick_or_similar(enum todo_command command) } } +static size_t subject_length(const char *body) +{ + const char *p = body; + while (*p) { + const char *next = skip_blank_lines(p); + if (next != p) + break; + p = strchrnul(p, '\n'); + if (*p) + p++; + } + return p - body; +} + static void append_squash_message(struct strbuf *buf, const char *body, struct replay_opts *opts) { + size_t commented_len = 0; + unlink(rebase_path_fixup_msg()); + if (starts_with(body, "squash!") || starts_with(body, "fixup!")) + commented_len = subject_length(body); strbuf_addf(buf, "\n%c ", comment_line_char); strbuf_addf(buf, _("This is the commit message #%d:"), ++opts->current_fixup_count + 1); strbuf_addstr(buf, "\n\n"); - strbuf_addstr(buf, body); + strbuf_add_commented_lines(buf, body, commented_len); + strbuf_addstr(buf, body + commented_len); } static int update_squash_messages(struct repository *r, diff --git a/t/t3415-rebase-autosquash.sh b/t/t3415-rebase-autosquash.sh index 7bab6000dc..a512335527 100755 --- a/t/t3415-rebase-autosquash.sh +++ b/t/t3415-rebase-autosquash.sh @@ -81,8 +81,7 @@ test_auto_squash () { echo 1 >file1 && git add -u && test_tick && - git commit -m "squash! first" && - + git commit -m "squash! first" -m "extra para for first" && git tag $1 && test_tick && git rebase $2 -i HEAD^^^ && @@ -139,7 +138,7 @@ test_expect_success 'auto squash that matches 2 commits' ' echo 1 >file1 && git add -u && test_tick && - git commit -m "squash! first" && + git commit -m "squash! first" -m "extra para for first" && git tag final-multisquash && test_tick && git rebase --autosquash -i HEAD~4 && @@ -192,7 +191,7 @@ test_expect_success 'auto squash that matches a sha1' ' git add -u && test_tick && oid=$(git rev-parse --short HEAD^) && - git commit -m "squash! $oid" && + git commit -m "squash! $oid" -m "extra para" && git tag final-shasquash && test_tick && git rebase --autosquash -i HEAD^^^ && @@ -203,7 +202,8 @@ test_expect_success 'auto squash that matches a sha1' ' git cat-file blob HEAD^:file1 >actual && test_cmp expect actual && git cat-file commit HEAD^ >commit && - grep squash commit >actual && + ! grep -v "squash" commit && + grep "^extra para" commit >actual && test_line_count = 1 actual ' @@ -213,7 +213,7 @@ test_expect_success 'auto squash that matches longer sha1' ' git add -u && test_tick && oid=$(git rev-parse --short=11 HEAD^) && - git commit -m "squash! $oid" && + git commit -m "squash! $oid" -m "extra para" && git tag final-longshasquash && test_tick && git rebase --autosquash -i HEAD^^^ && @@ -224,7 +224,8 @@ test_expect_success 'auto squash that matches longer sha1' ' git cat-file blob HEAD^:file1 >actual && test_cmp expect actual && git cat-file commit HEAD^ >commit && - grep squash commit >actual && + ! grep -v "squash" commit && + grep "^extra para" commit >actual && test_line_count = 1 actual ' @@ -233,7 +234,7 @@ test_auto_commit_flags () { echo 1 >file1 && git add -u && test_tick && - git commit --$1 first-commit && + git commit --$1 first-commit -m "extra para for first" && git tag final-commit-$1 && test_tick && git rebase --autosquash -i HEAD^^^ && @@ -261,11 +262,11 @@ test_auto_fixup_fixup () { echo 1 >file1 && git add -u && test_tick && - git commit -m "$1! first" && + git commit -m "$1! first" -m "extra para for first" && echo 2 >file1 && git add -u && test_tick && - git commit -m "$1! $2! first" && + git commit -m "$1! $2! first" -m "second extra para for first" && git tag "final-$1-$2" && test_tick && ( @@ -326,12 +327,12 @@ test_expect_success C_LOCALE_OUTPUT 'autosquash with custom inst format' ' git add -u && test_tick && oid=$(git rev-parse --short HEAD^) && - git commit -m "squash! $oid" && + git commit -m "squash! $oid" -m "extra para for first" && echo 1 >file1 && git add -u && test_tick && subject=$(git log -n 1 --format=%s HEAD~2) && - git commit -m "squash! $subject" && + git commit -m "squash! $subject" -m "second extra para for first" && git tag final-squash-instFmt && test_tick && git rebase --autosquash -i HEAD~4 && @@ -342,8 +343,9 @@ test_expect_success C_LOCALE_OUTPUT 'autosquash with custom inst format' ' git cat-file blob HEAD^:file1 >actual && test_cmp expect actual && git cat-file commit HEAD^ >commit && - grep squash commit >actual && - test_line_count = 2 actual + ! grep -v "squash" commit && + grep first commit >actual && + test_line_count = 3 actual ' test_expect_success 'autosquash with empty custom instructionFormat' ' diff --git a/t/t3900-i18n-commit.sh b/t/t3900-i18n-commit.sh index d277a9f4b7..bfab245eb3 100755 --- a/t/t3900-i18n-commit.sh +++ b/t/t3900-i18n-commit.sh @@ -226,10 +226,6 @@ test_commit_autosquash_multi_encoding () { git rev-list HEAD >actual && test_line_count = 3 actual && iconv -f $old -t UTF-8 "$TEST_DIRECTORY"/t3900/$msg >expect && - if test $flag = squash; then - subject="$(head -1 expect)" && - printf "\nsquash! %s\n" "$subject" >>expect - fi && git cat-file commit HEAD^ >raw && (sed "1,/^$/d" raw | iconv -f $new -t utf-8) >actual && test_cmp expect actual From patchwork Sun Jan 24 17:04:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charvi Mendiratta X-Patchwork-Id: 12042541 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 63316C433E6 for ; Sun, 24 Jan 2021 17:07:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 328BC22D58 for ; Sun, 24 Jan 2021 17:07:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726515AbhAXRHP (ORCPT ); Sun, 24 Jan 2021 12:07:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726496AbhAXRHL (ORCPT ); Sun, 24 Jan 2021 12:07:11 -0500 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59D6EC061756 for ; Sun, 24 Jan 2021 09:06:31 -0800 (PST) Received: by mail-pj1-x102f.google.com with SMTP id j12so6854863pjy.5 for ; Sun, 24 Jan 2021 09:06:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AKNDGS89h3BP7A+kc9sS7Cfxp6AlmTx76lu6cpG0xto=; b=XE9+lW8l8YymCHFPn5Cg/vjITDvGkoNmjjPkyc/d3C5c1cyZASukr9iXO6gOZoWuUt Rrt1da5+AR6aOTqY7K9PpE7O9thzXLCFcN1HKy80A+hbQVLIGvCk0NEyJsavaIg2jv4Y 0YVtrFo03F5+YmfDaiW40weTxqnWzPt8Kuo8saMIeNgid4k33nlmnkWlVksgyNZo16GS vaYMDlFLKzg66zcJMda+MmSfep8wRiVOmb3rQ+fGiMddY4hNfgRiApimRkKXN5CcxMhm Fq07sfC87quGbhBIGclrqQskDP7CHCjKGp3yWi1xVbCjA+Ym5XucPchI2qzONnc6YYkD 4K/g== 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=AKNDGS89h3BP7A+kc9sS7Cfxp6AlmTx76lu6cpG0xto=; b=G/bmUH22eIPsWnis/o/YzBUmrZ2a1wQBC1A6Dr4oeRzBaMbsXuPD3he+xzY2bac+Vx or/49d/CPfpMdOhH7cGwcGEnFtd1RROjBgUbxrymZxEcOgFM+A3ZTit2PXFLD90o4Au7 rqVkXCK7WqhpwVrlYSpFnIP7uWLi9f0ZlnuUQXdQHBxP7Fr7VeNf+SJPGaIS33nQFEAi KYqKJhCDFQGwnMD6JYXTcNZz4C5EDBy2Oo4rrT8vTaoA/aKQrOw0izxt4hxmfviGBEae wdeUKyBRcP/rQxa2y8N8tNFhZiYPLit1qM2lWGMFxZC5Re45s5/2swz7N4zqr/ObHKSI Yb+w== X-Gm-Message-State: AOAM533m2pIf4ye1lqgbppYUghwsF1UAt6iQc/nanzVliHfJ+XeHXWzn vpEEp5U2WHrExXVMm/YrVF6MiNmV7i12pQ== X-Google-Smtp-Source: ABdhPJzRVmhG3YoUC3vDWHi8cpe3m4v/smGhaa2XoEuZuuD4kvj2hZnZ75HyfXfKBQ0oqbexiQ2SUg== X-Received: by 2002:a17:90a:a44:: with SMTP id o62mr17302954pjo.209.1611507990751; Sun, 24 Jan 2021 09:06:30 -0800 (PST) Received: from localhost.localdomain ([2409:4050:2d0e:58a:f516:739c:ea0e:a6ba]) by smtp.googlemail.com with ESMTPSA id r30sm16283308pjg.43.2021.01.24.09.06.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Jan 2021 09:06:30 -0800 (PST) From: Charvi Mendiratta To: git@vger.kernel.org Cc: gitster@pobox.com, christian.couder@gmail.com, marcnarc@xiplink.com, phillip.wood123@gmail.com, Charvi Mendiratta , Christian Couder , Phillip Wood Subject: [PATCH v3 4/9] sequencer: pass todo_item to do_pick_commit() Date: Sun, 24 Jan 2021 22:34:02 +0530 Message-Id: <20210124170405.30583-5-charvi077@gmail.com> X-Mailer: git-send-email 2.29.0.rc1 In-Reply-To: <20210124170405.30583-1-charvi077@gmail.com> References: <20210119074102.21598-1-charvi077@gmail.com> <20210124170405.30583-1-charvi077@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org As an additional member of the structure todo_item will be required in future commits pass the complete structure. Mentored-by: Christian Couder Mentored-by: Phillip Wood Signed-off-by: Charvi Mendiratta --- sequencer.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/sequencer.c b/sequencer.c index 034149f24d..09cbb17f87 100644 --- a/sequencer.c +++ b/sequencer.c @@ -1877,8 +1877,7 @@ static void record_in_rewritten(struct object_id *oid, } static int do_pick_commit(struct repository *r, - enum todo_command command, - struct commit *commit, + struct todo_item *item, struct replay_opts *opts, int final_fixup, int *check_todo) { @@ -1891,6 +1890,8 @@ static int do_pick_commit(struct repository *r, struct commit_message msg = { NULL, NULL, NULL, NULL }; struct strbuf msgbuf = STRBUF_INIT; int res, unborn = 0, reword = 0, allow, drop_commit; + enum todo_command command = item->command; + struct commit *commit = item->commit; if (opts->no_commit) { /* @@ -4140,8 +4141,8 @@ static int pick_commits(struct repository *r, setenv(GIT_REFLOG_ACTION, reflog_message(opts, command_to_string(item->command), NULL), 1); - res = do_pick_commit(r, item->command, item->commit, - opts, is_final_fixup(todo_list), + res = do_pick_commit(r, item, opts, + is_final_fixup(todo_list), &check_todo); if (is_rebase_i(opts)) setenv(GIT_REFLOG_ACTION, prev_reflog_action, 1); @@ -4603,11 +4604,14 @@ static int single_pick(struct repository *r, struct replay_opts *opts) { int check_todo; + struct todo_item item; + + item.command = opts->action == REPLAY_PICK ? + TODO_PICK : TODO_REVERT; + item.commit = cmit; setenv(GIT_REFLOG_ACTION, action_name(opts), 0); - return do_pick_commit(r, opts->action == REPLAY_PICK ? - TODO_PICK : TODO_REVERT, cmit, opts, 0, - &check_todo); + return do_pick_commit(r, &item, opts, 0, &check_todo); } int sequencer_pick_revisions(struct repository *r, From patchwork Sun Jan 24 17:04:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charvi Mendiratta X-Patchwork-Id: 12042543 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6091C433E0 for ; Sun, 24 Jan 2021 17:07:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8810B22D57 for ; Sun, 24 Jan 2021 17:07:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726530AbhAXRHc (ORCPT ); Sun, 24 Jan 2021 12:07:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726524AbhAXRHU (ORCPT ); Sun, 24 Jan 2021 12:07:20 -0500 Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D755C0613D6 for ; Sun, 24 Jan 2021 09:06:40 -0800 (PST) Received: by mail-pg1-x529.google.com with SMTP id n7so7338255pgg.2 for ; Sun, 24 Jan 2021 09:06:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+sN6HX1BqV3b1XdRd5cbt+4ED2RdKrpGKUBRJZU//UU=; b=ezpVNRi81eD9RjPJaLarA7xXtvNB51L47fGG8YrX+TwB52JI02MmsFaTW9U9p70jZM 42y+qLVL8XO1MAAggzKvCnyNcRlB4I1AtibhjUzq0Du58tmixz3mBI450q7x6DMjWr68 ZjAf0sP8cGS4kCA+cnN6o+al8g++xctiKzzhHf9dF95kfJ7QFiZdTqeGDjCJvb74LarK uaJMYVSpFkrrowKoQtdzcWphCuaSwuhb7K/C4DFC6ThDEqeKUwVXFBiBfXJqTH97RHQU YQfbSsKMSJ0KOx4x4kyD86SR4DJUfqQdaxiOws+2XKqRifs8v77W1COyCgz2gJGYZVcq GyPw== 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=+sN6HX1BqV3b1XdRd5cbt+4ED2RdKrpGKUBRJZU//UU=; b=stWJRIEZmxR/W8oLGQR3bJlT6c0tkXHoD8UnfDZuyOOVQSjHK7psZsC4SPMrMsnzu3 TaclFh4HvklnJ3nf3+ldjwCfup2ZljilhKX7AoIjP/qGqMQj/jwu/D5eGGKsU7VslOCz MYzvKzJRf9MqDiXGqGYMrNzG8HzTgPeGoOaEb2yND2Qu7z9NJiKEZ3e9JLJFeKAD39xT riM360Cv1jVH91l1VS+qUUi4dC6GifPih3gbK1gBt2fvMHcN9TEXQfT8/jkRc3nQCxTl ieXfy0+CB/GIRhUPUGJzGD7UEad1MtcO/UT3R1XI1f8Hc5ikYJFTsU7pPpwLYXcoUYl5 0Dhg== X-Gm-Message-State: AOAM533ePt9ie5xvy5j74HI5pXX1COOT1f/Iv7oU3tEsuR92fdzqyPO9 6bn/XHphdW8Sy55i+SKyFtxQdfkUyoNvpA== X-Google-Smtp-Source: ABdhPJx3kw7cPHXxnsdv99Aq9VXCIRwKjSBxxUpDpWw7GjAvZ+2F8XZcmoWz7u9IPOG2K94dSnLsEQ== X-Received: by 2002:a62:2f07:0:b029:1bb:5f75:f985 with SMTP id v7-20020a622f070000b02901bb5f75f985mr8400262pfv.76.1611507999210; Sun, 24 Jan 2021 09:06:39 -0800 (PST) Received: from localhost.localdomain ([2409:4050:2d0e:58a:f516:739c:ea0e:a6ba]) by smtp.googlemail.com with ESMTPSA id r30sm16283308pjg.43.2021.01.24.09.06.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Jan 2021 09:06:38 -0800 (PST) From: Charvi Mendiratta To: git@vger.kernel.org Cc: gitster@pobox.com, christian.couder@gmail.com, marcnarc@xiplink.com, phillip.wood123@gmail.com, Charvi Mendiratta , Christian Couder , Phillip Wood , Taylor Blau Subject: [PATCH v3 5/9] sequencer: use const variable for commit message comments Date: Sun, 24 Jan 2021 22:34:03 +0530 Message-Id: <20210124170405.30583-6-charvi077@gmail.com> X-Mailer: git-send-email 2.29.0.rc1 In-Reply-To: <20210124170405.30583-1-charvi077@gmail.com> References: <20210119074102.21598-1-charvi077@gmail.com> <20210124170405.30583-1-charvi077@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org This makes it easier to use and reuse the comments. Mentored-by: Christian Couder Mentored-by: Phillip Wood Reviewed-by: Taylor Blau Signed-off-by: Charvi Mendiratta --- sequencer.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/sequencer.c b/sequencer.c index 09cbb17f87..6d9a10afcf 100644 --- a/sequencer.c +++ b/sequencer.c @@ -1732,6 +1732,11 @@ static size_t subject_length(const char *body) return p - body; } +static const char first_commit_msg_str[] = N_("This is the 1st commit message:"); +static const char nth_commit_msg_fmt[] = N_("This is the commit message #%d:"); +static const char skip_nth_commit_msg_fmt[] = N_("The commit message #%d will be skipped:"); +static const char combined_commit_msg_fmt[] = N_("This is a combination of %d commits."); + static void append_squash_message(struct strbuf *buf, const char *body, struct replay_opts *opts) { @@ -1741,7 +1746,7 @@ static void append_squash_message(struct strbuf *buf, const char *body, if (starts_with(body, "squash!") || starts_with(body, "fixup!")) commented_len = subject_length(body); strbuf_addf(buf, "\n%c ", comment_line_char); - strbuf_addf(buf, _("This is the commit message #%d:"), + strbuf_addf(buf, _(nth_commit_msg_fmt), ++opts->current_fixup_count + 1); strbuf_addstr(buf, "\n\n"); strbuf_add_commented_lines(buf, body, commented_len); @@ -1770,7 +1775,7 @@ static int update_squash_messages(struct repository *r, buf.buf : strchrnul(buf.buf, '\n'); strbuf_addf(&header, "%c ", comment_line_char); - strbuf_addf(&header, _("This is a combination of %d commits."), + strbuf_addf(&header, _(combined_commit_msg_fmt), opts->current_fixup_count + 2); strbuf_splice(&buf, 0, eol - buf.buf, header.buf, header.len); strbuf_release(&header); @@ -1794,9 +1799,9 @@ static int update_squash_messages(struct repository *r, } strbuf_addf(&buf, "%c ", comment_line_char); - strbuf_addf(&buf, _("This is a combination of %d commits."), 2); + strbuf_addf(&buf, _(combined_commit_msg_fmt), 2); strbuf_addf(&buf, "\n%c ", comment_line_char); - strbuf_addstr(&buf, _("This is the 1st commit message:")); + strbuf_addstr(&buf, _(first_commit_msg_str)); strbuf_addstr(&buf, "\n\n"); strbuf_addstr(&buf, body); @@ -1812,7 +1817,7 @@ static int update_squash_messages(struct repository *r, append_squash_message(&buf, body, opts); } else if (command == TODO_FIXUP) { strbuf_addf(&buf, "\n%c ", comment_line_char); - strbuf_addf(&buf, _("The commit message #%d will be skipped:"), + strbuf_addf(&buf, _(skip_nth_commit_msg_fmt), ++opts->current_fixup_count + 1); strbuf_addstr(&buf, "\n\n"); strbuf_add_commented_lines(&buf, body, strlen(body)); From patchwork Sun Jan 24 17:04:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charvi Mendiratta X-Patchwork-Id: 12042545 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0CF28C433E0 for ; Sun, 24 Jan 2021 17:07:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D422D22D57 for ; Sun, 24 Jan 2021 17:07:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726177AbhAXRHh (ORCPT ); Sun, 24 Jan 2021 12:07:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726525AbhAXRH1 (ORCPT ); Sun, 24 Jan 2021 12:07:27 -0500 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3367DC061573 for ; Sun, 24 Jan 2021 09:06:47 -0800 (PST) Received: by mail-pj1-x1035.google.com with SMTP id g15so7046148pjd.2 for ; Sun, 24 Jan 2021 09:06:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qLdX+uJa7pmuGOF1e2UIUg5ApTu+AhYbVa4GCRNkpGU=; b=Wfvn225PV0lXJDpSOjD3LNQrmpabfofhbQErsCkt7uJOok2ZYDDqIMG1w7fTmIMrFq QCBiwmaWAqIWaLFto5Hj2Hw+z9+PH9iJb5YGDqGVXEqLNfj45a0bk4WUbwYneoqzKJTS 20x6hgOfr29c4wfNey0eSzpDCxgpab2vIttlAdQvZNJXWEf8BsIwlyCQehe7aUNXl+XN liar37cc2ftsuWmsfKi+bGyRULdDnQUA6UMWqS/66UuchrmCEnk7PThWT9StRW1/BpaQ m3QG+H6u6CjSfw2IJYokfVwTXZi2bcONJOQY/2bs+wlRNHsSl5Vpd+tp4nXAyZkhJchH Gbwg== 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=qLdX+uJa7pmuGOF1e2UIUg5ApTu+AhYbVa4GCRNkpGU=; b=qeDIu6smhmWta2IH79h/xYBCy8he84KfIRvz9VfSWVleSUW2UjcvfQ3iDukVRzd4w9 12N+Z3Ne8IsEoebxkIPdVec7EUKJZsduSvmRvRw7ttjQ9Gxgz5VGdWxKloVMx3xcd+44 UcdXi4ux4uzrjq6c5NviOlKYX9MSqg52jY1313Y4A9vn6O8VnJF7W8f5v8VSNVbqrT2r Rl4TtZ+rKOTuM6KzSUo8xu9xkfmBQZrG77qZ2FdmGVrAmpxIAHykyylZFow4kju2lClU hz3jEJUg8a7gDD4wDOwaEf6uwcNldw8FOSzvXbazmObBo4kmcz8qlq9aCHl/N6lfKR42 CmSA== X-Gm-Message-State: AOAM5301wHZcT/ULxqlUOIkhzWpJeRVuqogYvyS7N0v40sSzGzO2/l7Q ZFptWKaJT5EyPA+4Sh+l3zx5jbKS/GCONg== X-Google-Smtp-Source: ABdhPJyPCKuhAp1KiMgeDNCYG/o7qBzngy2c4rWPcDN6iYYMIA/ddnLfVFR6XcVbThCrMUnaPS+OSQ== X-Received: by 2002:a17:90a:a88e:: with SMTP id h14mr17192520pjq.59.1611508006411; Sun, 24 Jan 2021 09:06:46 -0800 (PST) Received: from localhost.localdomain ([2409:4050:2d0e:58a:f516:739c:ea0e:a6ba]) by smtp.googlemail.com with ESMTPSA id r30sm16283308pjg.43.2021.01.24.09.06.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Jan 2021 09:06:45 -0800 (PST) From: Charvi Mendiratta To: git@vger.kernel.org Cc: gitster@pobox.com, christian.couder@gmail.com, marcnarc@xiplink.com, phillip.wood123@gmail.com, Charvi Mendiratta , Phillip Wood , Christian Couder Subject: [PATCH v3 6/9] rebase -i: add fixup [-C | -c] command Date: Sun, 24 Jan 2021 22:34:04 +0530 Message-Id: <20210124170405.30583-7-charvi077@gmail.com> X-Mailer: git-send-email 2.29.0.rc1 In-Reply-To: <20210124170405.30583-1-charvi077@gmail.com> References: <20210119074102.21598-1-charvi077@gmail.com> <20210124170405.30583-1-charvi077@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Add options to `fixup` command to fixup both the commit contents and message. `fixup -C` command is used to replace the original commit message and `fixup -c`, additionally allows to edit the commit message. Original-patch-by: Phillip Wood Mentored-by: Christian Couder Mentored-by: Phillip Wood Signed-off-by: Charvi Mendiratta --- rebase-interactive.c | 4 +- sequencer.c | 213 +++++++++++++++++++++++++++++++++++++++---- 2 files changed, 197 insertions(+), 20 deletions(-) diff --git a/rebase-interactive.c b/rebase-interactive.c index 762853bc7e..c3bd02adee 100644 --- a/rebase-interactive.c +++ b/rebase-interactive.c @@ -44,7 +44,9 @@ void append_todo_help(int command_count, "r, reword = use commit, but edit the commit message\n" "e, edit = use commit, but stop for amending\n" "s, squash = use commit, but meld into previous commit\n" -"f, fixup = like \"squash\", but discard this commit's log message\n" +"f, fixup [-C | -c] = like \"squash\", but discard this\n" +" commit's log message. Use -C to replace with this\n" +" commit message or -c to edit the commit message\n" "x, exec = run command (the rest of the line) using shell\n" "b, break = stop here (continue rebase later with 'git rebase --continue')\n" "d, drop = remove commit\n" diff --git a/sequencer.c b/sequencer.c index 6d9a10afcf..46e11d20e8 100644 --- a/sequencer.c +++ b/sequencer.c @@ -1718,6 +1718,12 @@ static int is_pick_or_similar(enum todo_command command) } } +enum todo_item_flags { + TODO_EDIT_MERGE_MSG = (1 << 0), + TODO_REPLACE_FIXUP_MSG = (1 << 1), + TODO_EDIT_FIXUP_MSG = (1 << 2), +}; + static size_t subject_length(const char *body) { const char *p = body; @@ -1734,32 +1740,176 @@ static size_t subject_length(const char *body) static const char first_commit_msg_str[] = N_("This is the 1st commit message:"); static const char nth_commit_msg_fmt[] = N_("This is the commit message #%d:"); +static const char skip_first_commit_msg_str[] = N_("The 1st commit message will be skipped:"); static const char skip_nth_commit_msg_fmt[] = N_("The commit message #%d will be skipped:"); static const char combined_commit_msg_fmt[] = N_("This is a combination of %d commits."); -static void append_squash_message(struct strbuf *buf, const char *body, - struct replay_opts *opts) +static int check_fixup_flag(enum todo_command command, + enum todo_item_flags flag) +{ + return command == TODO_FIXUP && ((flag & TODO_REPLACE_FIXUP_MSG) || + (flag & TODO_EDIT_FIXUP_MSG)); +} + +/* + * Wrapper around strbuf_add_commented_lines() which avoids double + * commenting commit subjects. + */ +static void add_commented_lines(struct strbuf *buf, const void *str, size_t len) +{ + const char *s = str; + while (len > 0 && s[0] == comment_line_char) { + size_t count; + const char *n = memchr(s, '\n', len); + if (!n) + count = len; + else + count = n - s + 1; + strbuf_add(buf, s, count); + s += count; + len -= count; + } + strbuf_add_commented_lines(buf, s, len); +} + +/* Does the current fixup chain contain a squash command? */ +static int seen_squash(struct replay_opts *opts) +{ + return starts_with(opts->current_fixups.buf, "squash") || + strstr(opts->current_fixups.buf, "\nsquash"); +} + +static void update_comment_bufs(struct strbuf *buf1, struct strbuf *buf2, int n) { - size_t commented_len = 0; + strbuf_setlen(buf1, 2); + strbuf_addf(buf1, _(nth_commit_msg_fmt), n); + strbuf_addch(buf1, '\n'); + strbuf_setlen(buf2, 2); + strbuf_addf(buf2, _(skip_nth_commit_msg_fmt), n); + strbuf_addch(buf2, '\n'); +} - unlink(rebase_path_fixup_msg()); - if (starts_with(body, "squash!") || starts_with(body, "fixup!")) +/* + * Comment out any un-commented commit messages, updating the message comments + * to say they will be skipped but do not comment out the empty lines that + * surround commit messages and their comments. + */ +static void update_squash_message_for_fixup(struct strbuf *msg) +{ + void (*copy_lines)(struct strbuf *, const void *, size_t) = strbuf_add; + struct strbuf buf1 = STRBUF_INIT, buf2 = STRBUF_INIT; + const char *s, *start; + char *orig_msg; + size_t orig_msg_len; + int i = 1; + + strbuf_addf(&buf1, "# %s\n", _(first_commit_msg_str)); + strbuf_addf(&buf2, "# %s\n", _(skip_first_commit_msg_str)); + s = start = orig_msg = strbuf_detach(msg, &orig_msg_len); + while (s) { + const char *next; + size_t off; + if (skip_prefix(s, buf1.buf, &next)) { + /* + * Copy the last message, preserving the blank line + * preceding the current line + */ + off = (s > start + 1 && s[-2] == '\n') ? 1 : 0; + copy_lines(msg, start, s - start - off); + if (off) + strbuf_addch(msg, '\n'); + /* + * The next message needs to be commented out but the + * message header is already commented out so just copy + * it and the blank line that follows it. + */ + strbuf_addbuf(msg, &buf2); + if (*next == '\n') + strbuf_addch(msg, *next++); + start = s = next; + copy_lines = add_commented_lines; + update_comment_bufs(&buf1, &buf2, ++i); + } else if (skip_prefix(s, buf2.buf, &next)) { + off = (s > start + 1 && s[-2] == '\n') ? 1 : 0; + copy_lines(msg, start, s - start - off); + start = s - off; + s = next; + copy_lines = strbuf_add; + update_comment_bufs(&buf1, &buf2, ++i); + } else { + s = strchr(s, '\n'); + if (s) + s++; + } + } + copy_lines(msg, start, orig_msg_len - (start - orig_msg)); + free(orig_msg); + strbuf_release(&buf1); + strbuf_release(&buf2); +} + +static int append_squash_message(struct strbuf *buf, const char *body, + enum todo_command command, struct replay_opts *opts, + enum todo_item_flags flag) +{ + const char *fixup_msg; + size_t commented_len = 0, fixup_off; + /* + * amend is non-interactive and not normally used with fixup! + * or squash! commits, so only comment out those subjects when + * squashing commit messages. + */ + if (starts_with(body, "amend!") || + ((command == TODO_SQUASH || seen_squash(opts)) && + (starts_with(body, "squash!") || starts_with(body, "fixup!")))) commented_len = subject_length(body); + strbuf_addf(buf, "\n%c ", comment_line_char); strbuf_addf(buf, _(nth_commit_msg_fmt), ++opts->current_fixup_count + 1); strbuf_addstr(buf, "\n\n"); strbuf_add_commented_lines(buf, body, commented_len); + /* buf->buf may be reallocated so store an offset into the buffer */ + fixup_off = buf->len; strbuf_addstr(buf, body + commented_len); + + /* fixup -C after squash behaves like squash */ + if (check_fixup_flag(command, flag) && !seen_squash(opts)) { + /* + * We're replacing the commit message so we need to + * append the Signed-off-by: trailer if the user + * requested '--signoff'. + */ + if (opts->signoff) + append_signoff(buf, 0, 0); + + if ((command == TODO_FIXUP) && + (flag & TODO_REPLACE_FIXUP_MSG) && + (file_exists(rebase_path_fixup_msg()) || + !file_exists(rebase_path_squash_msg()))) { + fixup_msg = skip_blank_lines(buf->buf + fixup_off); + if (write_message(fixup_msg, strlen(fixup_msg), + rebase_path_fixup_msg(), 0) < 0) + return error(_("cannot write '%s'"), + rebase_path_fixup_msg()); + } else { + unlink(rebase_path_fixup_msg()); + } + } else { + unlink(rebase_path_fixup_msg()); + } + + return 0; } static int update_squash_messages(struct repository *r, enum todo_command command, struct commit *commit, - struct replay_opts *opts) + struct replay_opts *opts, + enum todo_item_flags flag) { struct strbuf buf = STRBUF_INIT; - int res; + int res = 0; const char *message, *body; const char *encoding = get_commit_output_encoding(); @@ -1779,6 +1929,8 @@ static int update_squash_messages(struct repository *r, opts->current_fixup_count + 2); strbuf_splice(&buf, 0, eol - buf.buf, header.buf, header.len); strbuf_release(&header); + if (check_fixup_flag(command, flag) && !seen_squash(opts)) + update_squash_message_for_fixup(&buf); } else { struct object_id head; struct commit *head_commit; @@ -1792,18 +1944,22 @@ static int update_squash_messages(struct repository *r, return error(_("could not read HEAD's commit message")); find_commit_subject(head_message, &body); - if (command == TODO_FIXUP && write_message(body, strlen(body), + if (command == TODO_FIXUP && !flag && write_message(body, strlen(body), rebase_path_fixup_msg(), 0) < 0) { unuse_commit_buffer(head_commit, head_message); return error(_("cannot write '%s'"), rebase_path_fixup_msg()); } - strbuf_addf(&buf, "%c ", comment_line_char); strbuf_addf(&buf, _(combined_commit_msg_fmt), 2); strbuf_addf(&buf, "\n%c ", comment_line_char); - strbuf_addstr(&buf, _(first_commit_msg_str)); + strbuf_addstr(&buf, check_fixup_flag(command, flag) ? + _(skip_first_commit_msg_str) : + _(first_commit_msg_str)); strbuf_addstr(&buf, "\n\n"); - strbuf_addstr(&buf, body); + if (check_fixup_flag(command, flag)) + strbuf_add_commented_lines(&buf, body, strlen(body)); + else + strbuf_addstr(&buf, body); unuse_commit_buffer(head_commit, head_message); } @@ -1813,8 +1969,8 @@ static int update_squash_messages(struct repository *r, oid_to_hex(&commit->object.oid)); find_commit_subject(message, &body); - if (command == TODO_SQUASH) { - append_squash_message(&buf, body, opts); + if (command == TODO_SQUASH || check_fixup_flag(command, flag)) { + res = append_squash_message(&buf, body, command, opts, flag); } else if (command == TODO_FIXUP) { strbuf_addf(&buf, "\n%c ", comment_line_char); strbuf_addf(&buf, _(skip_nth_commit_msg_fmt), @@ -1825,7 +1981,9 @@ static int update_squash_messages(struct repository *r, return error(_("unknown command: %d"), command); unuse_commit_buffer(commit, message); - res = write_message(buf.buf, buf.len, rebase_path_squash_msg(), 0); + if (!res) + res = write_message(buf.buf, buf.len, rebase_path_squash_msg(), + 0); strbuf_release(&buf); if (!res) { @@ -2026,7 +2184,8 @@ static int do_pick_commit(struct repository *r, if (command == TODO_REWORD) reword = 1; else if (is_fixup(command)) { - if (update_squash_messages(r, command, commit, opts)) + if (update_squash_messages(r, command, commit, + opts, item->flags)) return -1; flags |= AMEND_MSG; if (!final_fixup) @@ -2191,10 +2350,6 @@ static int read_and_refresh_cache(struct repository *r, return 0; } -enum todo_item_flags { - TODO_EDIT_MERGE_MSG = 1 -}; - void todo_list_release(struct todo_list *todo_list) { strbuf_release(&todo_list->buf); @@ -2281,6 +2436,18 @@ static int parse_insn_line(struct repository *r, struct todo_item *item, return 0; } + if (item->command == TODO_FIXUP) { + if (skip_prefix(bol, "-C", &bol) && + (*bol == ' ' || *bol == '\t')) { + bol += strspn(bol, " \t"); + item->flags |= TODO_REPLACE_FIXUP_MSG; + } else if (skip_prefix(bol, "-c", &bol) && + (*bol == ' ' || *bol == '\t')) { + bol += strspn(bol, " \t"); + item->flags |= TODO_EDIT_FIXUP_MSG; + } + } + if (item->command == TODO_MERGE) { if (skip_prefix(bol, "-C", &bol)) bol += strspn(bol, " \t"); @@ -5287,6 +5454,14 @@ static void todo_list_to_strbuf(struct repository *r, struct todo_list *todo_lis short_commit_name(item->commit) : oid_to_hex(&item->commit->object.oid); + if (item->command == TODO_FIXUP) { + if (item->flags & TODO_EDIT_FIXUP_MSG) + strbuf_addstr(buf, " -c"); + else if (item->flags & TODO_REPLACE_FIXUP_MSG) { + strbuf_addstr(buf, " -C"); + } + } + if (item->command == TODO_MERGE) { if (item->flags & TODO_EDIT_MERGE_MSG) strbuf_addstr(buf, " -c"); From patchwork Sun Jan 24 17:04:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charvi Mendiratta X-Patchwork-Id: 12042547 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0702FC433DB for ; Sun, 24 Jan 2021 17:07:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CD1CC22D57 for ; Sun, 24 Jan 2021 17:07:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726554AbhAXRHt (ORCPT ); Sun, 24 Jan 2021 12:07:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726540AbhAXRHf (ORCPT ); Sun, 24 Jan 2021 12:07:35 -0500 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F14B2C0613ED for ; Sun, 24 Jan 2021 09:06:54 -0800 (PST) Received: by mail-pl1-x631.google.com with SMTP id t6so6158103plq.1 for ; Sun, 24 Jan 2021 09:06:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NMhPi4eCfuYg0ONamdCX/xyYmKMLmLyJyx2MePXNztQ=; b=Gp+p4FnCPImVr7kzYSc1QlgDi5+nf348HIVFGBEk0miRqPDFab+R9atRUACWAQ+Unp RzaPMYYBDl5VBLNlqB6KJLVoLRdUUGKbdrzLaISK/vYtnmxu4TWoVsWEGv/XhoME9YZK 9Kaqd7rSwR3GaY5WNC5/k7/XmQ4QubQ13VaIFJReoxvi9NlJ0xGh1+D8GfPZ8+FcAHOv FQboErzHU01JgvGKPeQytJqEILOPocIDo4iTGjldEaJJIECZYbvaUz7YTIPAFksRlMhj 3tZnNCWwL6hjaW7UIsKSlhrJ/SQ/LA+Exj/fDzlm3qC+2jSqjt3W3R/KgyZy84KquqHN 5TKw== 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=NMhPi4eCfuYg0ONamdCX/xyYmKMLmLyJyx2MePXNztQ=; b=dEoSINbMTspgRAlNZLstscnJdCYWTa0eyM2vrmua3ROd9Raiibn1OFbRz1u7fLySqi 7hYexv9DLkwDYFd5GbFFxYYwjMkbQ28OEpbg/GMXTQDy4YCzEeBzKBHJY9gvBwRDI3Rl /4bJFwvA35pdy+aqnBqOOBDSWc4PZXTyDdnteaPtlfwMa7GJmA9c7nC5JYgRLw1UaRMq XAjxprimIBrAlVX00+8PCXq2btXGCLOwhjBbbA6e/ENH5DK/oa/+y2YEaAIWWaHY4Kh3 pYPC+dDiC7/QJAwqW3MVSCYdxSaF3JwkSYOB80z8tMRcVS9gwURPGAT0BCbXL6toyOvO 5ciQ== X-Gm-Message-State: AOAM533oNFjflkkIh+l7axHcKLztXGdl1DWLRVowOSXw52u1aAhpQKKA a2WRMXyepJb1SL7WHV1Q8bK0Dl+InvUPaw== X-Google-Smtp-Source: ABdhPJxtWvmDnsNU0bx72+wRLAcdIfNlkt38jLOgW66nhn+9OUAmW8PaXDGKZqNckyV9RyFGhbmYXQ== X-Received: by 2002:a17:90a:2e88:: with SMTP id r8mr17629220pjd.84.1611508014226; Sun, 24 Jan 2021 09:06:54 -0800 (PST) Received: from localhost.localdomain ([2409:4050:2d0e:58a:f516:739c:ea0e:a6ba]) by smtp.googlemail.com with ESMTPSA id r30sm16283308pjg.43.2021.01.24.09.06.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Jan 2021 09:06:53 -0800 (PST) From: Charvi Mendiratta To: git@vger.kernel.org Cc: gitster@pobox.com, christian.couder@gmail.com, marcnarc@xiplink.com, phillip.wood123@gmail.com, Charvi Mendiratta , Christian Couder , Phillip Wood Subject: [PATCH v3 7/9] t3437: test script for fixup [-C|-c] options in interactive rebase Date: Sun, 24 Jan 2021 22:34:05 +0530 Message-Id: <20210124170405.30583-8-charvi077@gmail.com> X-Mailer: git-send-email 2.29.0.rc1 In-Reply-To: <20210124170405.30583-1-charvi077@gmail.com> References: <20210119074102.21598-1-charvi077@gmail.com> <20210124170405.30583-1-charvi077@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Mentored-by: Christian Couder Mentored-by: Phillip Wood Signed-off-by: Charvi Mendiratta --- t/lib-rebase.sh | 4 + t/t3437-rebase-fixup-options.sh | 213 ++++++++++++++++++++++++++++++ t/t3437/expected-combined-message | 21 +++ t/t3437/expected-squash-message | 51 +++++++ 4 files changed, 289 insertions(+) create mode 100755 t/t3437-rebase-fixup-options.sh create mode 100644 t/t3437/expected-combined-message create mode 100644 t/t3437/expected-squash-message diff --git a/t/lib-rebase.sh b/t/lib-rebase.sh index b72c051f47..e10e38060b 100644 --- a/t/lib-rebase.sh +++ b/t/lib-rebase.sh @@ -4,6 +4,7 @@ # # - override the commit message with $FAKE_COMMIT_MESSAGE # - amend the commit message with $FAKE_COMMIT_AMEND +# - copy the original commit message to a file with $FAKE_MESSAGE_COPY # - check that non-commit messages have a certain line count with $EXPECT_COUNT # - check the commit count in the commit message header with $EXPECT_HEADER_COUNT # - rewrite a rebase -i script as directed by $FAKE_LINES. @@ -33,6 +34,7 @@ set_fake_editor () { exit test -z "$FAKE_COMMIT_MESSAGE" || echo "$FAKE_COMMIT_MESSAGE" > "$1" test -z "$FAKE_COMMIT_AMEND" || echo "$FAKE_COMMIT_AMEND" >> "$1" + test -z "$FAKE_MESSAGE_COPY" || cat "$1" >"$FAKE_MESSAGE_COPY" exit ;; esac @@ -51,6 +53,8 @@ set_fake_editor () { action="$line";; exec_*|x_*|break|b) echo "$line" | sed 's/_/ /g' >> "$1";; + merge_*|fixup_*) + action=$(echo "$line" | sed 's/_/ /g');; "#") echo '# comment' >> "$1";; ">") diff --git a/t/t3437-rebase-fixup-options.sh b/t/t3437-rebase-fixup-options.sh new file mode 100755 index 0000000000..832971ffdb --- /dev/null +++ b/t/t3437-rebase-fixup-options.sh @@ -0,0 +1,213 @@ +#!/bin/sh +# +# Copyright (c) 2018 Phillip Wood +# + +test_description='git rebase interactive fixup options + +This test checks the "fixup [-C|-c]" command of rebase interactive. +In addition to amending the contents of the commit, "fixup -C" +replaces the original commit message with the message of the fixup +commit. "fixup -c" also replaces the original message, but opens the +editor to allow the user to edit the message before committing. +' + +. ./test-lib.sh + +. "$TEST_DIRECTORY"/lib-rebase.sh + +EMPTY="" + +test_commit_message () { + rev="$1" && # commit or tag we want to test + file="$2" && # test against the content of a file + git show --no-patch --pretty=format:%B "$rev" >actual-message && + if test "$2" = -m + then + str="$3" && # test against a string + printf "%s\n" "$str" >tmp-expected-message && + file="tmp-expected-message" + fi + test_cmp "$file" actual-message +} + +get_author () { + rev="$1" && + git log -1 --pretty=format:"%an %ae" "$rev" +} + +test_expect_success 'setup' ' + cat >message <<-EOF && + amend! B + ${EMPTY} + new subject + ${EMPTY} + new + body + EOF + + sed "1,2d" message >expected-message && + + test_commit A A && + test_commit B B && + get_author HEAD >expected-author && + ORIG_AUTHOR_NAME="$GIT_AUTHOR_NAME" && + ORIG_AUTHOR_EMAIL="$GIT_AUTHOR_EMAIL" && + GIT_AUTHOR_NAME="Amend Author" && + GIT_AUTHOR_EMAIL="amend@example.com" && + test_commit "$(cat message)" A A1 A1 && + test_commit A2 A && + test_commit A3 A && + GIT_AUTHOR_NAME="$ORIG_AUTHOR_NAME" && + GIT_AUTHOR_EMAIL="$ORIG_AUTHOR_EMAIL" && + git checkout -b conflicts-branch A && + test_commit conflicts A && + + set_fake_editor && + git checkout -b branch B && + echo B1 >B && + test_tick && + git commit --fixup=HEAD -a && + test_tick && + git commit --allow-empty -F - <<-EOF && + amend! B + ${EMPTY} + B + ${EMPTY} + edited 1 + EOF + test_tick && + git commit --allow-empty -F - <<-EOF && + amend! amend! B + ${EMPTY} + B + ${EMPTY} + edited 1 + ${EMPTY} + edited 2 + EOF + echo B2 >B && + test_tick && + FAKE_COMMIT_AMEND="edited squash" git commit --squash=HEAD -a && + echo B3 >B && + test_tick && + git commit -a -F - <<-EOF && + amend! amend! amend! B + ${EMPTY} + B + ${EMPTY} + edited 1 + ${EMPTY} + edited 2 + ${EMPTY} + edited 3 + EOF + + GIT_AUTHOR_NAME="Rebase Author" && + GIT_AUTHOR_EMAIL="rebase.author@example.com" && + GIT_COMMITTER_NAME="Rebase Committer" && + GIT_COMMITTER_EMAIL="rebase.committer@example.com" +' + +test_expect_success 'simple fixup -C works' ' + test_when_finished "test_might_fail git rebase --abort" && + git checkout --detach A2 && + FAKE_LINES="1 fixup_-C 2" git rebase -i B && + test_cmp_rev HEAD^ B && + test_cmp_rev HEAD^{tree} A2^{tree} && + test_commit_message HEAD -m "A2" +' + +test_expect_success 'simple fixup -c works' ' + test_when_finished "test_might_fail git rebase --abort" && + git checkout --detach A2 && + git log -1 --pretty=format:%B >expected-fixup-message && + test_write_lines "" "Modified A2" >>expected-fixup-message && + FAKE_LINES="1 fixup_-c 2" \ + FAKE_COMMIT_AMEND="Modified A2" \ + git rebase -i B && + test_cmp_rev HEAD^ B && + test_cmp_rev HEAD^{tree} A2^{tree} && + test_commit_message HEAD expected-fixup-message +' + +test_expect_success 'fixup -C removes amend! from message' ' + test_when_finished "test_might_fail git rebase --abort" && + git checkout --detach A1 && + FAKE_LINES="1 fixup_-C 2" git rebase -i A && + test_cmp_rev HEAD^ A && + test_cmp_rev HEAD^{tree} A1^{tree} && + test_commit_message HEAD expected-message && + get_author HEAD >actual-author && + test_cmp expected-author actual-author +' + +test_expect_success 'fixup -C with conflicts gives correct message' ' + test_when_finished "test_might_fail git rebase --abort" && + git checkout --detach A1 && + test_must_fail env FAKE_LINES="1 fixup_-C 2" git rebase -i conflicts && + git checkout --theirs -- A && + git add A && + FAKE_COMMIT_AMEND=edited git rebase --continue && + test_cmp_rev HEAD^ conflicts && + test_cmp_rev HEAD^{tree} A1^{tree} && + test_write_lines "" edited >>expected-message && + test_commit_message HEAD expected-message && + get_author HEAD >actual-author && + test_cmp expected-author actual-author +' + +test_expect_success 'skipping fixup -C after fixup gives correct message' ' + test_when_finished "test_might_fail git rebase --abort" && + git checkout --detach A3 && + test_must_fail env FAKE_LINES="1 fixup 2 fixup_-C 4" git rebase -i A && + git reset --hard && + FAKE_COMMIT_AMEND=edited git rebase --continue && + test_commit_message HEAD -m "B" +' + +test_expect_success 'sequence of fixup, fixup -C & squash --signoff works' ' + git checkout --detach branch && + FAKE_LINES="1 fixup 2 fixup_-C 3 fixup_-C 4 squash 5 fixup_-C 6" \ + FAKE_COMMIT_AMEND=squashed \ + FAKE_MESSAGE_COPY=actual-squash-message \ + git -c commit.status=false rebase -ik --signoff A && + git diff-tree --exit-code --patch HEAD branch -- && + test_cmp_rev HEAD^ A && + test_i18ncmp "$TEST_DIRECTORY/t3437/expected-squash-message" \ + actual-squash-message +' + +test_expect_success 'first fixup -C commented out in sequence fixup fixup -C fixup -C' ' + test_when_finished "test_might_fail git rebase --abort" && + git checkout branch && git checkout --detach branch~2 && + git log -1 --pretty=format:%b >expected-message && + FAKE_LINES="1 fixup 2 fixup_-C 3 fixup_-C 4" git rebase -i A && + test_cmp_rev HEAD^ A && + test_commit_message HEAD expected-message +' + +test_expect_success 'multiple fixup -c opens editor once' ' + test_when_finished "test_might_fail git rebase --abort" && + git checkout --detach A3 && + base=$(git rev-parse HEAD~4) && + FAKE_COMMIT_MESSAGE="Modified-A3" \ + FAKE_LINES="1 fixup_-C 2 fixup_-c 3 fixup_-c 4" \ + EXPECT_HEADER_COUNT=4 \ + git rebase -i $base && + test_cmp_rev $base HEAD^ && + test 1 = $(git show | grep Modified-A3 | wc -l) +' + +test_expect_success 'sequence squash, fixup & fixup -c gives combined message' ' + test_when_finished "test_might_fail git rebase --abort" && + git checkout --detach A3 && + FAKE_LINES="1 squash 2 fixup 3 fixup_-c 4" \ + FAKE_MESSAGE_COPY=actual-combined-message \ + git -c commit.status=false rebase -i A && + test_i18ncmp "$TEST_DIRECTORY/t3437/expected-combined-message" \ + actual-combined-message && + test_cmp_rev HEAD^ A +' + +test_done diff --git a/t/t3437/expected-combined-message b/t/t3437/expected-combined-message new file mode 100644 index 0000000000..a26cfb2fa9 --- /dev/null +++ b/t/t3437/expected-combined-message @@ -0,0 +1,21 @@ +# This is a combination of 4 commits. +# This is the 1st commit message: + +B + +# This is the commit message #2: + +# amend! B + +new subject + +new +body + +# The commit message #3 will be skipped: + +# A2 + +# This is the commit message #4: + +A3 diff --git a/t/t3437/expected-squash-message b/t/t3437/expected-squash-message new file mode 100644 index 0000000000..ab2434f90e --- /dev/null +++ b/t/t3437/expected-squash-message @@ -0,0 +1,51 @@ +# This is a combination of 6 commits. +# The 1st commit message will be skipped: + +# B +# +# Signed-off-by: Rebase Committer + +# The commit message #2 will be skipped: + +# fixup! B + +# The commit message #3 will be skipped: + +# amend! B +# +# B +# +# edited 1 +# +# Signed-off-by: Rebase Committer + +# This is the commit message #4: + +# amend! amend! B + +B + +edited 1 + +edited 2 + +Signed-off-by: Rebase Committer + +# This is the commit message #5: + +# squash! amend! amend! B + +edited squash + +# This is the commit message #6: + +# amend! amend! amend! B + +B + +edited 1 + +edited 2 + +edited 3 +squashed From patchwork Sun Jan 24 17:04:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charvi Mendiratta X-Patchwork-Id: 12042549 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19BFBC433E0 for ; Sun, 24 Jan 2021 17:07:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D258322D57 for ; Sun, 24 Jan 2021 17:07:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726541AbhAXRHw (ORCPT ); Sun, 24 Jan 2021 12:07:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726206AbhAXRHm (ORCPT ); Sun, 24 Jan 2021 12:07:42 -0500 Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FFDEC061574 for ; Sun, 24 Jan 2021 09:07:02 -0800 (PST) Received: by mail-pg1-x52e.google.com with SMTP id n7so7338608pgg.2 for ; Sun, 24 Jan 2021 09:07:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Mjnb7s4+wrUzyipXwVf1NX3axMeXC6d+hbWBTYQo6MQ=; b=MvifX3ToPSxdxge1qSrKu3T/MaWEYMocoZWZJ7GpbTBw1HKt0cTq9NtFUCmtLi0Glm jsStQ3JJDU0xSWfrbuTY1bF4NhYE4vnKrtOfPrUyzhtHb0utH0A82zuGUoBAPQxNaQRR kiOVl381SpwG7xChQvqD4LtvsqSD0/i8bbILmDpy+4Svv7vTNYVg1oxtAKDD/GJE2d6N JjqWvo4IhJjqA0z0sKtPDklYNhg/JUkSkoB21e9A74ltGEvgXUMZc6m5tFEHZjYm6BFu qJcP6o9BufsXUs7vJNLZSaOZV8RGc7R5KT8iaz7pJUttqAAzrLOY3mW2hv34ou7ti9Ih 8fag== 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=Mjnb7s4+wrUzyipXwVf1NX3axMeXC6d+hbWBTYQo6MQ=; b=cxgHQd1SzGMtNUQH6hcghPaznYTVyvwe7h3HchPvNnGMm4xRIGnmELamyPhRwW7+nA Y1zebwp5363Qwb40E2tXiXz/A2b5LCbXA4QuHDJY7G4yIKjSi/+LOBD/MimCrAEd72Im ysAupGcUODDplB/ZzIRvtqW4VrQCHdCLqVhl2cJLC1cve+bcVZTRCFBsMbMeolvDh4Pc XsXjWLR7Vg3AHn3jNk0pvqyBLpMo4NYiCUQlcS+iJWBIl0/vQqFRqoof6AuQUAKL6Jb4 ds5AV8XvkMgXG9guZDsv0Gf7K9EW8/k5W8sXt/uAbmhFBkS0MBxs6FXGoDxV0pMDLctK 1N0A== X-Gm-Message-State: AOAM533079A2IV1Q6hzNs88bF/l8N9epOPDXS76NgQRDzU970V/vUORm yeU/x9dFK94Z5mVdLHQq1e0qoV2Xiqifcw== X-Google-Smtp-Source: ABdhPJws3GtwjqSHHpg18hVdO/Wwz3iWkGj7Vq2ECGHSjnxLgYfmnfIff7HZ26CcdjndE5+5VpMwPw== X-Received: by 2002:a65:534c:: with SMTP id w12mr9063046pgr.179.1611508021565; Sun, 24 Jan 2021 09:07:01 -0800 (PST) Received: from localhost.localdomain ([2409:4050:2d0e:58a:f516:739c:ea0e:a6ba]) by smtp.googlemail.com with ESMTPSA id r30sm16283308pjg.43.2021.01.24.09.06.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Jan 2021 09:07:01 -0800 (PST) From: Charvi Mendiratta To: git@vger.kernel.org Cc: gitster@pobox.com, christian.couder@gmail.com, marcnarc@xiplink.com, phillip.wood123@gmail.com, Charvi Mendiratta , Phillip Wood , Christian Couder Subject: [PATCH v3 8/9] rebase -i: teach --autosquash to work with amend! Date: Sun, 24 Jan 2021 22:34:06 +0530 Message-Id: <20210124170405.30583-9-charvi077@gmail.com> X-Mailer: git-send-email 2.29.0.rc1 In-Reply-To: <20210124170405.30583-1-charvi077@gmail.com> References: <20210119074102.21598-1-charvi077@gmail.com> <20210124170405.30583-1-charvi077@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org If the commit subject starts with "amend!" then rearrange it like a "fixup!" commit and replace `pick` command with `fixup -C` command, which is used to fixup up the content if any and replaces the original commit message with amend! commit's message. Original-patch-by: Phillip Wood Mentored-by: Christian Couder Mentored-by: Phillip Wood Signed-off-by: Charvi Mendiratta --- sequencer.c | 23 ++++++++++++++++------- t/t3437-rebase-fixup-options.sh | 12 ++++++++++++ 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/sequencer.c b/sequencer.c index 46e11d20e8..d09ce446b6 100644 --- a/sequencer.c +++ b/sequencer.c @@ -5662,6 +5662,12 @@ static int subject2item_cmp(const void *fndata, define_commit_slab(commit_todo_item, struct todo_item *); +static inline int skip_fixup_amend_squash(const char *subject, const char **p) { + return skip_prefix(subject, "fixup! ", p) || + skip_prefix(subject, "amend! ", p) || + skip_prefix(subject, "squash! ", p); +} + /* * Rearrange the todo list that has both "pick commit-id msg" and "pick * commit-id fixup!/squash! msg" in it so that the latter is put immediately @@ -5720,15 +5726,13 @@ int todo_list_rearrange_squash(struct todo_list *todo_list) format_subject(&buf, subject, " "); subject = subjects[i] = strbuf_detach(&buf, &subject_len); unuse_commit_buffer(item->commit, commit_buffer); - if ((skip_prefix(subject, "fixup! ", &p) || - skip_prefix(subject, "squash! ", &p))) { + if (skip_fixup_amend_squash(subject, &p)) { struct commit *commit2; for (;;) { while (isspace(*p)) p++; - if (!skip_prefix(p, "fixup! ", &p) && - !skip_prefix(p, "squash! ", &p)) + if (!skip_fixup_amend_squash(p, &p)) break; } @@ -5758,9 +5762,14 @@ int todo_list_rearrange_squash(struct todo_list *todo_list) } if (i2 >= 0) { rearranged = 1; - todo_list->items[i].command = - starts_with(subject, "fixup!") ? - TODO_FIXUP : TODO_SQUASH; + if (starts_with(subject, "fixup!")) { + todo_list->items[i].command = TODO_FIXUP; + } else if (starts_with(subject, "amend!")) { + todo_list->items[i].command = TODO_FIXUP; + todo_list->items[i].flags = TODO_REPLACE_FIXUP_MSG; + } else { + todo_list->items[i].command = TODO_SQUASH; + } if (tail[i2] < 0) { next[i] = next[i2]; next[i2] = i; diff --git a/t/t3437-rebase-fixup-options.sh b/t/t3437-rebase-fixup-options.sh index 832971ffdb..945df2555b 100755 --- a/t/t3437-rebase-fixup-options.sh +++ b/t/t3437-rebase-fixup-options.sh @@ -210,4 +210,16 @@ test_expect_success 'sequence squash, fixup & fixup -c gives combined message' ' test_cmp_rev HEAD^ A ' +test_expect_success 'fixup -C works upon --autosquash with amend!' ' + git checkout --detach branch && + FAKE_COMMIT_AMEND=squashed \ + FAKE_MESSAGE_COPY=actual-squash-message \ + git -c commit.status=false rebase -ik --autosquash \ + --signoff A && + git diff-tree --exit-code --patch HEAD branch -- && + test_cmp_rev HEAD^ A && + test_i18ncmp "$TEST_DIRECTORY/t3437/expected-squash-message" \ + actual-squash-message +' + test_done From patchwork Sun Jan 24 17:04:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charvi Mendiratta X-Patchwork-Id: 12042551 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98558C433DB for ; Sun, 24 Jan 2021 17:08:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 71ABD22511 for ; Sun, 24 Jan 2021 17:08:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726305AbhAXRIM (ORCPT ); Sun, 24 Jan 2021 12:08:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726550AbhAXRHs (ORCPT ); Sun, 24 Jan 2021 12:07:48 -0500 Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E40B5C06174A for ; Sun, 24 Jan 2021 09:07:07 -0800 (PST) Received: by mail-pg1-x531.google.com with SMTP id n25so7355801pgb.0 for ; Sun, 24 Jan 2021 09:07:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ViXmFBzQ+/qpchAFb5bLM28xzO1lcwQ8ijh1Mo/eRpI=; b=hlhDjloJ6b1YvErtLOh8Uih1JG1e0opn49G2xRoccdv9j0z+43TfCZhHegbpNTdGG6 675MVZhLVoG7iBCWrKvforxfz/30BAp0aEn8A3nd6GSadPcnXCwGEnl2cA1jmsPgd584 f8pU2UG49ElimlTL8bbY3d6YxVKQbkIarGtkNP2ISRECDwzsXXw+eLpiUjBBTm7aFRpr k56TndNE8fh9jsTz+4NkvlnKx1G5nz6DIUnfibKPb2RV4nknbLtobdQDn24B/Lv0RqFr vQravZnhmQEvMh9H490Hu9u407cxtqIA1JoIdQ9jQjv6NVTeatFk/fPabrbBhcUx8HXV cVuw== 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=ViXmFBzQ+/qpchAFb5bLM28xzO1lcwQ8ijh1Mo/eRpI=; b=dDH14n00lXjbTWf/ih8ZHxgNk7leCT558liWeFV7plKe4vHpTDJGepTDc6xbTQG20I JA92gLLQMFEo23OeIcYwvwgsDDq14xQkzefOvZDy7oxFz5slDk8r2AAJmNRxB4jwAq65 5uCuJck7vf0Ks2/L1OzRMryInHIKfsPOw4c+HOjvH8Z9Ekm0teTB2AvT6/8OUc37n8u+ uVtZISfgpt/ChMnSBV+sWyu0nd5DonheGvtLSWpGFYFezR/jPizQ1VMQvv/3+wpmwahB muVzyUt9+YzYjV6TzQ0/fIMVmOWY1OGqY9a7PRjM1IlywBW79DxNFhF5J7BIBv9Iy8kf lXVw== X-Gm-Message-State: AOAM530l+M4G3Rqdh3TPOWmKOezdqry6MoZm2el74+VklBak0XDJC64w eS/UYriRErZHmRtOZzmw7y6VM36iYnJS+g== X-Google-Smtp-Source: ABdhPJxueNFq61ScMa/j2jtgB913xkTvBVBrGM7JRqv+/cXHy/3xIBGIgGsbcmup5RZvdXzExfVOOQ== X-Received: by 2002:a63:5526:: with SMTP id j38mr14473093pgb.177.1611508027299; Sun, 24 Jan 2021 09:07:07 -0800 (PST) Received: from localhost.localdomain ([2409:4050:2d0e:58a:f516:739c:ea0e:a6ba]) by smtp.googlemail.com with ESMTPSA id r30sm16283308pjg.43.2021.01.24.09.07.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Jan 2021 09:07:06 -0800 (PST) From: Charvi Mendiratta To: git@vger.kernel.org Cc: gitster@pobox.com, christian.couder@gmail.com, marcnarc@xiplink.com, phillip.wood123@gmail.com, Charvi Mendiratta , Christian Couder , Phillip Wood Subject: [PATCH v3 9/9] doc/git-rebase: add documentation for fixup [-C|-c] options Date: Sun, 24 Jan 2021 22:34:07 +0530 Message-Id: <20210124170405.30583-10-charvi077@gmail.com> X-Mailer: git-send-email 2.29.0.rc1 In-Reply-To: <20210124170405.30583-1-charvi077@gmail.com> References: <20210119074102.21598-1-charvi077@gmail.com> <20210124170405.30583-1-charvi077@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Mentored-by: Christian Couder Mentored-by: Phillip Wood Reviewed-by: Marc Branchaud Signed-off-by: Charvi Mendiratta --- Documentation/git-rebase.txt | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt index a0487b5cc5..a6903419c4 100644 --- a/Documentation/git-rebase.txt +++ b/Documentation/git-rebase.txt @@ -887,9 +887,17 @@ If you want to fold two or more commits into one, replace the command "pick" for the second and subsequent commits with "squash" or "fixup". If the commits had different authors, the folded commit will be attributed to the author of the first commit. The suggested commit -message for the folded commit is the concatenation of the commit -messages of the first commit and of those with the "squash" command, -but omits the commit messages of commits with the "fixup" command. +message for the folded commit is the concatenation of the first +commit's message with those identified by "squash" commands, omitting the +messages of commits identified by "fixup" commands, unless "fixup -c" +is used. In that case the suggested commit message is only the message +of the "fixup -c" commit, and an editor is opened allowing you to edit +the message. The contents (patch) of the "fixup -c" commit are still +incorporated into the folded commit. If there is more than one "fixup -c" +commit, the message from the last last one is used. You can also use +"fixup -C" to get the same behavior as "fixup -c" except without opening +an editor. + 'git rebase' will stop when "pick" has been replaced with "edit" or when a command fails due to merge errors. When you are done editing