From patchwork Mon Sep 30 12:20:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bert Wesarg X-Patchwork-Id: 11166573 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 CC6751599 for ; Mon, 30 Sep 2019 12:20:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9E71E2054F for ; Mon, 30 Sep 2019 12:20:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=googlemail.com header.i=@googlemail.com header.b="tRprH+dp" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729874AbfI3MUL (ORCPT ); Mon, 30 Sep 2019 08:20:11 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:44265 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729603AbfI3MUL (ORCPT ); Mon, 30 Sep 2019 08:20:11 -0400 Received: by mail-wr1-f66.google.com with SMTP id i18so11021188wru.11 for ; Mon, 30 Sep 2019 05:20:09 -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=tRprH+dpPmTjqNliNuj0I0HbY8NvL+Z9okH0S5OKLYrU5n1idg+vJjEaTCn4wK10Xa WXzsk2dwQDw2ll48jNmQxj3ag7tu4rYKC4U972KqDzkpw1h2V/kYceyzF92/jUWynpAj eWQV0aQ0TIFh9VGphc/ZsLAq0XusR9vp/YRqQUCKEs/fWBd/7VL+TCOAukWYdiuXp5Hg sJQuJjIjcT4mKvGt91gEx4j9WwHdcm/Vyz0CqE2FU2vAAeBeIED3l8ctNBnkrG3G38fv Mb7i+sg2e/deuicF8n1dkxbMD0qrd+A8CVRyoaI15hib+yTFFOYrlUjb/9QdkeqOOTTa TKNQ== 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=gpW0iXSm4vWPxFxbvIhNgOUoB+EPLuphLItd99KwHRUjl9EBn3XInkG16WjclA6cAd ihG7qK83oxa+V7RmJ8ZZlSQvuZkydtOrl2EzxMaYmjHsBacUVOxBAKzRobXtrk86Q+Nd JJjpTiL3tYswnU3N60gzGPMkwS2/TEC1eAHCSgjc+zrkv2WChP0JGcbUP4zrXqCVzDRL 3GaivrkofvOofKNXAUlUB7NQRUAb0gU7wqizb2SMnL4bGTEluqskBFiUCUkk3Y/BHRBw DWzcVL51DhOByqdMpfp+dV8faDmjqsCBiS2W//pYJ1r4O5/o2KIkPDeJhu1qkBtlOVHs N3oA== X-Gm-Message-State: APjAAAULisSm+JCkOoZZYohDI75sshMY3m0fDDl3S8d79WyUV9TJ6ykg coSr4E2C1Wl0i7JAT9Y= X-Google-Smtp-Source: APXvYqwYBgWj0zQ+IPfCe8p0hHI/NDSeH8E7xzSyjNUe7RXYgKkD3ybsOhHoSb5BwcSetM1MY2eKGw== X-Received: by 2002:adf:bb8e:: with SMTP id q14mr14204710wrg.74.1569846009099; Mon, 30 Sep 2019 05:20:09 -0700 (PDT) Received: from localhost (m221.zih.tu-dresden.de. [141.30.68.221]) by smtp.gmail.com with ESMTPSA id a192sm14578755wma.1.2019.09.30.05.20.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 30 Sep 2019 05:20:08 -0700 (PDT) From: Bert Wesarg To: git@vger.kernel.org Cc: Bert Wesarg , Pratyush Yadav Subject: [PATCH v2 1/2] git-gui: use existing interface to query a path's attribute Date: Mon, 30 Sep 2019 14:20:06 +0200 Message-Id: <97013a71289857767100d6a4adcb39ca99b2b21b.1569845908.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 Mon Sep 30 12:20:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bert Wesarg X-Patchwork-Id: 11166575 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 D7327112B for ; Mon, 30 Sep 2019 12:20:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B676D218AC for ; Mon, 30 Sep 2019 12:20:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=googlemail.com header.i=@googlemail.com header.b="PaGSq4zo" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730315AbfI3MUM (ORCPT ); Mon, 30 Sep 2019 08:20:12 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:42016 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726784AbfI3MUM (ORCPT ); Mon, 30 Sep 2019 08:20:12 -0400 Received: by mail-wr1-f68.google.com with SMTP id n14so11037250wrw.9 for ; Mon, 30 Sep 2019 05:20:11 -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=g7nWw8WPCUBImKMyvtDQlNwmDAeftb7FOsYAMucgmpY=; b=PaGSq4zouID7UK1+zr+cuNYywv6yLOwcT7TlZ2vxqk3uJSMyH3BWdElQ/6W4EHlpSz UQlz3wlighGwRDiI4M0cC9qMgJFz19X6lCwrTbBYDwU3gzV3zadZilz9CvS/IBF57YVW 97l1Zpt0stNeA98zs5BHrw7lvNS9Jm7drFaRic3rySc02FacqtBJ4CFKXJlBoJW+MIgL 20XSs9ZQrnbDojj5beXLfKXq+wPSEtc5pq4EjoZ6uR4vyRoywDShpQanZ6fkUfWz8GNH eJvwfd+3pWhBMeNMiRZ6zZfG0tvRkfQ/J4AZr3ALYgF85mH4MZ99hajXJnazVQJeB8G+ FQhw== 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=g7nWw8WPCUBImKMyvtDQlNwmDAeftb7FOsYAMucgmpY=; b=rvg+sEUaUqNPfpAl7HP+Abv3zZ06YqxfShGjSw2eTltvsp216jyMF3YocTXRFApHH0 zfvVxlLnhAQ2BC9YoXEzCP75oK814Y4gx+/ueuJsLryf/KVirlU5f+39P6eI8M8SY3xE nXXbWalH/4y5o5g5IbEziBZZa/0ITFrPO7ATtV9hsVMxi8ct7pjufCKxdyNsvpkf4sOT h8am2echyTRUCNhL+y6R8ucQBSPWNQ3olmdQmbAfvPHX0XO1jRPgjWQsqxeKorI/bjms rxBSs80z1TuDanlzgCvYT6snN9sBAbqKMfivPGtIgMZRvU777zxpVWcz/YP7JvFOJByQ Ns8w== X-Gm-Message-State: APjAAAVsliXU9GcTGthZjs9Fh4bdu6os0Ht8noilUdjJLR5l02AYtp3P Wp46nByftDDuTm3VrUQ= X-Google-Smtp-Source: APXvYqy5NQLTDiC0bnn4LBe8mUD3gl2V1CvZvDodqC6+iIVk3WY8kDAdsYLjwyg00aFhAJmf5g3fIw== X-Received: by 2002:adf:ef12:: with SMTP id e18mr1111285wro.65.1569846010618; Mon, 30 Sep 2019 05:20:10 -0700 (PDT) Received: from localhost (m221.zih.tu-dresden.de. [141.30.68.221]) by smtp.gmail.com with ESMTPSA id o22sm34023947wra.96.2019.09.30.05.20.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 30 Sep 2019 05:20:09 -0700 (PDT) From: Bert Wesarg To: git@vger.kernel.org Cc: Bert Wesarg , Philip Oakley , Pratyush Yadav Subject: [PATCH v2 2/2] git-gui: support for diff3 conflict style Date: Mon, 30 Sep 2019 14:20:07 +0200 Message-Id: <14754a59ecf15194dccc659072e2bc180280d097.1569845908.git.bert.wesarg@googlemail.com> X-Mailer: git-send-email 2.23.0.11.g242cf7f110 In-Reply-To: <97013a71289857767100d6a4adcb39ca99b2b21b.1569845908.git.bert.wesarg@googlemail.com> References: 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(-) 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..6459cfb 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_++ }