From patchwork Mon Sep 30 19:54:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bert Wesarg X-Patchwork-Id: 11167573 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B9D7C1709 for ; Mon, 30 Sep 2019 21:04:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 97FD322515 for ; Mon, 30 Sep 2019 21:04:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=googlemail.com header.i=@googlemail.com header.b="r7BRjTMM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732495AbfI3VEA (ORCPT ); Mon, 30 Sep 2019 17:04:00 -0400 Received: from mail-ed1-f66.google.com ([209.85.208.66]:46825 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727146AbfI3VD7 (ORCPT ); Mon, 30 Sep 2019 17:03:59 -0400 Received: by mail-ed1-f66.google.com with SMTP id t3so9894732edw.13 for ; Mon, 30 Sep 2019 14:03:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=7GVRNYReK5e+xaXYbkIkUPkbpyuBe8XxSH6w5AcRiMg=; b=r7BRjTMMHWsbmmO7EscXvtx/ZEeg26O/uZHDm+AQjzZXhpqXzWxG887YpnMxC4OIZb 78n4oCDTgNjdyqpmH7J5rxozjcS6XNmEmTlDQNLUE0eyPt52eKmCCmW1B1uutS1ErT/U a+GcsSd+yGshVsvZO7atL4TTP2JzNZ9SoyiVHvhjeQtbbLcUFsMRrYrv3R250zBGQYXj f7lc+VzSRXMgVm0XhVLnfkpM4fWfDzcTsIxdNcSg0Uqsvolp41qPbWz71+B+VTLarTtw SS5eMCDaLRdmcVvHP2p7v7YOI4oFYWqbtEf1Q0Uqc90BO/FDDAkRdkUGoj1iNuKrAVY0 9Zrw== 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:mime-version :content-transfer-encoding; bh=7GVRNYReK5e+xaXYbkIkUPkbpyuBe8XxSH6w5AcRiMg=; b=MD1Vpk1bJkvfOMpPfIXN8iqjnaeKf6Ck6R2ziEIENjcc+2RZa6qhGTD2/0yp2xJWsA aq3z7HbMiP8r3LiNICZMBkuWduTrXUeILaDKn3gNOOPFIN/hjZqrAHbuZ/n1WkxH4xQc Wz2zjeabJIrt/Irp7C3riyeXplRmNu5OSWlDD9fBaXl9O8V05dXMjnYxvU6Oc/iA7eY+ 30KXPtUTF/E48ou+KQnrX9POR0LXT8APmMORpPmzgV4lBF0Scp9PyADzIoeEsPiPcJ59 mTNmmxibEOkN2EqbunMhFEOe6a7dffP6PUi9+aUbL4xejeQQngBKywYgi1pRmaJXJpnY Fhwg== X-Gm-Message-State: APjAAAWy8HvqIWIxs4IcgPZ7Ktf5/v7dnT/AE8t1xsQEDcAOYXB+z7f2 5eJ7/ug9xLYBU9iCHo0= X-Google-Smtp-Source: APXvYqzL94hFgMVpHtN5IL/oEJMEypOJoPSoWFWbAj2CosGcAgEB1AK9R70jYtu0fKBI2PVd/mRYuQ== X-Received: by 2002:aa7:c343:: with SMTP id j3mr21830139edr.187.1569873294926; Mon, 30 Sep 2019 12:54:54 -0700 (PDT) Received: from localhost ([2a02:810a:8c80:d2c:4d89:574b:af6e:1a3]) by smtp.gmail.com with ESMTPSA id k22sm1565575eja.56.2019.09.30.12.54.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 30 Sep 2019 12:54:54 -0700 (PDT) From: Bert Wesarg To: git@vger.kernel.org Cc: Bert Wesarg , Pratyush Yadav Subject: [PATCH v3 1/2] git-gui: use existing interface to query a path's attribute Date: Mon, 30 Sep 2019 21:54:52 +0200 Message-Id: <97013a71289857767100d6a4adcb39ca99b2b21b.1569873171.git.bert.wesarg@googlemail.com> X-Mailer: git-send-email 2.23.0.11.g242cf7f110 MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Replace the hand-coded call to git check-attr with the already provided one. Signed-off-by: Bert Wesarg --- lib/diff.tcl | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/lib/diff.tcl b/lib/diff.tcl index 958a0fa..0fd4600 100644 --- a/lib/diff.tcl +++ b/lib/diff.tcl @@ -270,19 +270,6 @@ proc show_other_diff {path w m cont_info} { } } -proc get_conflict_marker_size {path} { - set size 7 - catch { - set fd_rc [eval [list git_read check-attr "conflict-marker-size" -- $path]] - set ret [gets $fd_rc line] - close $fd_rc - if {$ret > 0} { - regexp {.*: conflict-marker-size: (\d+)$} $line line size - } - } - return $size -} - proc start_show_diff {cont_info {add_opts {}}} { global file_states file_lists global is_3way_diff is_submodule_diff diff_active repo_config @@ -298,7 +285,7 @@ proc start_show_diff {cont_info {add_opts {}}} { set is_submodule_diff 0 set diff_active 1 set current_diff_header {} - set conflict_size [get_conflict_marker_size $path] + set conflict_size [gitattr $path conflict-marker-size 7] set cmd [list] if {$w eq $ui_index} { From patchwork Wed Oct 2 07:36:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bert Wesarg X-Patchwork-Id: 11170589 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4BEE01709 for ; Wed, 2 Oct 2019 07:36:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 29745215EA for ; Wed, 2 Oct 2019 07:36:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=googlemail.com header.i=@googlemail.com header.b="CD5MQAB6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726902AbfJBHgG (ORCPT ); Wed, 2 Oct 2019 03:36:06 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:34959 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726783AbfJBHgF (ORCPT ); Wed, 2 Oct 2019 03:36:05 -0400 Received: by mail-wm1-f65.google.com with SMTP id y21so5788665wmi.0 for ; Wed, 02 Oct 2019 00:36:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tFnttCed13jYBuJxShS3UDdAo0SwnChsGPD7bTLyt90=; b=CD5MQAB6blVbxL0/bHxm3tpQOXoZpucUvE7Vv+CNhVLwgX243tXRA3AmsKBr/IsUGW B4qF2chmQ8uDat/s+VygGYWnTzWcac/iravB1WJWM/W+AlV12Kn7Gy7Aspz01CK9Fe8I IFGlYDNsvSntzLRBFgoatQa4ruoJFCqlB//APkn439o4njXyhpKuC/D7JJ2Jnd2UYG49 Q7+yn0kmTEBRdNTHKgebmZkkpXagGt4bCOWO4+dAm0NHF98OgjpSsdmQXXaCosj0IoCW n053/iQ38hUqX05i0d+DrFPPyFJM6uJQb7I/cLcearaofv8aElVDbBCoY5cK+fxKqW+w kR4g== 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=tFnttCed13jYBuJxShS3UDdAo0SwnChsGPD7bTLyt90=; b=tx8A36xmoyXnXFaorr4LeuFJPsojxUM+lReZFpsZQR9LiGyvAyiQO3YBp62+86yTrb Yto3JCw6j7WhVs9J/kQiaC7tDey2kolB6xlNzNacooElmt00+no4tj5o1/Wzw99M+Q7m hba/uiXzjMUVYNPEQvThBcOQrr6WwANk09C0AcVTxQevVJYzJHvHu0yGfBYp8apFrIOY gqPOsxLCgUYHksA5Unu09ftkalPHIwQxDrD3MtwK0PG+ssuFEi+R45YUd7mRHzTMW/Kc OXWv4Vbuxc2txtPLzkIQqR++/RmNvpH0r0gS5H1tgTRLTIJgZ4zH6wsYsMzYkm8Yq26B bHfw== X-Gm-Message-State: APjAAAWg5vwE19N8zNiyYEp5XN9/HvqBndyV4Ce1tJBs59JDBziRi2cH tCU0In3foWyNb9fB/fxAbw== X-Google-Smtp-Source: APXvYqw+n2aEIiKuBRAZhJW5AtzxOG3pcmdv9H4i5tkquDAn5OZ1ea4K5S2vPzb1HeI8o80yyMp4tA== X-Received: by 2002:a1c:720b:: with SMTP id n11mr1544530wmc.23.1570001763737; Wed, 02 Oct 2019 00:36:03 -0700 (PDT) Received: from localhost (m221.zih.tu-dresden.de. [141.30.68.221]) by smtp.gmail.com with ESMTPSA id a10sm20108186wrm.52.2019.10.02.00.36.03 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 02 Oct 2019 00:36:03 -0700 (PDT) From: Bert Wesarg To: git@vger.kernel.org Cc: Bert Wesarg , Philip Oakley , Pratyush Yadav Subject: [PATCH v3 2/2] git-gui: support for diff3 conflict style Date: Wed, 2 Oct 2019 09:36:02 +0200 Message-Id: X-Mailer: git-send-email 2.23.0.11.g242cf7f110 In-Reply-To: <97013a71289857767100d6a4adcb39ca99b2b21b.1569873171.git.bert.wesarg@googlemail.com> References: <14754a59ecf15194dccc659072e2bc180280d097.1569845908.git.bert.wesarg@googlemail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org This adds highlight support for the diff3 conflict style. The common pre-image will be reversed to --, because it has been removed and replaced with ours or theirs side respectively. Signed-off-by: Bert Wesarg --- git-gui.sh | 3 +++ lib/diff.tcl | 17 ++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) --- v3: Fixed a syntax error diff --git a/git-gui.sh b/git-gui.sh index fd476b6..6d80f82 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -3581,6 +3581,9 @@ $ui_diff tag conf d_s- \ $ui_diff tag conf d< \ -foreground orange \ -font font_diffbold +$ui_diff tag conf d| \ + -foreground orange \ + -font font_diffbold $ui_diff tag conf d= \ -foreground orange \ -font font_diffbold diff --git a/lib/diff.tcl b/lib/diff.tcl index 0fd4600..dacdda2 100644 --- a/lib/diff.tcl +++ b/lib/diff.tcl @@ -347,6 +347,10 @@ proc start_show_diff {cont_info {add_opts {}}} { } set ::current_diff_inheader 1 + # detect pre-image lines of the diff3 conflict-style, they are just '++' + # lines which is not bijective, thus we need to maintain a state across + # lines + set ::conflict_in_pre_image 0 fconfigure $fd \ -blocking 0 \ -encoding [get_path_encoding $path] \ @@ -449,11 +453,22 @@ proc read_diff {fd conflict_size cont_info} { {--} {set tags d_--} {++} { set regexp [string map [list %conflict_size $conflict_size]\ - {^\+\+([<>=]){%conflict_size}(?: |$)}] + {^\+\+([<>=|]){%conflict_size}(?: |$)}] if {[regexp $regexp $line _g op]} { set is_conflict_diff 1 set line [string replace $line 0 1 { }] set tags d$op + # the ||| conflict-marker marks the start of the pre-image, + # all those lines are also prefixed with '++', thus we need + # to maintain this state + set ::conflict_in_pre_image [expr {$op eq {|}}] + } elseif {$::conflict_in_pre_image} { + # this is a pre-image line, it is the one which both sides + # are based on. As it has also the '++' line start, it is + # normally shown as 'added', invert this to '--' to make + # it a 'removed' line + set line [string replace $line 0 1 {--}] + set tags d_-- } else { set tags d_++ }