On Fri, Apr 08 2022, Erik Cervin Edin wrote: > At the risk of bikeshedding. > > The case in favor of not allowing empty commit messages by default is > that most of the time, empty commit messages are useless. > > I've written my fair share of poor commit messages (-,..., wip, foo). > Sometimes I've fixed that retroactively, sometimes not. The advantage > I see with empty commit messages is that it's more ubiquitous to > "write something better" or "whatever". The downside is I can't git > log --grep '^$' to find them. You can: git log --invert-grep --grep '.' > On Fri, Apr 8, 2022 at 7:47 PM Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> wrote: >> E.g. I wouldn't mind if we made pushes start failing (probably guarded >> by appropriate isatty() checks) if the user was pushing content without >> commit messages, unless some option were overridden, or we could start >> sternly warning about that. Ditto for merging a branch into another one >> (especially if we can see it's the default branch). > > I could see this being a potentially nice option but also pretty much > .git/hooks/pre-push.sample but with rev-list --grep '^$' (which > doesn't appear to work) The reason it doesn't work is that our --grep doesn't allow for matching across the whole message, we should fix that, it would be useful in other contexts. But for this the --invert-grep above will do what you want. I.e. if our --grep matches any one character and we discard any that matched with --invert-grep we're left with empty commit messages.