Setting GIT_AUTHOR_* causes incorrect commit dates

52 views
Skip to first unread message

Nathan Yergler

unread,
Apr 14, 2012, 5:40:48 PM4/14/12
to ma...@googlegroups.com
Good afternoon,

I've been having a problem intermittently over the past month or so
that I finally took the time to track down yesterday. The symptom is
that I'd commit something to the git repository at work using magit,
and when I looked at the commit log, the date was in the past. This
was first pointed out to me by a co-worker who asked if I'd managed to
invent a time machine: fixing a bug we discovered yesterday a week ago
is a pretty neat party trick. Once I confirmed that I truly was not
Dr. Sam Beckett [1], I decided to track down the problem.

Yesterday I noticed that a commit made through Magit had the incorrect
date, while a commit made from the command line (outside of Emacs) had
the correct date. When I started looking at magit.el, I found the
setting of GIT_AUTHOR_DATE in magit-log-edit-setup-author-env. My
hypothesis, which I was able to confirm, is that when you rewrite a
commit, GIT_AUTHOR_DATE is set. However, despite the fact
process-environment is set up as a local variable, the setting
persists -- running (get-env "GIT_AUTHOR_DATE") in *scratch* after
rewriting a commit returns the rewritten commit's date. Future commits
will all have the same date as the last rewritten commit.

I started to go down the path of clearing the GIT_AUTHOR_* variables
from the process-environment when no author is present, but that would
preclude setting them outside of Emacs. I wonder if instead magit
should specify --author and/or --date to the command line if the
author information is present.

Does that seem reasonable? Has anyone else run into this issue?

Thanks,

NRY

[1] http://en.wikipedia.org/wiki/Quantum_Leap

Tom Moertel

unread,
Aug 6, 2012, 4:30:48 PM8/6/12
to ma...@googlegroups.com
Yes, I'm having the same problem, same apparent cause.

Here's my workaround. Whenever the GIT_AUTHOR_DATE seems stuck, I clear it by hand:

  C-u M-x setenv GIT_AUTHOR_DATE

Cheers,
Tom

Nathan Yergler

unread,
Aug 20, 2012, 12:29:44 AM8/20/12
to Tom Moertel, ma...@googlegroups.com
Interestingly, I sat down to try and debug this and write a patch a
couple weeks ago and couldn't reproduce the error case. I'm not sure
if it was the version of magit or something else, but looking at my
notes I can't figure it out. I sort of assumed that the silence my
original email was met with meant the issue was limited to me, but if
you're seeing the problem maybe there's something else going on.

NRY
Reply all
Reply to author
Forward
0 new messages