From patchwork Wed Sep 4 20:10:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bert Wesarg X-Patchwork-Id: 11131379 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 D73BE1399 for ; Wed, 4 Sep 2019 20:10:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B836022CED for ; Wed, 4 Sep 2019 20:10:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=googlemail.com header.i=@googlemail.com header.b="ibDl1aKR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729890AbfIDUK1 (ORCPT ); Wed, 4 Sep 2019 16:10:27 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:53797 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727125AbfIDUK1 (ORCPT ); Wed, 4 Sep 2019 16:10:27 -0400 Received: by mail-wm1-f66.google.com with SMTP id q19so144965wmc.3 for ; Wed, 04 Sep 2019 13:10:25 -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=hQI/CX+6goGxeN+fvOEdGestwrQV6fklFPnHMlqJhrk=; b=ibDl1aKRQC1CPEerI1MpsaT/CdEYvVOQ2ADA8S1/M2zgwxZmnURIg7vcyGUNFDtmNv kJG2naWchHpLRvHaE0TR2UB83oeUC74Bi2xks+rqCBCO91zNYgHwipyeU/7E2NVdhMPY R6z/q4M16OM3nQ0tubP2qjEXl5+tINpf35V6wuyM6kVnShuLQYfz8r9M5U4EzYqLHZYb OWRGBNbw6prrHTc1kUPSghExwbA27AVTzGEgWjc51Buv4d1fzqZDQLPcoYZXldPzyDYw nF83wVZv3nR7KWZQ3/aS+8CfiA7SAmE/4t616KLDwIrimkcEhMxhx2tMGlqU649GImN3 /HSg== 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=hQI/CX+6goGxeN+fvOEdGestwrQV6fklFPnHMlqJhrk=; b=V9xh7OrVT3DWuNydg5B7dR8q7pdgtOdC+PZJYbriWwor/WErvmOFmWiCcIiZNWau30 GPgMhvuYYJJMe5uuc6im3SYSFceMEw4FrHibHh2WaPFCw67b2YDNnBMnzbhUc2id8uGZ 8Wvll49+XcO59HW2i4Seyztj80A+cDbFAtDZBIYHcVfmnKc7M4lC9C6dl+37BEJbzkM8 TZSgAwjrxvCGVeyGLSu/2NAVh0d8eTkxHeL5GjB05wx8anA83oCsEiCIR0C8Zn5+Xxdz t0n1h09JpNySYVv9MbDVaFat2QJB1OGqWwMGDSgSS0GPynQgy+Qepc3LC2kdM9t61+MA Gfhg== X-Gm-Message-State: APjAAAXCMw3dGDXY73dqltM7aFViO6CIBFbXELMpRsCX1rWPvyVmvafD uDHfABPVpaVx0DE8zFloxw== X-Google-Smtp-Source: APXvYqzoJBfiGJeOEm39ptx5hSEGrrLZV6TQa1vQhfaSozXkOoE6PAf519NbPXdWaQuQAUgGa69SFA== X-Received: by 2002:a7b:ca43:: with SMTP id m3mr59312wml.20.1567627824759; Wed, 04 Sep 2019 13:10:24 -0700 (PDT) Received: from localhost ([2a02:810a:8c80:d2c:e18b:2076:d6e6:a85d]) by smtp.gmail.com with ESMTPSA id d28sm23746744wrb.95.2019.09.04.13.10.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 04 Sep 2019 13:10:24 -0700 (PDT) From: Bert Wesarg To: git@vger.kernel.org Cc: me@yadavpratyush.com, Birger Skogeng Pedersen , Bert Wesarg Subject: [PATCH 1/2] git-gui: warn if the commit message contains lines longer than the set limit Date: Wed, 4 Sep 2019 22:10:22 +0200 Message-Id: <7da71d89f9fa987eca2e25974e4cec382c146e44.1567627609.git.bert.wesarg@googlemail.com> X-Mailer: git-send-email 2.21.0.789.ga095d9d866 MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The commit message widget does not wrap the next and has a configurable fixed width to avoid creating too wide commit messages. Though this was only enforced in the GUI. Now we also check the commit message at commit time for long lines and ask the author for confirmation if it exceeds the configured line length. Needs Tcl 8.6 because of `lmap`. Signed-off-by: Bert Wesarg --- git-gui.sh | 4 ++-- lib/commit.tcl | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/git-gui.sh b/git-gui.sh index 5bc21b8..a491085 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -31,8 +31,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA}] ## ## Tcl/Tk sanity check -if {[catch {package require Tcl 8.4} err] - || [catch {package require Tk 8.4} err] +if {[catch {package require Tcl 8.6} err] + || [catch {package require Tk 8.6} err] } { catch {wm withdraw .} tk_messageBox \ diff --git a/lib/commit.tcl b/lib/commit.tcl index 83620b7..fa9760b 100644 --- a/lib/commit.tcl +++ b/lib/commit.tcl @@ -215,6 +215,16 @@ A good commit message has the following format: unlock_index return } + if {[tcl::mathfunc::max {*}[lmap x [split $msg "\n"] {string length $x}]] >= $repo_config(gui.commitmsgwidth) \ + && [ask_popup "Commit message contains lines longer than $repo_config(gui.commitmsgwidth) characters. + +You may change this limit in the options. + +Continue to commit? +"] ne yes} { + unlock_index + return + } # -- Build the message file. # From patchwork Wed Sep 4 20:10:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bert Wesarg X-Patchwork-Id: 11131381 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 1D1CF18A6 for ; Wed, 4 Sep 2019 20:10:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F15842077B for ; Wed, 4 Sep 2019 20:10:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=googlemail.com header.i=@googlemail.com header.b="LY3wVlX1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729963AbfIDUK2 (ORCPT ); Wed, 4 Sep 2019 16:10:28 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:36302 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727809AbfIDUK1 (ORCPT ); Wed, 4 Sep 2019 16:10:27 -0400 Received: by mail-wm1-f65.google.com with SMTP id p13so167615wmh.1 for ; Wed, 04 Sep 2019 13:10:26 -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=XAoHavd9gEhtsLp6Fd3abE1R+fYRNr0sGN7AF3r1X70=; b=LY3wVlX13hRXN+xoPAGTINlJrkGL/+xeGSefzQsIpnoNcd0d+VkRWTs0CLJYl6MYnz xW20XYkOr9y7UL1k4ftiQXbhmr1N+UMCS1GYDK4TvH2TzPGf38vNv+/g4wKwTgQ2euTV wq0sv2yUOhmFMwCiAnKRT8WWnNwW1W78FbjDnCPS3FHZc6axu3cx5npL5WlU2QUF9ukL sjOTRtB5f2I16GdXotIxVAT0JeoP/UoWAJzLC6bHoZEPI3stBvBLC2VmQ2mKYh0/Bzux tooiY0tv6hNITwF6ZUbjsN4dcEODliMG/ClcfjociBVASm/B5ZOnRCR2I4MGBJztXqZM vUYg== 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=XAoHavd9gEhtsLp6Fd3abE1R+fYRNr0sGN7AF3r1X70=; b=kH2YNFzvvAYuFnHmVEj405ChWyYd/sD+8UonFZhs2sMXzMAwzcnoM3TDehietV+BZi Mh/GUw83Xegjpfg2MCOAuOe0O0xc4YjnDDNZLwKGcfdXZJDxZITLLpkF+DPayQpWjrW3 IbROu/PCRwEiVfO4n9mw1hg0ddsOReUhVHaqmCsutFPoYxEH03teYLbFQPLYb73H/HmC kRMypISSwXOsJjR+MIGEz2Tt+4+kXwPyKiycIWwqwMr9hYaDE+obEBqCXN8+/rgkrNzc RGCBT4AfiL0S1q8wGY242aXYQXj9pTOxPO1U8PYjqj85yTTV+6I2c8pHS6sVE51zx3QQ zFSg== X-Gm-Message-State: APjAAAX99SXw11rD1WNCXhm8rI18goCx3bcYbu/47O69DfKJL8KTQhHp 0R7XHDFiM0Ct23Lj+hRCXA== X-Google-Smtp-Source: APXvYqwvrG1SqKtz9smR64UZajEE/GNPg+Tp5nX5Q2hmZ3w7DDSpid6dH1Ew0morv8OgLi8WypQuSg== X-Received: by 2002:a1c:658a:: with SMTP id z132mr50765wmb.98.1567627825913; Wed, 04 Sep 2019 13:10:25 -0700 (PDT) Received: from localhost ([2a02:810a:8c80:d2c:e18b:2076:d6e6:a85d]) by smtp.gmail.com with ESMTPSA id u83sm5643695wme.0.2019.09.04.13.10.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 04 Sep 2019 13:10:25 -0700 (PDT) From: Bert Wesarg To: git@vger.kernel.org Cc: me@yadavpratyush.com, Birger Skogeng Pedersen , Bert Wesarg Subject: [PATCH 2/2] git-gui: add horizontal scrollbar to commit buffer Date: Wed, 4 Sep 2019 22:10:23 +0200 Message-Id: <62ef03a2938ac0d2158b1c3201c7f10e52e30ecb.1567627609.git.bert.wesarg@googlemail.com> X-Mailer: git-send-email 2.21.0.789.ga095d9d866 In-Reply-To: <7da71d89f9fa987eca2e25974e4cec382c146e44.1567627609.git.bert.wesarg@googlemail.com> References: <7da71d89f9fa987eca2e25974e4cec382c146e44.1567627609.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 While the commit message widget has a configurable fixed width, it nevertheless allows to write commit messages which exceed this limit. Though it does not show this content because there is not scrollbar for this widget. No it is. There seems to be a bug in at least up to Tcl/Tk 8.6.8, which does not update the horizontal scrollbar if one removes the whole content at once. Suggested-by: Birger Skogeng Pedersen Signed-off-by: Bert Wesarg --- git-gui.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/git-gui.sh b/git-gui.sh index a491085..fa9c0d2 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -3363,14 +3363,20 @@ ttext $ui_comm -background white -foreground black \ -relief sunken \ -width $repo_config(gui.commitmsgwidth) -height 9 -wrap none \ -font font_diff \ + -xscrollcommand {.vpane.lower.commarea.buffer.frame.sbx set} \ -yscrollcommand {.vpane.lower.commarea.buffer.frame.sby set} +${NS}::scrollbar .vpane.lower.commarea.buffer.frame.sbx \ + -orient horizontal \ + -command [list $ui_comm xview] ${NS}::scrollbar .vpane.lower.commarea.buffer.frame.sby \ + -orient vertical \ -command [list $ui_comm yview] +pack .vpane.lower.commarea.buffer.frame.sbx -side bottom -fill x pack .vpane.lower.commarea.buffer.frame.sby -side right -fill y -pack $ui_comm -side left -fill y +pack $ui_comm -side left -fill both -expand 1 pack .vpane.lower.commarea.buffer.header -side top -fill x -pack .vpane.lower.commarea.buffer.frame -side left -fill y +pack .vpane.lower.commarea.buffer.frame -side bottom -fill both -expand 1 pack .vpane.lower.commarea.buffer -side left -fill y # -- Commit Message Buffer Context Menu