Home > Blockchain >  Git commit doesn't accept summary
Git commit doesn't accept summary

Time:01-03

So I've recently cloned the gnu-coreutils to see how the programs I use actually work, and to get more familiar with git, especially git's CLI. But when I tried committing a change I made to basename.c by using git commit src/basename.c with the description basename: some-desc, it returned the error

commit-msg: invalid first word(s) of summary line: basename
Interrupt (Ctrl-C) to abort...
Too many errors from stdin
commit-msg: .git/COMMIT_EDITMSG: the editor (editor) failed, aborting

This description follows the guidelines from the "HACKING" file included in the repository:

Try to make the summary line fit one of the following forms:

program_name: change-description
prog1, prog2: change-description
doc: change-description
tests: change-description
build: change-description
maint: change-description

but still git doesn't accept basename as the program name. The names of other programs like cat, base64 and chcon work however, so maybe this is just a bug?

I also tried googling the issue, but except for general guidelines on how to format git commit messages I couldn't find anything.

CodePudding user response:

The coreutils repository sets up Git hooks in your local clone of the repository. You can find the commit message check in scripts/git-hooks/commit-msg.

It is run every time you try to commit. It defines the allowed keywords starting in line 14:

# Keywords allowed before the colon on the first line of a commit message:
# program names and a few general category names.
my @valid = qw(
    arch b2sum base32 base64 basenc nbasename cat chcon chgrp chmod chown
    chroot cksum comm cp csplit cut date dd df dir dircolors dirname du echo
    env expand expr factor false fmt fold groups head hostid hostname id
    install join kill link ln logname ls md5sum mkdir mkfifo mknod mktemp
    mv nice nl nohup nproc numfmt od paste pathchk pinky pr printenv printf
    ptx pwd readlink realpath rm rmdir runcon seq sha1sum sha224sum sha256sum
    sha384sum sha512sum shred shuf sleep sort split stat stdbuf stty
    sum sync tac tail tee test timeout touch tr true truncate tsort
    tty uname unexpand uniq unlink uptime users vdir wc who whoami yes

    all copy gnulib tests maint doc build scripts sha\*sum digest
    );

basename is not among them, but nbasename is.

To temporarily disable running commit hooks, specify --no-verify during commit.

  • Related