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

Re: --reset-author does not reset author date when used in post-commit hook

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Apr 1, 2025, 22:58 UTC
Message-ID
<Z-xvfqCsQnDIGaXx@tapette.crustytoothpaste.net>
In-Reply-To
<CANM0SV0Np+52vjoopvAJ88U3Ue0EF35iarwBpOozrBH9KbH2Uw@mail.gmail.com>
On 2025-04-01 at 03:44:17, Devste Devste wrote:
Show 5 quoted lines
> >your call to `git commit` will still invoke the
> `prepare-commit-msg` (and possibly `commit-msg`) hook
> 
> Since I used --no-edit --no-verify in the example/hook, that shouldn't
> be the case though?

My testing demonstrates that `commit-msg` is skipped with `--no-edit --no-verify`, but not `prepare-commit-msg`.

Show 8 quoted lines
> >such as by using an alias that sets `TZ=UTC0` to commit.
> 
> Unfortunately, (at least on Windows) most tools and IDEs don't even
> load a bashrc file (e.g. intellij) for their git UI, so that's not an
> option (and setting the TZ as a global environment variable has
> unwanted side effects, since it will set the timezone in various
> applications randomly, e.g. Electron/Slack will use the TZ for some
> but not for other things,...)

What I could recommend instead is setting a shell script or PowerShell file or such as the default Git binary (instead of git.exe) and setting `TZ=UTC0` in that script (possibly only if the command is `commit` or `commit-tree`). I use Neovim with the fugitive extension, and it provides functionality to override the Git executable, so I suspect other editors will as well. This is something that will likely be robust and unlikely to break.

The reason I make that recommendation is that I suspect you're going to find that there are other infelicities or weird edge cases in what you're doing and this would be a use case that I could see getting broken accidentally. We've accidentally broken people doing `git add` in `pre-commit` hooks (which we also don't recommend) in the past, for instance.

-- 
brian m. carlson (they/them)
Toronto, Ontario, CA
Previous: Devste DevsteNext: Devste Devste
Message 4 of 5 in “--reset-author does not reset author date when used in post-commit hook”
  1. Devste DevsteMar 31, 2025
  2. brian m. carlsonApr 1, 2025
  3. Devste DevsteApr 1, 2025
  4. brian m. carlsonApr 1, 2025
  5. Devste DevsteApr 2, 2025

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.