git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "SZEDER Gábor" <szeder.dev@gmail.com>
To: Johannes Sixt <j6t@kdbg.org>
Cc: Thomas Gummerer <t.gummerer@gmail.com>,
	git@vger.kernel.org, rsbecker@nexbridge.com,
	johannes.schindelin@gmx.de, larsxschneider@gmail.com
Subject: Re: [PATCH] t0021: make sure clean filter runs
Date: Thu, 22 Aug 2019 00:03:55 +0200	[thread overview]
Message-ID: <20190821220355.GZ20404@szeder.dev> (raw)
In-Reply-To: <a8de9661-7f6a-f953-93a0-8ef88e9a490a@kdbg.org>

On Wed, Aug 21, 2019 at 08:23:23PM +0200, Johannes Sixt wrote:
> Am 21.08.19 um 16:56 schrieb Thomas Gummerer:
> > On 08/20, Johannes Sixt wrote:
> >> Am 20.08.19 um 08:56 schrieb Thomas Gummerer:
> >>> Fix the test by updating the mtime of test.r, ...
> >>
> >>> diff --git a/t/t0021-conversion.sh b/t/t0021-conversion.sh
> >>> index e10f5f787f..66f75005d5 100755
> >>> --- a/t/t0021-conversion.sh
> >>> +++ b/t/t0021-conversion.sh
> >>> @@ -390,6 +390,7 @@ test_expect_success PERL 'required process filter should filter data' '
> >>>  		EOF
> >>>  		test_cmp_exclude_clean expected.log debug.log &&
> >>>  
> >>> +		touch test.r &&
> >>
> >> 		test-tool chmtime +10 test.r
> >>
> >> would be more reliable.
> > 
> > Hmm, is touch unreliable on some platforms?  I didn't think of
> > 'test-tool chmtime', but I'm also not sure it's better than touch in
> > this case.
> > 
> > To me te 'touch' signifies that the timestamp must be updated after
> > the previous checkout, so git thinks it could possibly have been
> > changed, which I think is clearer in this case than setting the mtime
> > to a future time.
> 
> touch does not guarantee that the current time is different from the
> timestamp that the file already carries, particularly not when the
> filesystem stores just a resolution of 1 second, and commands are
> executed quickly.

This 'touch' must ensure that the timestamp of the file is not older
than the timestamp of the index, and to achive that it doesn't
necessarily have to modify the timestamp.

The file is modified first, then the index is updated, and finally
comes this 'touch'.  Consequently, if 'touch' doesn't modify the
timestamp of the file, then it must have the same timestamp as the
index, IOW it's racily clean, and the subsequent 'git checkout' has to
look at the file content and has to run the filter, and that's what we
want to see here.

However, I'm not sure what would happens if the system clock were to
jump back in between, but since it's only a test I don't think it's
worth caring about.

> But when we use test-tool chmtime +10, then the timestamp is definitely
> different.

'test-tool chmtime +10' adjusts the timestamp of the file relative to
its current timestamp.  So yeah, the file's timestamp definitely
changes, but that's not enough, because it doesn't ensure that the new
timestamp is not older than the timestamp of the index.  Just imagine
the arguably pathological situation that right after the file was last
modified the system miraculously comes to a complete stall, and only
manages to resume after 15 seconds to continue with updating the
index.  This means that the timestamp of the file will be 15s older
than the index, and after that 'chmtime +10' it will still be 5s
older.  Consequently, 'git checkout' will think that the file is
clean, it won't run the filter that we expect, and the test will fail.
So instead of '+10' it should be '=+10' to set the new timestamp
relative to the current time, but I'm not too keen about the timestamp
in the future either (though the file is about to be deleted anyway).

I think it would be best to explicitly set the timestamp of the file
and the index sort-of relative to each other and add an in-code
comment as well, e.g.:

  # Make sure that the file appears dirty, so checkout below has to
  # run the configured filter.
  test-tool chmtime =-10 .git/index &&
  test-tool chmtime =+0 test.r &&


  reply	other threads:[~2019-08-21 22:04 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-20  6:56 [PATCH] t0021: make sure clean filter runs Thomas Gummerer
2019-08-20 18:01 ` Junio C Hamano
2019-08-21 14:52   ` Thomas Gummerer
2019-08-21 15:40     ` Junio C Hamano
2019-08-20 19:11 ` Johannes Sixt
2019-08-21 14:56   ` Thomas Gummerer
2019-08-21 18:23     ` Johannes Sixt
2019-08-21 22:03       ` SZEDER Gábor [this message]
2019-08-22 17:49         ` Thomas Gummerer
2019-08-22 18:04           ` Junio C Hamano
2019-08-22 18:52           ` Johannes Sixt
2019-08-22 19:22 ` [PATCH v2] " Thomas Gummerer
2019-08-22 20:01   ` Junio C Hamano
2019-08-23  8:34   ` SZEDER Gábor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190821220355.GZ20404@szeder.dev \
    --to=szeder.dev@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=j6t@kdbg.org \
    --cc=johannes.schindelin@gmx.de \
    --cc=larsxschneider@gmail.com \
    --cc=rsbecker@nexbridge.com \
    --cc=t.gummerer@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).