git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: t0027 racy?

From
Jeff King <peff@peff.net>
Date
Aug 9, 2016, 13:27 UTC
Message-ID
<20160809132744.kjzmkgt2qiugeolj@sigill.intra.peff.net>
In-Reply-To
<20160809125958.GA1501@tb-raspi>
On Tue, Aug 09, 2016 at 12:59:58PM +0000, Torsten Bögershausen wrote:
Show 19 quoted lines
> Thanks for the explanation, so there are 2 chances for a race.
> 
> I assume that the suggested "touch" will fix race#2 in most cases.
> In my understanding, the change of the file size will be more reliable:
>  
> 
> diff --git a/t/t0027-auto-crlf.sh b/t/t0027-auto-crlf.sh
> index 2860d2d..9933a9b 100755
> --- a/t/t0027-auto-crlf.sh
> +++ b/t/t0027-auto-crlf.sh
> @@ -120,6 +120,7 @@ commit_chk_wrnNNO () {
>                 cp $f $fname &&
>                 printf Z >>"$fname" &&
>                 git -c core.autocrlf=$crlf add $fname 2>/dev/null &&
> +               printf Z >>"$fname" &&
>                 git -c core.autocrlf=$crlf commit -m "commit_$fname" $fname >"${pfx}_$f.err" 2>&1
>         done
> -------------------
> Does anybody agree ?

I think the mtime change is reliable. We know that the mtime on the file will be greater than or equal to the index mtime (because it happened afterwards), so git will always look at the on-disk contents.

With your change, "git commit" will also always re-read the file from disk, because it actually has new content (and you provide the filename on the command line, so it is stage-and-commit, not just "commit-the-index").

So either is fine.
> And, by the way, the convert warning may be issued twice, once in
> "git add" and once in "git commit".

Yes, but you only save it from "git commit", so we can ignore what happens from "add" here. But that's why I wondered if:

  git -c core.autocrlf=$crlf add $fname >"${pfx}_$f.err" 2>&1

would make more sense. We _know_ that we have to do convert_to_git() in that step because the content is changed. And then you can ignore the warnings from "git commit" (which are racy), or you can simply commit as a whole later, as some other loops do.

But like Dscho, I do not actually understand what this test is checking. The function is called commit_chk_wrnNNO(), so perhaps you really are interested in what "commit" has to say. But IMHO that is not an interesting test. We know that if it has to read the content from disk, it will call convert_to_git(), which is the exact same code path used by "git add". So I do not understand what it is accomplishing to make a commit at all here.

-Peff
Previous: Torsten BögershausenNext: Torsten Bögershausen
Message 10 of 45 in “t0027 racy?”
  1. Johannes SchindelinAug 8, 2016
  2. Jeff KingAug 8, 2016
  3. Torsten BögershausenAug 8, 2016
  4. Jeff KingAug 9, 2016
  5. Jeff KingAug 9, 2016
  6. Johannes SchindelinAug 9, 2016
  7. Torsten BögershausenAug 9, 2016
  8. Jeff KingAug 9, 2016
  9. Torsten BögershausenAug 9, 2016
  10. Jeff KingAug 9, 2016
  11. Torsten BögershausenAug 9, 2016
  12. Johannes SchindelinAug 10, 2016
  13. Torsten BögershausenAug 11, 2016
  14. Junio C HamanoAug 11, 2016
  15. Jeff KingAug 12, 2016
  16. 0/2 Fix conversion warningstboegi@web.de, Aug 12, 2016
  17. 2/2 convert: missing `LF will be replaced by CRLFtboegi@web.de, Aug 12, 2016
  18. Junio C HamanoAug 12, 2016
  19. 1/2 t0027: Correct raciness in NNO testtboegi@web.de, Aug 12, 2016
  20. Junio C HamanoAug 12, 2016
  21. Johannes SixtAug 13, 2016
  22. Torsten BögershausenAug 13, 2016
  23. Junio C HamanoAug 14, 2016
  24. 1/1 convert: Correct NNO tests and missing `LF will be replaced by CRLF`tboegi@web.de, Aug 13, 2016
  25. 0/1 convert: Correct NNO tests and missing `LF will be replaced by CRLF`tboegi@web.de, Aug 13, 2016
  26. Johannes SchindelinAug 17, 2016
  27. 0/1 Rename NotNormalized (NNO) into CRLF in indextboegi@web.de, Aug 19, 2016
  28. Junio C HamanoAug 19, 2016
  29. 1/1 t0027: Rename NotNormalized (NNO) into CRLF in indextboegi@web.de, Aug 19, 2016
  30. 1/2 git ls-files: text=auto eol=lf is supported in Git 2.10tboegi@web.de, Aug 25, 2016
  31. Junio C HamanoAug 25, 2016
  32. 0/3 Update eol documentationtboegi@web.de, Aug 25, 2016
  33. Junio C HamanoAug 25, 2016
  34. Jacob KellerAug 26, 2016
  35. Torsten BögershausenAug 26, 2016
  36. 2/2 gitattributes: Document the unified "auto" handlingtboegi@web.de, Aug 25, 2016
  37. Junio C HamanoAug 25, 2016
  38. 0/2 Adjust the documentation to the unified "auto" handlingtboegi@web.de, Aug 26, 2016
  39. 1/2 git ls-files: text=auto eol=lf is supported in Git 2.10tboegi@web.de, Aug 26, 2016
  40. 2/2 gitattributes: Document the unified "auto" handlingtboegi@web.de, Aug 26, 2016
  41. Junio C HamanoAug 26, 2016
  42. Johannes SchindelinAug 9, 2016
  43. Jeff KingAug 9, 2016
  44. Torsten BögershausenAug 8, 2016
  45. Johannes SchindelinAug 9, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.