Date: Wed, 29 May 2019 17:58:43 +0000 From: Grzegorz Junka <list1@gjunka.com> To: Ed Maste <emaste@freebsd.org> Cc: freebsd-git@freebsd.org Subject: Re: Git handling of commit times Message-ID: <82938a26-892e-0459-aa23-bdcd9e318b6c@gjunka.com> In-Reply-To: <CAPyFy2CkyET7v6hTfhv8ZQ=%2BSYM_yyhtBwzM3GfS3funaDBZHQ@mail.gmail.com> References: <8697933A-B813-4088-90B7-A84589C3CD33@freebsd.org> <CAPyFy2Bqg6m8D6rO%2Bg87Wk74iBYOGfq%2B=t6B_VhUM26mUZXO%2BQ@mail.gmail.com> <6fb4c8cb-7f59-872e-4de6-a8a02e7c4e29@gjunka.com> <CAPyFy2CkyET7v6hTfhv8ZQ=%2BSYM_yyhtBwzM3GfS3funaDBZHQ@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On 29/05/2019 17:08, Ed Maste wrote: > On Wed, 29 May 2019 at 11:40, Grzegorz Junka <list1@gjunka.com> 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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?82938a26-892e-0459-aa23-bdcd9e318b6c>