From owner-freebsd-git@freebsd.org Wed May 29 15:40:21 2019 Return-Path: Delivered-To: freebsd-git@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BB9CB15A5303 for ; Wed, 29 May 2019 15:40:21 +0000 (UTC) (envelope-from list1@gjunka.com) Received: from msa1.earth.yoonka.com (yoonka.com [88.98.225.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "msa1.earth.yoonka.com", Issuer "msa1.earth.yoonka.com" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id BE9B671A25 for ; Wed, 29 May 2019 15:40:20 +0000 (UTC) (envelope-from list1@gjunka.com) Received: from crayon2.yoonka.com (crayon2.yoonka.com [10.70.7.20]) (authenticated bits=0) by msa1.earth.yoonka.com (8.15.2/8.15.2) with ESMTPSA id x4TFeIJp075138 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO) for ; Wed, 29 May 2019 15:40:18 GMT (envelope-from list1@gjunka.com) Subject: Re: Git handling of commit times To: freebsd-git@freebsd.org References: <8697933A-B813-4088-90B7-A84589C3CD33@freebsd.org> From: Grzegorz Junka Message-ID: <6fb4c8cb-7f59-872e-4de6-a8a02e7c4e29@gjunka.com> Date: Wed, 29 May 2019 15:40:18 +0000 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-GB-large X-Rspamd-Queue-Id: BE9B671A25 X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org; spf=pass (mx1.freebsd.org: domain of list1@gjunka.com designates 88.98.225.149 as permitted sender) smtp.mailfrom=list1@gjunka.com X-Spamd-Result: default: False [-6.78 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; FROM_HAS_DN(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:88.98.225.149]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-git@freebsd.org]; TO_DN_NONE(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; DMARC_NA(0.00)[gjunka.com]; MX_GOOD(-0.01)[cached: gjunka.com]; NEURAL_HAM_SHORT(-0.84)[-0.839,0]; IP_SCORE(-3.63)[ip: (-9.50), ipnet: 88.98.192.0/18(-4.75), asn: 56478(-3.80), country: GB(-0.09)]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:56478, ipnet:88.98.192.0/18, country:GB]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2] X-BeenThere: freebsd-git@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion of git use in the FreeBSD project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 May 2019 15:40:22 -0000 On 29/05/2019 14:41, Ed Maste wrote: > On Tue, 28 May 2019 at 23:20, Devin Teske wrote: >>> Did anyone ever find an elegant solution to preventing the following edge-case? >>> >>> 1. Committer uses a VM but keeps it paused most of the time >>> >>> 2. Committer unpauses VM and makes a commit without first running ntpdate to correct the clock of the paused VM >>> >>> 3. Committer pushes commit with a timestamp that predates the timestamp for the previous commit on the file in-question >>> >>> In this case, GitHub renders the commits our of order. If memory serves, "git log" will show them in the proper order, but github web interface shows them in wrong order. GitHub is the worst way of looking at commit history. Any other way is better than their clunky interface. The issue is that the history isn't linear no matter what you see in the interface. You either need to use Insights/Network or "git log --graph" to make sense of the order of commits. Timestamp alone doesn't give much information. What matters is when the branch in which the commit was added has been merged with other branches (shown as merge commits in the history). > It seems to me there are two separate issues here - committing with an > incorrect system time, and GitHub's rendering. We should try to avoid > the first case (e.g., by hooking into VM infrastructure to have the > date set correctly after resume) where we can. I haven't actually > checked GitHub's ordering. > > Git tracks the author and commit timestamps separately. They're often > the same (e.g. if I commit a change and push it to a repository) but > don't have to be - for example, if I cherry-pick change from someone > the author time will be when they originally wrote it, while the > commit time will be the time of my cherry-pick. > > There are other cases where the author time of a pair of changes will > be out of order with respect to the commit ordering of those changes > -- I may have a change to a file in my tree that I haven't pushed > anywhere yet. If you then make a change to that file and I rebase, my > change will come after in the commit graph but will have an earlier > author time. > >>> I think there was some talk of a hook to prevent timestamps moving backward with respect to each object being touched in a pushed commit -- is this even possible to prevent? > I believe a hook that prevents commit times from going backwards or > being ahead of the server time would serve this purpose, but I haven't > investigated in any detail. I'm also not sure off hand how GitHub, > git, and other tools use author vs commit dates. This is something > else that will need more investigation. Bear in mind that commits are local (by the virtue of git being distributed scm). You can certainly write a git hook that verifies local time to be approximately the same as server time and stop the commit if that's not the case. But that's clunky and patronizing in my opinion (e.g. someone won't be able to commit when on a train and off the grid). Also, when a developer wants to push local changes to the remote server, they have to pull remote first. That means a merge of remote branch with local branch. That merge, again, will be according to local time, which may be incorrect. When such a commit is pushed to the remote it may appear out of order in relation to other commits. Git commits are joined by hashes, timestamp is only some metadata. It makes sens to talk about amount of commits since a particular hash but not so much about amount of commits since a particular date. GrzegorzJ