Re: [RFC PATCH 0/1] adding user.hideTimezone for setting UTC timezone

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Junio C Hamano <gitster@xxxxxxxxx> writes:

> What I said is that git () { TZ=UTC command git "$@" } is simple
> enough that I doubt it is worth the engineering effort to either
> read configuration file early (which is tricky) so that setenv() can
> be done early in cmd_main() and/or audit the codebase widely enough
> (which is time consuming) to make sure that we pay attention to the
> configuration variable in all codepaths that matter to do the
> setenv().

Regarding the implementation, the posted patch to "git commit" uses
the "futz with TZ early inside the git process" approach, but I
think we should not do so for another reason.  Our setenv() may not
be early enough---before the code that decides to call a setenv()
is run, there are many things that are outside your control (like
the tracing subsystem, repository discovery, etc.) will run, and if
any of them does something that triggers tzset() to be called, it
will be done with the value of TZ the process started with, and our
setenv() that happens much later won't have any effect to it.

Another thing is that setting TZ ourselves would affect hooks and
other programs we spawn as subprocess, which may or may not be
desired, depending on the reason why the user is forcing UTC.

All code that create object headers like committer, author and
tagger lines use the same git_author_info() and git_committer_info()
API, I think, which eventually goes to fmt_ident(), and they produce
a pair <number of seconds since epoch, offset>.  This gives us an
entirely different opening to tackle this issue from, because the
"number of seconds since epoch" part won't change the value no
matter what timezone you are in.

You can let the existing code produce its natural result and then
when the "force UTC" flag is set, override the offset part to +0000
if and only if the timezone was obtained from the current
environment (this if-and-only-if is necessary, because you do not
want to rewrite and force UTC when you run "git commit --amend"
without the "--reset-author" option to update a commit that was
created somewhere else to UTC).  That way, we do not have to futz
with TZ environment or tzset.

Just something to think about.



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux