From patchwork Wed Nov 14 05:24:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 10681927 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 72293139B for ; Wed, 14 Nov 2018 05:25:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 660CC2AA90 for ; Wed, 14 Nov 2018 05:25:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5A9432B29B; Wed, 14 Nov 2018 05:25:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 03D822B205 for ; Wed, 14 Nov 2018 05:25:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727770AbeKNP0f (ORCPT ); Wed, 14 Nov 2018 10:26:35 -0500 Received: from mail-io1-f67.google.com ([209.85.166.67]:42320 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726927AbeKNP0f (ORCPT ); Wed, 14 Nov 2018 10:26:35 -0500 Received: by mail-io1-f67.google.com with SMTP id h19-v6so10786412iog.9 for ; Tue, 13 Nov 2018 21:24:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=uVPq+k7fzn2aWkjdYWn9mxk3TChnXCXerFAxSKB2PFo=; b=n1nMRb3kL2xj0JPt9Je9DvrhM91cuEp8dayxjhGMd1S5M+BERErIv7MNeNUL3kChj+ 2laQXa8Efq6Nt2hemei2EOoAnuzfbjVRgevBZfDN1NVbrJmb88KH3Z1cYf/xFLgaTfJc gIoQNlZxFNebdeUJTIGHRbfOguvN2iFraeIxu419XnKXlCmKXUVP9RuXqwpfxX7O+GM+ gO4fxl4K2d35FsMEf131yGMSVsMMigYONuHyffQQy5wTQD1f1t9az7DQJPQNaeOTGM6o R+wCrKGbLLciuxT3RWoe9cCUiydUv9axo9OT/urNndJAZsohpLERNBQOEbQKbG2o+tmI mxQw== 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:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=uVPq+k7fzn2aWkjdYWn9mxk3TChnXCXerFAxSKB2PFo=; b=XBp6Pg513u8wYgeR7w8PpHwM4F31csf5PDXlsAKfpo84ae7qLR3DIZNYWCZl3jBHjc u47w3JiTmElsON4aEcdiqnztTWNmEofmsCXv96P33An3vmxacnijDAqkSRJYS0C7gBNQ 4H1k/Ovr/oS1j/OTtwltXsuWRdhVNMxtnOP+s0J7N7ObRKVrriFNJ1wv9S3mlXbuwAHo LH531ANPlwv5LzZZs+3xnV5VF0pxCc7/XpKguplJyRL2L6t9jcqNXPbwUprSUxwjyOu/ ZUfq6xIq7IJB0mPafnAn1hmyroc/gQBX3bNgVU94qUfvuhHaO07aJ3s2vkG1BtJCdxhI qtqQ== X-Gm-Message-State: AA+aEWazMt7hzHb0OZQN/6O4vkRgGtgC3XiTAW7tViLrOD5zMgYTCEL2 E6dHNomLz80bs1wZ5Q4aHtSJJsEw X-Google-Smtp-Source: AJdET5eglK69TGMr+Iumx8H/VKOJC8tflf/mbEH0vfrwy5I4cl+M7ChwCDVdsNhLfcumKnOeSZTocA== X-Received: by 2002:a6b:1582:: with SMTP id 124-v6mr352820iov.204.1542173095263; Tue, 13 Nov 2018 21:24:55 -0800 (PST) Received: from archbookpro.localdomain (ktnron0919w-lp140-01-76-68-143-166.dsl.bell.ca. [76.68.143.166]) by smtp.gmail.com with ESMTPSA id u3-v6sm7393956iog.33.2018.11.13.21.24.54 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Nov 2018 21:24:54 -0800 (PST) Date: Wed, 14 Nov 2018 00:24:53 -0500 From: Denton Liu To: git@vger.kernel.org Subject: [RFC PATCH 1/2] commit: don't add scissors line if one exists Message-ID: <1c16b9497bd630f0636aa7729082da7a90ba42d9.1542172724.git.liu.denton@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If commit.cleanup = scissors is specified, don't produce a scissors line if one already exists in the commit message. Signed-off-by: Denton Liu --- builtin/commit.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/builtin/commit.c b/builtin/commit.c index 0d9828e29e..e486246329 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -659,6 +659,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 contains_scissors = 0; /* This checks and barfs if author is badly specified */ determine_author_info(author_ident); @@ -742,6 +743,10 @@ static int prepare_to_commit(const char *index_file, const char *prefix, clean_message_contents = 0; } + if (cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS && + wt_status_locate_end(sb.buf, sb.len) != sb.len) + contains_scissors = 1; + /* * The remaining cases don't modify the template message, but * just set the argument(s) to the prepare-commit-msg hook. @@ -798,7 +803,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 && + !contains_scissors) wt_status_add_cut_line(s->fp); status_printf_ln(s, GIT_COLOR_NORMAL, whence == FROM_MERGE @@ -824,7 +830,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix, " 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) + whence == FROM_COMMIT && + !contains_scissors) wt_status_add_cut_line(s->fp); else /* COMMIT_MSG_CLEANUP_SPACE, that is. */ status_printf(s, GIT_COLOR_NORMAL, From patchwork Wed Nov 14 05:25:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 10681931 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 CA76E14DB for ; Wed, 14 Nov 2018 05:25:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BDC1A2B205 for ; Wed, 14 Nov 2018 05:25:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B1F4C2B28B; Wed, 14 Nov 2018 05:25:21 +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 EC43A2B205 for ; Wed, 14 Nov 2018 05:25:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727718AbeKNP0w (ORCPT ); Wed, 14 Nov 2018 10:26:52 -0500 Received: from mail-it1-f193.google.com ([209.85.166.193]:39617 "EHLO mail-it1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726927AbeKNP0w (ORCPT ); Wed, 14 Nov 2018 10:26:52 -0500 Received: by mail-it1-f193.google.com with SMTP id m15so22107154itl.4 for ; Tue, 13 Nov 2018 21:25:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Rqhc5FSyIvLQM32fWWnSu0bjkk3luOMJ+AT6RewXqVc=; b=gRed1Q4Pk7mJD74Y5AnijCesLbFcYnu4l88yNrnHXEcn5qBXlXjZwoJ+EZO8nZffff +kQoMCW0m0/MUo4iGxfjOY4DyUed85zR2vcdmiWUxkaDFvVvC2dtKUeY9ebmCEBFYeYm uXuwzXWyzqlaw7UoQx6vUTMgAx+5/wj+HPYCqx6leuyjpogo16c2//yOjaf0+n/h2YWr 0dsVSdXWeJzaVlLJucpf7MvKMCb7x3rVEk8Wt3J+jol57irEcQ0DIPX3n9FJzU3kcD7Q DOtORQ3oS31rTUf/VwzItgE4Hz4edhAxs5dXJGrreGAUMbFFLYhKfk+CUuRp8xNFh5bz rLfQ== 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:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Rqhc5FSyIvLQM32fWWnSu0bjkk3luOMJ+AT6RewXqVc=; b=c+Ml8zY1DJjVijXBaDnjbKZTrz9bAdpND6kxtbm+1/1x+COEYse1aIAjLD8SeKH1p6 MMEpzQZ+oxTcbLtBkcrkvV2qtGurSQy+qPUMwVp0Xv3RjQ0dh050AYD5iRZoftGfaz2F DCsStSIwgK4GgijB+MCfJ3D+I3nH/mF8QbW6ag9e2+dU1AI7mXRLJ7Cz1w04bu5W6Ehw kVOyHS78GwWCtqHNUR1IjbBR/wItJaFBgiPBPISiWbFOnV0RYSmr5ewBQMYZB/op9k3m es1dr6TwTUXHgxggVYmc/nhq2AXYUUUh5fXCqxxpwKg6ROW2kYXTcbkJgop1V/f8GCua oLug== X-Gm-Message-State: AGRZ1gKOaDazCvZW97x5xhup62tmZbwrfVIZ86KoSoY+t7m1AExY7Hn9 i4FiGHNf7o57S5O3v5p/aoyBblCW X-Google-Smtp-Source: AJdET5ea7MilbQispJJ2odLIJVlaQHqarAUd8GVV/5eIXjGAgmjqdKPRy2Jj66KsX9kkWHKGILzczg== X-Received: by 2002:a24:d204:: with SMTP id z4-v6mr800589itf.11.1542173112053; Tue, 13 Nov 2018 21:25:12 -0800 (PST) Received: from archbookpro.localdomain (ktnron0919w-lp140-01-76-68-143-166.dsl.bell.ca. [76.68.143.166]) by smtp.gmail.com with ESMTPSA id o74sm3469479itc.44.2018.11.13.21.25.11 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Nov 2018 21:25:11 -0800 (PST) Date: Wed, 14 Nov 2018 00:25:09 -0500 From: Denton Liu To: git@vger.kernel.org Subject: [RFC PATCH 2/2] merge: add scissors line on merge conflict Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) 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 merge.cleanup = scissors. Signed-off-by: Denton Liu --- builtin/merge.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/builtin/merge.c b/builtin/merge.c index 8f4a5065c2..c5010cee5e 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -36,6 +36,7 @@ #include "packfile.h" #include "tag.h" #include "alias.h" +#include "wt-status.h" #define DEFAULT_TWOHEAD (1<<0) #define DEFAULT_OCTOPUS (1<<1) @@ -96,6 +97,9 @@ enum ff_type { static enum ff_type fast_forward = FF_ALLOW; +const char *cleanup_arg; +int put_scissors; + static int option_parse_message(const struct option *opt, const char *arg, int unset) { @@ -243,6 +247,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"), @@ -606,6 +611,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")) { @@ -894,6 +901,13 @@ static int suggest_conflicts(void) filename = git_path_merge_msg(the_repository); fp = xfopen(filename, "a"); + if (put_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(&msgbuf); fputs(msgbuf.buf, fp); strbuf_release(&msgbuf); @@ -1402,6 +1416,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix) if (option_edit < 0) option_edit = default_edit_option(); + put_scissors = cleanup_arg && !strcmp(cleanup_arg, "scissors"); + if (!use_strategies) { if (!remoteheads) ; /* already up-to-date */