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

git commit --verbose shows incorrect diff when pre-commit hook is used to modify files

From
FCFernando Chorney <djsbx@djsbx.com>
Date
Feb 11, 2019, 21:27 UTC
Message-ID
<CANFDZM5=ffu-=H=vrO3Kr0t2km-3Zg4=msYUWqqJQKGxGojnqA@mail.gmail.com>
In-Reply-To
<CANFDZM7fsbwwqhyWTzfivm4L=GgtCMfCi+DekZurs+SFGqaOjw@mail.gmail.com>
Hi,

I am trying to use a pre-commit hook to modify files before they are to be committed. The problem I am running into is that if I use "git commit --verbose", which I often do so that I can see the diff, the diff it displays in the editor is the diff before the pre-commit hook was run rather than what the diff would be after the pre-commit was run.

I would like to note, that the pre-commit hook is definitely running, but when git grabs the diff seems to be in the wrong place.

I have set up a simple example on my github to show the problem. https://github.com/fchorney/pre-commit-example

Is this intended behaviour, or perhaps an issue?
 Thanks,
 Fernando Chorney
Next: Sergey Lukashev
Message 1 of 4 in “git commit --verbose shows incorrect diff when pre-commit hook is used to modify files”
  1. Fernando ChorneyFeb 11, 2019
  2. Sergey LukashevFeb 11, 2019
  3. Fernando ChorneyFeb 26, 2019
  4. Junio C HamanoMar 3, 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.