git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/2] git-gui: warn if the commit message contains lines longer than the set limit

From
Bert Wesarg <bert.wesarg@googlemail.com>
Date
Sep 12, 2019, 19:26 UTC
Message-ID
<CAKPyHN0gX087_-tn=Q7gt7dJJaFg5idgz-E8zfTfRQxkCZb57A@mail.gmail.com>
In-Reply-To
<01e3c41d-af69-f9b3-31e6-12192e566f92@kdbg.org>
On Tue, Sep 10, 2019 at 6:50 PM Johannes Sixt <j6t@kdbg.org> wrote:
Show 44 quoted lines
>
> Am 04.09.19 um 22:10 schrieb Bert Wesarg:
> > 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 <bert.wesarg@googlemail.com>
> > ---
> >  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) \
>
> This has an off-by-one error: When I fill the edit box to the limit, but
> not beyond it, I get the warning popup. I guess this should be '>', not
> '>='.

Thanks. As Pratyush wont pull this one, I separated it and keep it in a branch in my fork:

https://github.com/bertwesarg/git-gui/tree/bw/warn-wide-commit-message
Bert
Show 16 quoted lines
>
> > +         && [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.
> >       #
> >
>
> -- Hannes
Previous: Johannes SixtNext: Pratyush Yadav
Message 19 of 21 in “git-gui: warn if the commit message contains lines longer than the set limit”
  1. 1/2 git-gui: warn if the commit message contains lines longer than the set limitBert Wesarg, Sep 4, 2019
  2. 2/2 git-gui: add horizontal scrollbar to commit bufferBert Wesarg, Sep 4, 2019
  3. Eric SunshineSep 4, 2019
  4. Bert WesargSep 4, 2019
  5. Pratyush YadavSep 10, 2019
  6. Bert WesargSep 12, 2019
  7. Eric SunshineSep 4, 2019
  8. Bert WesargSep 4, 2019
  9. Pratyush YadavSep 4, 2019
  10. Birger Skogeng PedersenSep 5, 2019
  11. Bert WesargSep 5, 2019
  12. Birger Skogeng PedersenSep 6, 2019
  13. Philip OakleySep 6, 2019
  14. David AguilarSep 10, 2019
  15. Pratyush YadavSep 10, 2019
  16. Johannes SixtSep 5, 2019
  17. Bert WesargSep 5, 2019
  18. Johannes SixtSep 10, 2019
  19. Bert WesargSep 12, 2019
  20. Pratyush YadavSep 10, 2019
  21. Bert WesargSep 12, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.