From owner-freebsd-git@freebsd.org Wed May 29 17:58:46 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 21C8215A8DAB for ; Wed, 29 May 2019 17:58:46 +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 4FE8A775D4; Wed, 29 May 2019 17:58:45 +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 x4THwhxW077195 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO); Wed, 29 May 2019 17:58:43 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> From: Grzegorz Junka Message-ID: <82938a26-892e-0459-aa23-bdcd9e318b6c@gjunka.com> Date: Wed, 29 May 2019 17:58:43 +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: 4FE8A775D4 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.88 / 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.95)[-0.949,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: Wed, 29 May 2019 17:58:46 -0000 On 29/05/2019 17:08, Ed Maste wrote: > On Wed, 29 May 2019 at 11:40, Grzegorz Junka wrote: >> 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). > Our history is mostly devoid of merges though, but your broader point > is certainly valid - the relationship that's actually important is the > parent/child commits, not the order of either date stamp. > >> 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). > I'm not suggesting that we require the commit time to be close to the > server time, just that we could disallow two actually invalid cases: You mean undesirable cases? Since it's only metadata for git, these are not invalid per se. Also, in both cases below "commit time" means "local time" at the time the commit is being made. Updating timestamp in a commit rehashes that commit. > - commit time is earlier than parent(s) Yeah, sounds pretty easy to check. Should be enough to compare "git show -s --format=%ci HEAD" with local time. That could actually be enough to prompt a developer to update local time if HEAD is recent enough. > - 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). 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). > If you have local commits made while on the train and someone else > pushes to the canonical repository before you're back online you're > going to have to merge or rebase, and will then have an updated commit > time. > > The solution to this issue triggering is easy - just make sure the > client has the correct time. > >> 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. > Indeed, but that said developers like to think in terms like "commits > since a particular date", and we should provide a good experience > there if we can do so without restricting realistic workflows.