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

Re: erratic behavior commit --allow-empty

From
ABAngelo Borsotti <angelo.borsotti@gmail.com>
Date
Oct 3, 2012, 07:35 UTC
Message-ID
<CAB9Jk9BczA0KjU2oKm=S_Ms6mqBFNHg8RO3xvb+PNEsMxQih+A@mail.gmail.com>
In-Reply-To
<506BE577.900@viscovery.net>
Hi Hannes,
>
> Perhaps you are confused by the fact that the commit you made first does
> not have a parent, either. But that is just a "side effect" that it
> happened to be the very first commit that you made after 'git init'.

Well, I know that, and this is why I added --allow-empty. The man page of git commit ("This option bypasses the safety, ..."). I thought that it would unconditionally create a brand new, commit.

> Your case does not demonstrate a bug in git.

The bug is that the git commit --allow-empty does a different action depending on whether the system clock has changed its seconds right before the command. This is a time-dependent behavior, and it is very harmful. Our applications must never behave differently depending on the time they are run or on the processor speed. It is an issue of correctness and robustness of software. To have a predictable behavior, i.e. to create a brand new commit with git commit --allow-empty, the command in a script must ALWAYS be preceded by a sleep 1 so as to make sure that the date and time it will use are for sure different from any other commits'. But then it would be a lot better to embed such a sleep in the command. If that is not possible, then the users must be warned in the man page that the command sometimes may not create a brand new commit, and that if the user instead wants it s/he should change something in the commit, like, e.g. the message.

>
> Why don't you use a different commit message to ensure that there is a
> difference between the commits?
>
This is what eventually I did to force the creation of a brand new commit.
-Angelo
Previous: Johannes SixtNext: Junio C Hamano
Message 50 of 53 in “erratic behavior commit --allow-empty”
  1. Angelo BorsottiOct 2, 2012
  2. Johannes SixtOct 2, 2012
  3. Angelo BorsottiOct 2, 2012
  4. Junio C HamanoOct 2, 2012
  5. Angelo BorsottiOct 2, 2012
  6. Junio C HamanoOct 2, 2012
  7. Angelo BorsottiOct 2, 2012
  8. PJ WeisbergOct 3, 2012
  9. Johannes SixtOct 3, 2012
  10. Angelo BorsottiOct 3, 2012
  11. Johannes SixtOct 3, 2012
  12. Philip OakleyOct 3, 2012
  13. Angelo BorsottiOct 3, 2012
  14. Matthieu MoyOct 3, 2012
  15. Angelo BorsottiOct 3, 2012
  16. Matthieu MoyOct 3, 2012
  17. Angelo BorsottiOct 3, 2012
  18. Matthieu MoyOct 3, 2012
  19. Angelo BorsottiOct 3, 2012
  20. Matthieu MoyOct 3, 2012
  21. Philip OakleyOct 3, 2012
  22. Angelo BorsottiOct 4, 2012
  23. Phil HordOct 4, 2012
  24. Angelo BorsottiOct 4, 2012
  25. Philip OakleyOct 4, 2012
  26. Angelo BorsottiOct 4, 2012
  27. Philip OakleyOct 4, 2012
  28. Angelo BorsottiOct 4, 2012
  29. Tomas CarneckyOct 3, 2012
  30. Angelo BorsottiOct 3, 2012
  31. Andreas SchwabOct 3, 2012
  32. Angelo BorsottiOct 3, 2012
  33. Andreas SchwabOct 3, 2012
  34. Angelo BorsottiOct 3, 2012
  35. Andreas SchwabOct 3, 2012
  36. Angelo BorsottiOct 3, 2012
  37. Andreas SchwabOct 3, 2012
  38. Angelo BorsottiOct 3, 2012
  39. Andreas SchwabOct 3, 2012
  40. Phil HordOct 3, 2012
  41. Angelo BorsottiOct 3, 2012
  42. PJ WeisbergOct 3, 2012
  43. Angelo BorsottiOct 3, 2012
  44. Andreas SchwabOct 3, 2012
  45. PJ WeisbergOct 3, 2012
  46. Lars NoschinskiOct 5, 2012
  47. Jan EngelhardtJan 12, 2013
  48. Joachim SchmitzJan 16, 2013
  49. Johannes SixtOct 3, 2012
  50. Angelo BorsottiOct 3, 2012
  51. Junio C HamanoOct 3, 2012
  52. Angelo BorsottiOct 3, 2012
  53. Phil HordOct 3, 2012

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.