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

Verbose commit message diff not showing changes from pre-commit hook

From
MLMaxime Louet <maxime@saumon.io>
Date
Jul 25, 2020, 14:47 UTC
Message-ID
<CADv3qkGq3jA8iXsjhrqfsUX=gW+KOuLyeVgDzmku1tUpsMdvtw@mail.gmail.com>
Hi,
I'm using git version 2.27.0 on Linux.

I have verbose commits enabled (`git commit --verbose`) and a repository configured to lint code before every commit with a pre-commit hook. This hook may change files and `git add` them just before the commit.

However, when that hook actually changes files (and `git add`s them right away) these changes are not reflected in the commit verbose diff (the commented lines below the commit message). The changes *are* taken into account by git, as `git diff --staged` shows — and later the commit info, after actually making the commit. However the displayed diff in the commit message file is a snapshot of the diff *before* the pre-commit hook.

Is this expected behaviour? I find it somehow confusing that the diff in the commit message isn't the actual commit diff.

Thank you for your help!
Kind regards,
-- 
Maxime Louet
Next: Junio C Hamano
Message 1 of 6 in “Verbose commit message diff not showing changes from pre-commit hook”
  1. Maxime LouetJul 25, 2020
  2. Junio C HamanoJul 25, 2020
  3. Junio C HamanoJul 25, 2020
  4. René ScharfeJul 26, 2020
  5. Maxime LouetJul 26, 2020
  6. Paolo BonziniJul 27, 2020

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.