public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
From: "brian m. carlson" <sandals@crustytoothpaste.net>
To: Devste Devste <devstemail@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: --reset-author does not reset author date when used in post-commit hook
Date: Tue, 1 Apr 2025 22:58:06 +0000	[thread overview]
Message-ID: <Z-xvfqCsQnDIGaXx@tapette.crustytoothpaste.net> (raw)
In-Reply-To: <CANM0SV0Np+52vjoopvAJ88U3Ue0EF35iarwBpOozrBH9KbH2Uw@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1702 bytes --]

On 2025-04-01 at 03:44:17, Devste Devste wrote:
> >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`.

> >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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 263 bytes --]

  reply	other threads:[~2025-04-01 22:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-31 20:19 --reset-author does not reset author date when used in post-commit hook Devste Devste
2025-04-01  0:43 ` brian m. carlson
2025-04-01  3:44   ` Devste Devste
2025-04-01 22:58     ` brian m. carlson [this message]
2025-04-02 10:06       ` Devste Devste

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Z-xvfqCsQnDIGaXx@tapette.crustytoothpaste.net \
    --to=sandals@crustytoothpaste.net \
    --cc=devstemail@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox