On 4/1/2020 5:35 PM, Junio C Hamano wrote: > "Derrick Stolee via GitGitGadget" <gitgitgadget@xxxxxxxxx> writes: > >> From: Derrick Stolee <dstolee@xxxxxxxxxxxxx> >> >> The use of 'touch -m' to modify a file's mtime is slightly less >> portable than using our own 'test-tool chmtime'. > > Portability aside, the relative form would also be resistant against > skews between filesystem time and wallclock time and is preferrable > when we can use it. > >> The important >> thing is that these pack-files are ordered in a special way to >> ensure the multi-pack-index selects some as the "newer" pack-files >> when resolving duplicate objects. > > This note is very much appreciated. > >> rm -rf .git/objects/pack && >> mv .git/objects/pack-backup .git/objects/pack && >> - touch -m -t 201901010000 .git/objects/pack/pack-D* && >> - touch -m -t 201901010001 .git/objects/pack/pack-C* && >> - touch -m -t 201901010002 .git/objects/pack/pack-B* && >> - touch -m -t 201901010003 .git/objects/pack/pack-A* && >> + test-tool chmtime =-5 .git/objects/pack/pack-D* && >> + test-tool chmtime =-4 .git/objects/pack/pack-C* && >> + test-tool chmtime =-3 .git/objects/pack/pack-B* && >> + test-tool chmtime =-2 .git/objects/pack/pack-A* && > > The original wants D to be the oldest and A to be the newest, and > the updated would want the same ordering. > > When created, we know A gets created before B which gets created > before C and so on, in the "setup expire tests" part. If each step > takes too much time (e.g. the VM is heavily loaded), wouldn't the > adjustment above become insufficient? > > In other words, would we want to flip the order these packs get > created in the "setup" part, in addition to the use of chmtime > (which reads the existing file timestamp using stat(2) and then > updates the file timestamp relative to the original timestamp) > we see here? > > Also, in the best case (i.e. original timestamp of A/B/C/D are the > same), the above seems to assume that the filesystem has at least 1 > second file timestamp granularity. Do we want to make them at least > 2 seconds apart, or am I worried too much about ancient filesystems > that no longer metter? The old test relied on one-second granularity, so that hasn't changed. I could easily space it out a bit more without issue. Your concern about the original timestamps getting skewed shouldn't be an issue because "test-tool chmtime =-<seconds>" subtracts the <seconds> from the current system time, not the file's mtime. This is subtle: without the "=" it would modify it from the file's mtime. Since we are assigning the offset values in the proper order (D to A) there isn't an issue if time ticks forward between these steps. Thanks, -Stolee