From patchwork Tue Aug 2 21:41:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12935049 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A10DAC00140 for ; Tue, 2 Aug 2022 21:41:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234691AbiHBVll (ORCPT ); Tue, 2 Aug 2022 17:41:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230252AbiHBVlj (ORCPT ); Tue, 2 Aug 2022 17:41:39 -0400 Received: from mail-oi1-x22a.google.com (mail-oi1-x22a.google.com [IPv6:2607:f8b0:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26E3913F8B for ; Tue, 2 Aug 2022 14:41:38 -0700 (PDT) Received: by mail-oi1-x22a.google.com with SMTP id p132so17973584oif.9 for ; Tue, 02 Aug 2022 14:41:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=yLh5wycFW2229a754eWiyLX+FUa/e4cpDSnEqRG3XKM=; b=COAmRcbAlcgaNuCDVONoiDZiYcSe6+80EFeuWh4uQm7IGh5v6AIROVSYnt2wIr7lA2 /rjLsLEHstcBh70kLOavh0wgxvLC9b0AgL/d+8X63l1M1x6OAPaZfxmCA8Z/TPw0j2zt W2PzeEwzPr2vs3vPj4N5aSxqYIYNcXqqDlXepFbDVJ5GHVl2IlznUuOQ6o4HmwRWYevY JoRjBl0thqek+st5AkKdv4l3e/gzAvASe0Xcw4cY40ux6Ygjs0Sk5TWVzVnedzn/7gV1 lYBwFIYSAyIg56jp+hQU5IoJlfe/+abDrpbFZsPCFss7yG60yApR9iuRcj8lxNlOgkSf cAgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=yLh5wycFW2229a754eWiyLX+FUa/e4cpDSnEqRG3XKM=; b=p3dmCbAhRTKR9Lpoule9hreiTtWXH7yl41nw+ysd180R5qPRjJX9uLpLYNber5jwBc hBvz0vbGpZm6T10kocLRHnuFg3YktoYEG7EGxqsO9p1bBPbagXBpbFq6GdaMSOIIPb+U +M5kKqjgDK88KwtgmsGMSRoNPX7FW4Vi40LwQ3n1nuhONZ8xrvYvnIfuKCbQpHVq1UzM Lhl/RYHwuzEc24L1atfDkVBQFhKp/Y4pqlYkVgD67LOv3saDjQCTmEvVRDuTBlchqwCi +QRLKV4qF/CpTRPdz18rDA9y4Gag2VG34gH2hjj1trOIsH+WK1dN4g94yaVrg2Exfqp/ jxKw== X-Gm-Message-State: ACgBeo08fGE6W+7HkYOfEOYmxh0Kp7jF4iDToh7ReWEb0/l4VW1A61YF LlH9UHHnqrm/Gk5Z6u5w0vy7isNCAsU= X-Google-Smtp-Source: AA6agR6O0XHkRAhd+fNHwgEQnSHNc6g4JR9pk5dHLkAS2PpXxa39Z1WQc5Rvaf1BUYZAaCzOnzB6MQ== X-Received: by 2002:a05:6808:2194:b0:33a:bab5:ddbe with SMTP id be20-20020a056808219400b0033abab5ddbemr577491oib.3.1659476497188; Tue, 02 Aug 2022 14:41:37 -0700 (PDT) Received: from localhost ([2806:2f0:4000:5c95:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id a40-20020a056870d62800b0010e00d6a1c0sm4032052oaq.51.2022.08.02.14.41.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Aug 2022 14:41:36 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Fernando Ramos , Felipe Contreras Subject: [PATCH 1/2] mergetools: vimdiff3: make it work as intended Date: Tue, 2 Aug 2022 16:41:33 -0500 Message-Id: <20220802214134.681300-2-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.1.313.ge269dbcbc5 In-Reply-To: <20220802214134.681300-1-felipe.contreras@gmail.com> References: <20220802214134.681300-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When vimdiff3 was added in 7c147b77d3 (mergetools: add vimdiff3 mode, 2014-04-20), the description made clear the intention: It's similar to the default, except that the other windows are hidden. This ensures that removed/added colors are still visible on the main merge window, but the other windows not visible. However, in 0041797449 (vimdiff: new implementation with layout support, 2022-03-30) this was broken by generating a command that never creates windows, and therefore vim never shows the diff. In order to show the diff, the windows need to be created first, and then when they are hidden the diff remains (if hidenoff isn't set). The layout support implementation broke the whole purpose of vimdiff3, and simply shows MERGED, which is no different from simply opening the file with vim. We could restore the correct behavior by modifying gen_cmd to open all the windows, and then hide them, but there's no need to do that when the -d option of vim (vimdiff) does precisely that. So let's skip the whole gen_cmd function for vimdiff3, and hide the windows, therefore restoring the previous intended behavior. Cc: Fernando Ramos Signed-off-by: Felipe Contreras --- mergetools/vimdiff | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/mergetools/vimdiff b/mergetools/vimdiff index f770b8fe24..f4c3bf6d11 100644 --- a/mergetools/vimdiff +++ b/mergetools/vimdiff @@ -388,26 +388,36 @@ merge_cmd () { layout=$(git config mergetool.vimdiff.layout) case "$1" in - *vimdiff) - if test -z "$layout" + *vimdiff3) + if $base_present then - # Default layout when none is specified - layout="(LOCAL,BASE,REMOTE)/MERGED" + CMD='hid | hid | hid' + else + CMD='hid | hid' fi + FINAL_CMD="-d -c '$CMD'" ;; - *vimdiff1) - layout="@LOCAL,REMOTE" - ;; - *vimdiff2) - layout="LOCAL,MERGED,REMOTE" - ;; - *vimdiff3) - layout="MERGED" + *) + case "$1" in + *vimdiff) + if test -z "$layout" + then + # Default layout when none is specified + layout="(LOCAL,BASE,REMOTE)/MERGED" + fi + ;; + *vimdiff1) + layout="@LOCAL,REMOTE" + ;; + *vimdiff2) + layout="LOCAL,MERGED,REMOTE" + ;; + esac + + gen_cmd "$layout" ;; esac - gen_cmd "$layout" - debug_print "" debug_print "FINAL CMD : $FINAL_CMD" debug_print "FINAL TAR : $FINAL_TARGET" From patchwork Tue Aug 2 21:41:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12935050 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42D8EC19F2B for ; Tue, 2 Aug 2022 21:41:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234785AbiHBVln (ORCPT ); Tue, 2 Aug 2022 17:41:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234211AbiHBVlk (ORCPT ); Tue, 2 Aug 2022 17:41:40 -0400 Received: from mail-oa1-x33.google.com (mail-oa1-x33.google.com [IPv6:2001:4860:4864:20::33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC21C140F3 for ; Tue, 2 Aug 2022 14:41:39 -0700 (PDT) Received: by mail-oa1-x33.google.com with SMTP id 586e51a60fabf-10ea7d8fbf7so13506473fac.7 for ; Tue, 02 Aug 2022 14:41:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=IhCWye945A4XmVVuVAk2VgYttRGu4+5PKrVE94+/IDo=; b=CUiDHr3RT5CWwJgi4p1qXkTeRULfp8hHQdhXPag68PkVbLlM76yMWK2osvFiVgMoZQ GVn1GQhlEd2/63+6xz11ZEzgY1UW7kebpXE4Oczow62VD1VmipJms22v3qdpNnMTKUZQ s8zCvRHwfaWAN374DUp6qF2Fj7J6XRhY4EuwzcFOUalm7rRULUHiIfKuBplZIZhOeznU ZW2dR9e6PyabdprpeXtTmS23uL3rmh4n66K6dm3Y/RXOGbj6XM1gWWbOCTGMj/O0YeWb AnhVMOIJMa2SHkqk0qlHe/eVJ8Ml1GXVxK8W30DEwq1RrFTrAI3jKt44s2iMtF0+RUAb Ml0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=IhCWye945A4XmVVuVAk2VgYttRGu4+5PKrVE94+/IDo=; b=ht11E4vlneP6THoC8CqluN6VSFgiSx9DruI74tc0MaSw3MoB2L+W5MsY5mJpZwgwwU /GqbnfIu57ZlikXvSL9pKI+/85KL7hQNsldxkmnGfCA3hauAIoKUBlWmmgWZjepbhhHU 09KGlkXd0D8uGyg4ThgwTeGueEB60uuc3fO7fyYhQU0QW+NgvxBoMhjYebEH1ipKT08z CIfph3V82/Fz1Ksn5E/uE2UwhsRv11s9fiKgrqJ7WLSzS1YNwAH1YAZ9w7HUOcG87Z49 FtSRMUDERcutNLxQWCZ/86aBrx9ace5PKK8/yc6Qn6lwHB6RGN+AfHG1Q8JpvIvU0zR8 kFBw== X-Gm-Message-State: ACgBeo2cknex1Kci+7wEqow3gUZvGirEB9Nrft8m1LCYyqEcTeDI+FDR naYxg2zcX7mjYeBo2Bn6Xvt26x2gumU= X-Google-Smtp-Source: AA6agR4HXjiM4uG4O7jy45K5Gh+Ozg3eSDLr0xj7x7lSa4AFkYosdy3W+Tm5kdQ+davMEZJrB9cAQg== X-Received: by 2002:a05:6870:32cb:b0:10c:289b:76ba with SMTP id r11-20020a05687032cb00b0010c289b76bamr661781oac.72.1659476498794; Tue, 02 Aug 2022 14:41:38 -0700 (PDT) Received: from localhost ([2806:2f0:4000:5c95:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id z9-20020a05687041c900b001048f70e03dsm4073330oac.15.2022.08.02.14.41.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Aug 2022 14:41:38 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Fernando Ramos , Felipe Contreras Subject: [PATCH 2/2] mergetools: vimdiff3: fix diffopt options Date: Tue, 2 Aug 2022 16:41:34 -0500 Message-Id: <20220802214134.681300-3-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.1.313.ge269dbcbc5 In-Reply-To: <20220802214134.681300-1-felipe.contreras@gmail.com> References: <20220802214134.681300-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org If either closeoff or hiddenoff are enabled, vimdiff3 doesn't work as intended, so turn them off. Signed-off-by: Felipe Contreras --- mergetools/vimdiff | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mergetools/vimdiff b/mergetools/vimdiff index f4c3bf6d11..baccabc403 100644 --- a/mergetools/vimdiff +++ b/mergetools/vimdiff @@ -395,7 +395,7 @@ merge_cmd () { else CMD='hid | hid' fi - FINAL_CMD="-d -c '$CMD'" + FINAL_CMD="-d -c 'setl diffopt-=closeoff diffopt-=hiddenoff | $CMD'" ;; *) case "$1" in