From patchwork Sun Jun 13 22:58:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12317915 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 CFC05C48BDF for ; Sun, 13 Jun 2021 22:59:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AD4826135F for ; Sun, 13 Jun 2021 22:59:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232230AbhFMXBm (ORCPT ); Sun, 13 Jun 2021 19:01:42 -0400 Received: from mail-oi1-f173.google.com ([209.85.167.173]:42910 "EHLO mail-oi1-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232181AbhFMXBl (ORCPT ); Sun, 13 Jun 2021 19:01:41 -0400 Received: by mail-oi1-f173.google.com with SMTP id s23so12482661oiw.9 for ; Sun, 13 Jun 2021 15:59:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EWTeNABEujHxG4bFYTR71RWN5RYFRTpnd3Cjx6YCkS0=; b=iHBozdfAXHYmuLFGsSLRk3gkVxTwgp/95TPEk+V0V8GDbpYDkVP2f9sAiMOSF8kevz yA0Xnf8CJ93b3CSl2F5EuLaXV2sKJ6E4L9X4glIYUjEM7zdIpXxMC0DuNxd/Ohrg6h3n wxBcDcrSgoa9YXZt2PkcN428wBoXAJbVm6KcGI4xvEXDESWqK4rMcpWATWLKmEVkE6k7 UWAPyU9+V03aEHSCnrtkYgQDVjAqEnGOWtqg4CfA7nxqdnkDrdx1JB3bOH171cDGOvyt 7KK2oHRvgbFpRdpn5vQ6ZQkELhORBRJcmh7VkTYMtjdZJy0fp8ipjzEUBSDqwcQk1ovU eQ5Q== 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=EWTeNABEujHxG4bFYTR71RWN5RYFRTpnd3Cjx6YCkS0=; b=U9LocRAVzOezIo0nn4W66hkT5cUR3GR7c5mUgcSEd/UEp09IUzeukfCxFC3QTYkIf9 BN5LhKtZ2O6ubxT9R0qR2HBugn9UAaFDHkxNluIkro5WmEnR2kSe9gZISJNKUjlpf7gD JJpk9XygdcXXuZ8X/rSHKS9pBO1roZgEKwfrs7+n9saCEb2W0k/3LWfvo/vvQJP5vj6M mEcHlhKxaDgLxZnLBRAye2DmvsZTMTDxUcmC9Ida6yijPnDBE07dkaz/16HlvtF904L2 mCd0scAtKSoSCuAk1Es9ArwiLlNNhanm97VVa3irYr89oibZ9HUVNlpJwC3iZOIK3RoE pLAw== X-Gm-Message-State: AOAM532xl6HCjfk5hQykV7HyNbt9av5+odc7Y0DkjKq4ZczX8QWcgDPS as8AsLQBeAWyp0nyVC2GOS4kFqEdLD6rFg== X-Google-Smtp-Source: ABdhPJwRZHpA0W9s8TBQRJrpL/xJXyv6nW7vnk8ZlS1TpPSPSIGzBcN7qjInKNisYIOdkTqzWaPKtA== X-Received: by 2002:a05:6808:919:: with SMTP id w25mr10004363oih.30.1623625119617; Sun, 13 Jun 2021 15:58:39 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id x29sm2845450ott.68.2021.06.13.15.58.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Jun 2021 15:58:39 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Jeff King , Junio C Hamano , Felipe Contreras Subject: [PATCH 1/4] merge: simplify initialization Date: Sun, 13 Jun 2021 17:58:33 -0500 Message-Id: <20210613225836.1009569-2-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210613225836.1009569-1-felipe.contreras@gmail.com> References: <20210613225836.1009569-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Signed-off-by: Felipe Contreras --- builtin/merge-file.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/builtin/merge-file.c b/builtin/merge-file.c index 06a2f90c48..0186f4156a 100644 --- a/builtin/merge-file.c +++ b/builtin/merge-file.c @@ -28,7 +28,7 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix) const char *names[3] = { NULL, NULL, NULL }; mmfile_t mmfs[3]; mmbuffer_t result = {NULL, 0}; - xmparam_t xmp = {{0}}; + xmparam_t xmp = { .level = XDL_MERGE_ZEALOUS_ALNUM }; int ret = 0, i = 0, to_stdout = 0; int quiet = 0; struct option options[] = { @@ -48,10 +48,6 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix) OPT_END(), }; - xmp.level = XDL_MERGE_ZEALOUS_ALNUM; - xmp.style = 0; - xmp.favor = 0; - if (startup_info->have_repository) { /* Read the configuration file */ git_config(git_xmerge_config, NULL); From patchwork Sun Jun 13 22:58:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12317917 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 126F0C48BDF for ; Sun, 13 Jun 2021 22:59:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D8C2461363 for ; Sun, 13 Jun 2021 22:59:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232231AbhFMXB6 (ORCPT ); Sun, 13 Jun 2021 19:01:58 -0400 Received: from mail-ot1-f50.google.com ([209.85.210.50]:44852 "EHLO mail-ot1-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232181AbhFMXB5 (ORCPT ); Sun, 13 Jun 2021 19:01:57 -0400 Received: by mail-ot1-f50.google.com with SMTP id q5-20020a9d66450000b02903f18d65089fso9065060otm.11 for ; Sun, 13 Jun 2021 15:59:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bvnzbM1V/v21TQTXSkhY6XD51NKXzk91beoDIhOObL8=; b=Fa4B46/cgHCGPwcAd2HHPXOeSu88pIvwJW5jbymBGFsQnKFlk6+wB/PPz51C1+ewgS 64U68W2ArwcxoGm1j6OCEgvS8+Dw0KlLpA8qufR2ks39CwdcgSxwmJ8vXn2UF2BcDv7h vKmOgy8hY8QY9nAaRFhOIFVuL3Yb/8W/u8Q3C6WO2Ra+45PESmxA4jlUymtRYHoaW5jF eVEii6vsitksauwHJH80ZDJGMQqxnBI5aeZJ+FCuq/MFHX0zkfMWxnHh1GeIxE8b+DXM j0CfffC91R7gKtFeRzomtgIuCOXYG+1OBKi0B6uLq2sSa/faJPn/zEqU3pDysP1xbiZQ 3M5A== 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=bvnzbM1V/v21TQTXSkhY6XD51NKXzk91beoDIhOObL8=; b=mACqmvd64CHMcZ8XWRWXg0CWYTR2V6m43hf+y0hLU6ThOcx89tJobyPVm8ySxjST3j dIsYvRQcQNzL3Mz2q7oRfrz1HVtlyT8u+tohJUI0tZHYdiAz0oV4kFJvAIsn7620Za+h 2HW5y7ktsRY3hMya5f6nSY2YSW4nhsGKcLE8suMj7QGO2nuIJWIDqDXQhOnb5SEPqgHl 5O7BEwvPV0uuOC+6nVYMbfVXfFP/AaZrOjMo+In+5eKR26n5/GdvIxKW2rS6gWJ+7ZG9 u+MaE38BmBHaR4O5yphTQlr+ApbcvlEANjlx82NhsGsv0q3NMyGmiO3ZRTBbgF4Ef7BA EP4w== X-Gm-Message-State: AOAM532cvUTVXBf0OLhq+APpKrn0dKm/vdPhohDS0c/Vo2i0qH8rkN0I 5xivhZJ4qcLheYkyW6QHByBg0dkVVxkJ3w== X-Google-Smtp-Source: ABdhPJzzhrBeRRQuVIrO7Lr7PP8jcz32vmouslUuV6e7T6IzSs/8w1LLkkHkXZmumW910+0haoNDBw== X-Received: by 2002:a9d:8cc:: with SMTP id 70mr10809423otf.289.1623625121308; Sun, 13 Jun 2021 15:58:41 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id 30sm2407123ott.78.2021.06.13.15.58.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Jun 2021 15:58:40 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Jeff King , Junio C Hamano , Felipe Contreras Subject: [PATCH 2/4] merge: fix Yoda conditions Date: Sun, 13 Jun 2021 17:58:34 -0500 Message-Id: <20210613225836.1009569-3-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210613225836.1009569-1-felipe.contreras@gmail.com> References: <20210613225836.1009569-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Signed-off-by: Felipe Contreras --- builtin/merge-file.c | 2 +- xdiff/xmerge.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/builtin/merge-file.c b/builtin/merge-file.c index 0186f4156a..6affccaf19 100644 --- a/builtin/merge-file.c +++ b/builtin/merge-file.c @@ -51,7 +51,7 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix) if (startup_info->have_repository) { /* Read the configuration file */ git_config(git_xmerge_config, NULL); - if (0 <= git_xmerge_style) + if (git_xmerge_style >= 0) xmp.style = git_xmerge_style; } diff --git a/xdiff/xmerge.c b/xdiff/xmerge.c index 1659edb453..ab3448ca88 100644 --- a/xdiff/xmerge.c +++ b/xdiff/xmerge.c @@ -487,7 +487,7 @@ static int xdl_do_merge(xdfenv_t *xe1, xdchange_t *xscr1, * "diff3 -m" output does not make sense for anything * more aggressive than XDL_MERGE_EAGER. */ - if (XDL_MERGE_EAGER < level) + if (level > XDL_MERGE_EAGER) level = XDL_MERGE_EAGER; } @@ -603,10 +603,10 @@ static int xdl_do_merge(xdfenv_t *xe1, xdchange_t *xscr1, if (!changes) changes = c; /* refine conflicts */ - if (XDL_MERGE_ZEALOUS <= level && + if (level >= XDL_MERGE_ZEALOUS && (xdl_refine_conflicts(xe1, xe2, changes, xpp) < 0 || xdl_simplify_non_conflicts(xe1, changes, - XDL_MERGE_ZEALOUS < level) < 0)) { + level > XDL_MERGE_ZEALOUS) < 0)) { xdl_cleanup_merge(changes); return -1; } From patchwork Sun Jun 13 22:58:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12317919 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 0CCADC48BE8 for ; Sun, 13 Jun 2021 22:59:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E201161363 for ; Sun, 13 Jun 2021 22:59:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232236AbhFMXCA (ORCPT ); Sun, 13 Jun 2021 19:02:00 -0400 Received: from mail-ot1-f49.google.com ([209.85.210.49]:42509 "EHLO mail-ot1-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232181AbhFMXB7 (ORCPT ); Sun, 13 Jun 2021 19:01:59 -0400 Received: by mail-ot1-f49.google.com with SMTP id w23-20020a9d5a970000b02903d0ef989477so9076676oth.9 for ; Sun, 13 Jun 2021 15:59:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TsewPFur6US8iCogUp0fhQqt3tQPgXXXzcJV06V66uE=; b=Jo+ZwWo/0iImxd2aFDEQomNPMPeujSfZyrFAYtlP5om4vZAyQKzphy8EeHfT8jk9zB FnH2a99+p+Zy52BK7ZPFty5llN7TXQW3MFjDcNv/yGtDNdngLPwIwpjQKNIPTxBqw5Un jW41DgGVYGgwVxwfQRA35ikzJtBB2gXuSEe5Wa+mE0zdVxU5g0qklWqZQHlOtmtPPcZN oxzJ1PcS/z26ayTWqx5oaa8qQSF5kxmcC14wr9LPY0Z6GDPgoPTsIcWkwFNeqEe5f2fU PWMhk4kAZkNkvYkbI2BQ/oj66/quk8sZxpGENidpnM1x2ZgNuEHcShzN8eIEaMslhYK1 nsyw== 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=TsewPFur6US8iCogUp0fhQqt3tQPgXXXzcJV06V66uE=; b=hF3pyIbysM6jSlrsrrFloUlG2osjMYPTt/bTLNbxLPKu7A5DLQC01rniqJtKeCWrIH kw2yepDtddvFnV0Dagv4nS+7tOwNGMawgDN0c5SdTCk8gOdPCiN5uuyqSEB6R4dkqHek dNmY+KlTD4daaeFrKApwiYqccXKM9olh7HT/VZpsrcWxusIhW0DZUdpirSZs0ctMfgWq SyF0lJpXndajHiEPCsmVYqcilKHhYAge18JqFeUSdg5VBU7NlvwMdFeKMVqz/Gj5u4hq LWf1Wf/qiCAZ4/O27P7kzd6m49WvAvi5+qXNFzUoaP5izEPP/k4NE/VW9Aq523KHTN9/ 1O0g== X-Gm-Message-State: AOAM5320uLUoa+wI5pZonvnNfYc5uqstRZcMGWpe8s5DdkP08Q2Zqe77 ceOnGHNI7EoF2QNlNXxeKsdUZmic3Z8c9w== X-Google-Smtp-Source: ABdhPJxwtwS/N5rraMjRxVM9+PtiPZ2l6w0Z5yd9qUtfuJJZV2RfoY7PGyYuawEkJ71PC525CQuwcA== X-Received: by 2002:a05:6830:16cd:: with SMTP id l13mr10998258otr.171.1623625122831; Sun, 13 Jun 2021 15:58:42 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id p9sm2868410otl.64.2021.06.13.15.58.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Jun 2021 15:58:42 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Jeff King , Junio C Hamano , Felipe Contreras Subject: [PATCH 3/4] xdiff/xmerge: simplify xdl_recs_copy_0 Date: Sun, 13 Jun 2021 17:58:35 -0500 Message-Id: <20210613225836.1009569-4-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210613225836.1009569-1-felipe.contreras@gmail.com> References: <20210613225836.1009569-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Remove one unnecessary indentation level. Signed-off-by: Felipe Contreras --- xdiff/xmerge.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/xdiff/xmerge.c b/xdiff/xmerge.c index ab3448ca88..b5b3f56f92 100644 --- a/xdiff/xmerge.c +++ b/xdiff/xmerge.c @@ -122,19 +122,19 @@ static int xdl_recs_copy_0(int use_orig, xdfenv_t *xe, int i, int count, int nee for (i = 0; i < count; size += recs[i++]->size) if (dest) memcpy(dest + size, recs[i]->ptr, recs[i]->size); - if (add_nl) { - i = recs[count - 1]->size; - if (i == 0 || recs[count - 1]->ptr[i - 1] != '\n') { - if (needs_cr) { - if (dest) - dest[size] = '\r'; - size++; - } - + if (!add_nl) + return size; + i = recs[count - 1]->size; + if (i == 0 || recs[count - 1]->ptr[i - 1] != '\n') { + if (needs_cr) { if (dest) - dest[size] = '\n'; + dest[size] = '\r'; size++; } + + if (dest) + dest[size] = '\n'; + size++; } return size; } From patchwork Sun Jun 13 22:58:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12317913 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 89767C48BE8 for ; Sun, 13 Jun 2021 22:59:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6873A6124B for ; Sun, 13 Jun 2021 22:59:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232225AbhFMXBB (ORCPT ); Sun, 13 Jun 2021 19:01:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232181AbhFMXBB (ORCPT ); Sun, 13 Jun 2021 19:01:01 -0400 Received: from mail-ot1-x32e.google.com (mail-ot1-x32e.google.com [IPv6:2607:f8b0:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F357C061574 for ; Sun, 13 Jun 2021 15:58:45 -0700 (PDT) Received: by mail-ot1-x32e.google.com with SMTP id w23-20020a9d5a970000b02903d0ef989477so9076737oth.9 for ; Sun, 13 Jun 2021 15:58:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/vlpUfp9K00BVnxAIIyPR+nmhbV27ININ2rArAaXpSM=; b=M05/36iFmfx1OMfDiUQ5s9JFxWx03OwRJSzOjg3WIoKQ1oxhVfSk9Z8FQ96RKf/g7a 8F07LMF7PyXhBrXkau2lESZ66Ui8IO2zrgL7FI9Zz3L+QIRMJJVJhJK4Dn6rtFZJCrL7 hwJJHWO8HT6sFc08QCTOycYyS4gv/yf7i7fQOe8/aJ3GCdRAxPoeXCARGRA95wh+F5z2 qL8QE8f3M0wP1HRw7so3jhG7EQgsZBq4WkZvYAla25ac3n4oVPqYNN+kY6Xv2zrcxr52 w1tFg3dyLbP2Na+0CEUvZk8hzSad2H1+6l+52M749EoP8SkEWCreEHlHLRPpO/dS5c/N rJ7Q== 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=/vlpUfp9K00BVnxAIIyPR+nmhbV27ININ2rArAaXpSM=; b=nqT2UMHL3ucMzUOx4/fwTtB3moQOxm/TsUKC1Rf4NoXO9l8bcjowEF01mWadx5xXJ4 xhLrSP125fyuD3fF3j/lFr1ivaFSG/zd3B3Zetp4qn4NB5ulBYFPM4ulMZnnZoN/b7ys c63DBHkER+Nk4LgJMX1Kp12syMV0RWF2BNgldf3XmUhIdcdcUTjhMJgSMSN5Easy/KFY p2mEdVnimBowjUEGaG1i7eoz3XUBsaOVA/zFxoxQmnu9h/OgCARr7jdlhxpAbedjH6+n N+2wb2luBHp1CVes6nWyL3fl0hfy0AKnLs0tTOqeqeRjctJ1J+Ev2gidLZlWxnR5ny0n y/cQ== X-Gm-Message-State: AOAM530+GvTI9kO5+Az3dnnlyCmQbt6cxVkfMZiknBZs3TtxF3EMlzJM RwyZssGx0UkovfoGZxgMIEDLEaU2AcbWJw== X-Google-Smtp-Source: ABdhPJzbIMrRu3IPjyi51MWNvv2ayXduXs11T536OsMeZLN9htahCYJvLRo2dLSYAyLE09sVxQ0VPQ== X-Received: by 2002:a9d:ea2:: with SMTP id 31mr11705355otj.200.1623625124382; Sun, 13 Jun 2021 15:58:44 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id r1sm2964049oth.19.2021.06.13.15.58.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Jun 2021 15:58:44 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Jeff King , Junio C Hamano , Felipe Contreras Subject: [PATCH 4/4] xdiff/xmerge: fix chg0 initialization Date: Sun, 13 Jun 2021 17:58:36 -0500 Message-Id: <20210613225836.1009569-5-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210613225836.1009569-1-felipe.contreras@gmail.com> References: <20210613225836.1009569-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org chg0 is needed when style is XDL_MERGE_DIFF3, xdl_refine_conflicts() currently is only called when level >= XDL_MERGE_ZEALOUS, which cannot happen since the level is capped to XDL_MERGE_EAGER. However, if at some point in the future we decide to not cap diff3, or introduce a similar uncapped mode, an uninitialized chg0 would cause a crash. Let's initialize it to be safe. Cc: Jeff King Signed-off-by: Felipe Contreras --- xdiff/xmerge.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xdiff/xmerge.c b/xdiff/xmerge.c index b5b3f56f92..d9b3a0dccd 100644 --- a/xdiff/xmerge.c +++ b/xdiff/xmerge.c @@ -333,7 +333,7 @@ static int xdl_refine_conflicts(xdfenv_t *xe1, xdfenv_t *xe2, xdmerge_t *m, mmfile_t t1, t2; xdfenv_t xe; xdchange_t *xscr, *x; - int i1 = m->i1, i2 = m->i2; + int i0 = m->i0, i1 = m->i1, i2 = m->i2; /* let's handle just the conflicts */ if (m->mode) @@ -384,6 +384,8 @@ static int xdl_refine_conflicts(xdfenv_t *xe1, xdfenv_t *xe2, xdmerge_t *m, m->next = m2; m = m2; m->mode = 0; + m->i0 = i0; + m->chg0 = 0; m->i1 = xscr->i1 + i1; m->chg1 = xscr->chg1; m->i2 = xscr->i2 + i2;