From owner-freebsd-git@freebsd.org Thu May 30 02:34:56 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 5989F15B4999 for ; Thu, 30 May 2019 02:34:56 +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 8075A6B7B7; Thu, 30 May 2019 02:34:55 +0000 (UTC) (envelope-from list1@gjunka.com) Received: from [10.70.7.24] ([10.70.7.24]) (authenticated bits=0) by msa1.earth.yoonka.com (8.15.2/8.15.2) with ESMTPSA id x4U2YrBZ084424 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO); Thu, 30 May 2019 02:34:53 GMT (envelope-from list1@gjunka.com) Subject: Re: Git handling of commit times To: Ed Maste Cc: freebsd-git@freebsd.org References: <8697933A-B813-4088-90B7-A84589C3CD33@freebsd.org> <6fb4c8cb-7f59-872e-4de6-a8a02e7c4e29@gjunka.com> <82938a26-892e-0459-aa23-bdcd9e318b6c@gjunka.com> From: Grzegorz Junka Message-ID: Date: Thu, 30 May 2019 03:34:48 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-GB X-Rspamd-Queue-Id: 8075A6B7B7 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.86 / 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)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:88.98.225.149]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[gjunka.com]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; IP_SCORE(-3.62)[ip: (-9.47), ipnet: 88.98.192.0/18(-4.74), asn: 56478(-3.79), country: GB(-0.09)]; MX_GOOD(-0.01)[cached: gjunka.com]; RCPT_COUNT_TWO(0.00)[2]; NEURAL_HAM_SHORT(-0.94)[-0.935,0]; 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: Thu, 30 May 2019 02:34:56 -0000 On 29/05/2019 19:27, Ed Maste wrote: > On Wed, 29 May 2019 at 13:58, Grzegorz Junka wrote: >> You mean undesirable cases? Since it's only metadata for git, these are >> not invalid per se. > Not invalid from the perspective of the Git DAG, but from the > perspective of causality and time. Yes, the git client will allow me > to create a commit dated next week (as it should). That said it'd be > just fine for the server to refuse to accept such a commit on the > basis that it's not actually valid. > >>> - commit time is later than the (accurate) server time >> That would require a trip over the internet from a hook. Still doable >> but not very user-friendly (as I mentioned earlier). > Yes, this would have to be done on the server side. But, I don't think > it's unfriendly for the server to deny a commit based on that commit > reportedly happening in the future. That's not what I was referring to. The time when the commit is made is not related to when it's pushed to the remote. I am saying that for this to work the hook on your laptop would need to check the time on the server when the commit is being made locally (e.g. on a train). The commit could be made, say, with tomorrow's date, but pushed to the remote next week. This would be invalid according to your definition (commit made with future date) but still wouldn't be caught (because it's pushed after that future date). Equally, the commit could be made with yesterday's date and if HEAD is a week ago this again wouldn't be caught. From what I understand you want to catch a situation when developer's VM was sleeping and then used to commit changes. In that case the local date will be behind the server's time, not ahead. In any case, if you want to ensure that the timestamp in the commit when it's made locally (on your laptop) makes sense in the context of the server's time, then there is no other way than to check server time when the commit is being made, not when it's beings pushed. Or am I misunderstanding the requirements? > >> However, hooks may >> be per branch, so checking time with the server could be done only for >> example when merging/committing to a particular branch (e.g. so that >> someone could commit without restrictions on their branch but when >> merging with upstream branch the local time would be enforced to be >> matched with the server time). > Yeah, in this discussion I'm assuming that any such checks are > performed only on the canonical repository, which likely holds only > "official" branches. Forks and derived repositories are free to apply > whatever commit hooks they see fit (or not). Same story as above, I was referring to commits being made locally (on your laptop). Checking anything on the server is too late. Imagine that by accident you committed locally changes with yesterday's date (VM was sleeping) and now server rejects your push. In order to fix this you need to either: 1. Adjust your local time, set environment variables to the time you want to change, then rebase affected commits on top of the last commit that the server wouldn't reject (how to find it is another story). If any of those rebased commits have already been pushed then you suddenly have conflicts that you need to resolve by pulling remote changes, merging and pushing again. 2. Revert X commits up to the commit that the server wouldn't reject. Changed files should be in git staging now. Then you need to update the time and commit the files again. If you made 10 commits with proper commit messages then all this history is lost. After reverting you have all the changes in all the commits in git staging and now you can only commit the files once. Situation becomes more complicated if there was a merge within those commits that you reverted because the staging will contain all changes from all reverted commits. If you had any merge conflicts you will no longer have the history how these conflicts have been resolved, which will impact any future debugging of problems possibly caused by those commits. Either situation is super user unfriendly. If you want to prevent incorrect timestamp then it must be done when the commit is being made locally, not on the server when the commit is being pushed from laptop to the remote repo. Of course you can do both but in my opinion just doing it on the server isn't enough.