Bug 256451 - Add a repo hook to prevent pushing commits with future timestamps
Summary: Add a repo hook to prevent pushing commits with future timestamps
Status: In Progress
Alias: None
Product: Services
Classification: Unclassified
Component: Core Infrastructure (show other bugs)
Version: unspecified
Hardware: Any Any
: --- Affects Some People
Assignee: Cluster Admin
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-06-06 18:42 UTC by tech-lists
Modified: 2021-06-07 14:47 UTC (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description tech-lists 2021-06-06 18:42:48 UTC
Hi,

context: arm64.aarch64 / main-n247177-dab84426a68

# uname -KU
1400018 1400018

root@rpi4:/usr/src# git remote -v
origin  ssh://anongit@git.freebsd.org/src.git (fetch)
origin  ssh://anongit@git.freebsd.org/src.git (push)

root@rpi4:/usr/src# git -C /usr/src --no-pager log -1 --format=%cd origin/HEAD && git -C /usr/src rev-list --first-parent --count HEAD

Mon Jun 7 06:22:25 2021 +0300
247212

root@rpi4:/usr/src# date

Sun Jun  6 19:35:13 BST 2021

root@rpi4:/usr/src#
Comment 1 Philip Paeps freebsd_committer 2021-06-07 01:04:09 UTC
Is this a problem?  It looks like dchagin's clock was fast by a couple of hours.  There is nothing wrong with the infrastructure or the repository.

Having said that, we might want a repository hook to prevent commits being pushed with timestamps in the future.

(And Dmitry should probably fix his system clock :))
Comment 2 tech-lists 2021-06-07 01:38:07 UTC
(In reply to Philip Paeps from comment #1)

I thought it looked broken when I saw it. Isn't it the server that timestamps the commits it gets?
Comment 3 Alexey Dokuchaev freebsd_committer 2021-06-07 02:25:13 UTC
(In reply to Philip Paeps from comment #1)
> Is this a problem?
The problem is that the server is trusting, that is, recording user's timestamp instead overriding it with its own.  This just paves the way for too much fuckups, the least of which is jeopardized timeline of the commits because of unsynchronised clocks of different committers (even by several seconds).
Comment 4 Philip Paeps freebsd_committer 2021-06-07 02:33:12 UTC
No.  Git is decentralised.  Commits are made locally and pushed to the server.  The hash that identifies the commit also covers the timestamp.
Comment 5 Philip Paeps freebsd_committer 2021-06-07 02:37:05 UTC
(In reply to Alexey Dokuchaev from comment #3)
> The problem is that the server is trusting, that is, recording user's timestamp instead overriding it with its own.

The server cannot change the timestamp without invalidating the commit hash.

If we consider timestamps in the future to be a problem, we could install a hook to reject pushes containing commits with timestamps in the future, relative to the time the server sees the commit.

People will have different opinions on whether this is a problem.  We'll need to find a middle ground.
Comment 6 Alexey Dokuchaev freebsd_committer 2021-06-07 02:53:14 UTC
(In reply to Philip Paeps from comment #5)
> The server cannot change the timestamp without invalidating the commit hash.
Oh, I see; we can forget about forcing server timestamps then. :(
Comment 7 Li-Wen Hsu freebsd_committer 2021-06-07 03:05:52 UTC
I think a hook to warn the user that they live in the future is a good idea.
Comment 8 Dmitry Chagin freebsd_committer 2021-06-07 06:50:02 UTC
(In reply to Li-Wen Hsu from comment #7)
+1 here, I run many Linux tests and some of test does not restore system clock( sorry
Comment 9 Dmitry Chagin freebsd_committer 2021-06-07 06:50:16 UTC
(In reply to Li-Wen Hsu from comment #7)
+1 here, I run many Linux tests and some of test does not restore system clock( sorry
Comment 10 Mathieu Arnold freebsd_committer 2021-06-07 06:59:16 UTC
I'll work on adding a warning to the hooks.
Comment 11 Li-Wen Hsu freebsd_committer 2021-06-07 14:46:54 UTC
mat's hook is in staging env.