t6022, t6046: fix flaky files-are-updated checks

Several tests wanted to verify that files were actually modified by a
merge, which it would do by checking that the mtime was updated.  In
order to avoid problems with the merge completing so fast that the mtime
at the beginning and end of the operation was the same, these tests
would first set the mtime of a file to something "old".  This "old"
value was usually determined as current system clock minus one second,
truncated to the nearest integer.  Unfortunately, it appears the system
clock and filesystem clock are different and comparing across the two
runs into race problems resulting in flaky tests.

From https://stackoverflow.com/questions/14392975/timestamp-accuracy-on-ext4-sub-millsecond:

    date will call the gettimeofday system call which will always return
    the most accurate time available based on the cached kernel time,
    adjusted by the CPU cycle time if available to give nanosecond
    resolution. The timestamps stored in the file system however, are
    only based on the cached kernel time. ie The time calculated at the
    last timer interrupt.

and from https://apenwarr.ca/log/20181113:

    Does mtime get set to >= the current time?

    No, this depends on clock granularity. For example, gettimeofday()
    can return times in microseconds on my system, but ext4 rounds
    timestamps down to the previous ~10ms (but not exactly 10ms)
    increment, with the surprising result that a newly-created file is
    almost always created in the past:

      $ python -c "
      import os, time
      t0 = time.time()
      open('testfile', 'w').close()
      print os.stat('testfile').st_mtime - t0
      "

      -0.00234484672546

So, instead of trying to compare across what are effectively two
different clocks, just avoid using the system clock.  Any new updates to
files have to give an mtime at least as big as what is already in the
file, so we could define "old" as one second before the mtime found in
the file before the merge starts.  But, to avoid problems with leap
seconds, ntp updates, filesystems that only provide two second
resolution, and other such weirdness, let's just pick an hour before the
mtime found in the file before the merge starts.

Also, clarify in one test where we check the mtime of different files
that it really was intentional.  I totally forgot the reasons for that
and assumed it was a bug when asked.

Reported-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 files changed
tree: eb08c50b10cb7a274ca3ceb2cb0b48c1ef3a56e5
  1. .cirrus.yml
  2. .clang-format
  3. .editorconfig
  4. .gitattributes
  5. .github/
  6. .gitignore
  7. .gitmodules
  8. .mailmap
  9. .travis.yml
  10. .tsan-suppressions
  11. CODE_OF_CONDUCT.md
  12. COPYING
  13. Documentation/
  14. GIT-VERSION-GEN
  15. INSTALL
  16. LGPL-2.1
  17. Makefile
  18. README.md
  19. abspath.c
  20. aclocal.m4
  21. add-interactive.c
  22. add-interactive.h
  23. add-patch.c
  24. advice.c
  25. advice.h
  26. alias.c
  27. alias.h
  28. alloc.c
  29. alloc.h
  30. apply.c
  31. apply.h
  32. archive-tar.c
  33. archive-zip.c
  34. archive.c
  35. archive.h
  36. argv-array.c
  37. argv-array.h
  38. attr.c
  39. attr.h
  40. azure-pipelines.yml
  41. banned.h
  42. base85.c
  43. bisect.c
  44. bisect.h
  45. blame.c
  46. blame.h
  47. blob.c
  48. blob.h
  49. block-sha1/
  50. branch.c
  51. branch.h
  52. builtin.h
  53. builtin/
  54. bulk-checkin.c
  55. bulk-checkin.h
  56. bundle.c
  57. bundle.h
  58. cache-tree.c
  59. cache-tree.h
  60. cache.h
  61. chdir-notify.c
  62. chdir-notify.h
  63. check-builtins.sh
  64. check_bindir
  65. checkout.c
  66. checkout.h
  67. ci/
  68. color.c
  69. color.h
  70. column.c
  71. column.h
  72. combine-diff.c
  73. command-list.txt
  74. commit-graph.c
  75. commit-graph.h
  76. commit-reach.c
  77. commit-reach.h
  78. commit-slab-decl.h
  79. commit-slab-impl.h
  80. commit-slab.h
  81. commit.c
  82. commit.h
  83. common-main.c
  84. compat/
  85. config.c
  86. config.h
  87. config.mak.dev
  88. config.mak.in
  89. config.mak.uname
  90. configure.ac
  91. connect.c
  92. connect.h
  93. connected.c
  94. connected.h
  95. contrib/
  96. convert.c
  97. convert.h
  98. copy.c
  99. credential-cache--daemon.c
  100. credential-cache.c
  101. credential-store.c
  102. credential.c
  103. credential.h
  104. csum-file.c
  105. csum-file.h
  106. ctype.c
  107. daemon.c
  108. date.c
  109. decorate.c
  110. decorate.h
  111. delta-islands.c
  112. delta-islands.h
  113. delta.h
  114. detect-compiler
  115. diff-delta.c
  116. diff-lib.c
  117. diff-no-index.c
  118. diff.c
  119. diff.h
  120. diffcore-break.c
  121. diffcore-delta.c
  122. diffcore-order.c
  123. diffcore-pickaxe.c
  124. diffcore-rename.c
  125. diffcore.h
  126. dir-iterator.c
  127. dir-iterator.h
  128. dir.c
  129. dir.h
  130. editor.c
  131. entry.c
  132. environment.c
  133. ewah/
  134. exec-cmd.c
  135. exec-cmd.h
  136. fast-import.c
  137. fetch-negotiator.c
  138. fetch-negotiator.h
  139. fetch-pack.c
  140. fetch-pack.h
  141. fmt-merge-msg.h
  142. fsck.c
  143. fsck.h
  144. fsmonitor.c
  145. fsmonitor.h
  146. fuzz-commit-graph.c
  147. fuzz-pack-headers.c
  148. fuzz-pack-idx.c
  149. generate-cmdlist.sh
  150. gettext.c
  151. gettext.h
  152. git-add--interactive.perl
  153. git-archimport.perl
  154. git-bisect.sh
  155. git-compat-util.h
  156. git-cvsexportcommit.perl
  157. git-cvsimport.perl
  158. git-cvsserver.perl
  159. git-difftool--helper.sh
  160. git-filter-branch.sh
  161. git-gui/
  162. git-instaweb.sh
  163. git-legacy-stash.sh
  164. git-merge-octopus.sh
  165. git-merge-one-file.sh
  166. git-merge-resolve.sh
  167. git-mergetool--lib.sh
  168. git-mergetool.sh
  169. git-p4.py
  170. git-parse-remote.sh
  171. git-quiltimport.sh
  172. git-rebase--preserve-merges.sh
  173. git-request-pull.sh
  174. git-send-email.perl
  175. git-sh-i18n.sh
  176. git-sh-setup.sh
  177. git-submodule.sh
  178. git-svn.perl
  179. git-web--browse.sh
  180. git.c
  181. git.rc
  182. gitk-git/
  183. gitweb/
  184. gpg-interface.c
  185. gpg-interface.h
  186. graph.c
  187. graph.h
  188. grep.c
  189. grep.h
  190. hash.h
  191. hashmap.c
  192. hashmap.h
  193. help.c
  194. help.h
  195. hex.c
  196. http-backend.c
  197. http-fetch.c
  198. http-push.c
  199. http-walker.c
  200. http.c
  201. http.h
  202. ident.c
  203. imap-send.c
  204. interdiff.c
  205. interdiff.h
  206. iterator.h
  207. json-writer.c
  208. json-writer.h
  209. khash.h
  210. kwset.c
  211. kwset.h
  212. levenshtein.c
  213. levenshtein.h
  214. line-log.c
  215. line-log.h
  216. line-range.c
  217. line-range.h
  218. linear-assignment.c
  219. linear-assignment.h
  220. list-objects-filter-options.c
  221. list-objects-filter-options.h
  222. list-objects-filter.c
  223. list-objects-filter.h
  224. list-objects.c
  225. list-objects.h
  226. list.h
  227. ll-merge.c
  228. ll-merge.h
  229. lockfile.c
  230. lockfile.h
  231. log-tree.c
  232. log-tree.h
  233. ls-refs.c
  234. ls-refs.h
  235. mailinfo.c
  236. mailinfo.h
  237. mailmap.c
  238. mailmap.h
  239. match-trees.c
  240. mem-pool.c
  241. mem-pool.h
  242. merge-blobs.c
  243. merge-blobs.h
  244. merge-recursive.c
  245. merge-recursive.h
  246. merge.c
  247. mergesort.c
  248. mergesort.h
  249. mergetools/
  250. midx.c
  251. midx.h
  252. name-hash.c
  253. negotiator/
  254. notes-cache.c
  255. notes-cache.h
  256. notes-merge.c
  257. notes-merge.h
  258. notes-utils.c
  259. notes-utils.h
  260. notes.c
  261. notes.h
  262. object-store.h
  263. object.c
  264. object.h
  265. oidmap.c
  266. oidmap.h
  267. oidset.c
  268. oidset.h
  269. pack-bitmap-write.c
  270. pack-bitmap.c
  271. pack-bitmap.h
  272. pack-check.c
  273. pack-objects.c
  274. pack-objects.h
  275. pack-revindex.c
  276. pack-revindex.h
  277. pack-write.c
  278. pack.h
  279. packfile.c
  280. packfile.h
  281. pager.c
  282. parse-options-cb.c
  283. parse-options.c
  284. parse-options.h
  285. patch-delta.c
  286. patch-ids.c
  287. patch-ids.h
  288. path.c
  289. path.h
  290. pathspec.c
  291. pathspec.h
  292. perl/
  293. pkt-line.c
  294. pkt-line.h
  295. po/
  296. ppc/
  297. preload-index.c
  298. pretty.c
  299. pretty.h
  300. prio-queue.c
  301. prio-queue.h
  302. progress.c
  303. progress.h
  304. promisor-remote.c
  305. promisor-remote.h
  306. prompt.c
  307. prompt.h
  308. protocol.c
  309. protocol.h
  310. quote.c
  311. quote.h
  312. range-diff.c
  313. range-diff.h
  314. reachable.c
  315. reachable.h
  316. read-cache.c
  317. rebase-interactive.c
  318. rebase-interactive.h
  319. ref-filter.c
  320. ref-filter.h
  321. reflog-walk.c
  322. reflog-walk.h
  323. refs.c
  324. refs.h
  325. refs/
  326. refspec.c
  327. refspec.h
  328. remote-curl.c
  329. remote-testsvn.c
  330. remote.c
  331. remote.h
  332. replace-object.c
  333. replace-object.h
  334. repo-settings.c
  335. repository.c
  336. repository.h
  337. rerere.c
  338. rerere.h
  339. resolve-undo.c
  340. resolve-undo.h
  341. revision.c
  342. revision.h
  343. run-command.c
  344. run-command.h
  345. send-pack.c
  346. send-pack.h
  347. sequencer.c
  348. sequencer.h
  349. serve.c
  350. serve.h
  351. server-info.c
  352. setup.c
  353. sh-i18n--envsubst.c
  354. sha1-array.c
  355. sha1-array.h
  356. sha1-file.c
  357. sha1-lookup.c
  358. sha1-lookup.h
  359. sha1-name.c
  360. sha1dc/
  361. sha1dc_git.c
  362. sha1dc_git.h
  363. sha256/
  364. shallow.c
  365. shell.c
  366. shortlog.h
  367. sideband.c
  368. sideband.h
  369. sigchain.c
  370. sigchain.h
  371. split-index.c
  372. split-index.h
  373. stable-qsort.c
  374. strbuf.c
  375. strbuf.h
  376. streaming.c
  377. streaming.h
  378. string-list.c
  379. string-list.h
  380. sub-process.c
  381. sub-process.h
  382. submodule-config.c
  383. submodule-config.h
  384. submodule.c
  385. submodule.h
  386. symlinks.c
  387. t/
  388. tag.c
  389. tag.h
  390. tar.h
  391. tempfile.c
  392. tempfile.h
  393. templates/
  394. thread-utils.c
  395. thread-utils.h
  396. tmp-objdir.c
  397. tmp-objdir.h
  398. trace.c
  399. trace.h
  400. trace2.c
  401. trace2.h
  402. trace2/
  403. trailer.c
  404. trailer.h
  405. transport-helper.c
  406. transport-internal.h
  407. transport.c
  408. transport.h
  409. tree-diff.c
  410. tree-walk.c
  411. tree-walk.h
  412. tree.c
  413. tree.h
  414. unicode-width.h
  415. unimplemented.sh
  416. unix-socket.c
  417. unix-socket.h
  418. unpack-trees.c
  419. unpack-trees.h
  420. upload-pack.c
  421. upload-pack.h
  422. url.c
  423. url.h
  424. urlmatch.c
  425. urlmatch.h
  426. usage.c
  427. userdiff.c
  428. userdiff.h
  429. utf8.c
  430. utf8.h
  431. varint.c
  432. varint.h
  433. vcs-svn/
  434. version.c
  435. version.h
  436. versioncmp.c
  437. walker.c
  438. walker.h
  439. wildmatch.c
  440. wildmatch.h
  441. worktree.c
  442. worktree.h
  443. wrap-for-bin.sh
  444. wrapper.c
  445. write-or-die.c
  446. ws.c
  447. wt-status.c
  448. wt-status.h
  449. xdiff-interface.c
  450. xdiff-interface.h
  451. xdiff/
  452. zlib.c
README.md

Build Status

Git - fast, scalable, distributed revision control system

Git is a fast, scalable, distributed revision control system with an unusually rich command set that provides both high-level operations and full access to internals.

Git is an Open Source project covered by the GNU General Public License version 2 (some parts of it are under different licenses, compatible with the GPLv2). It was originally written by Linus Torvalds with help of a group of hackers around the net.

Please read the file INSTALL for installation instructions.

Many Git online resources are accessible from https://git-scm.com/ including full documentation and Git related tools.

See Documentation/gittutorial.txt to get started, then see Documentation/giteveryday.txt for a useful minimum set of commands, and Documentation/git-<commandname>.txt for documentation of each command. If git has been correctly installed, then the tutorial can also be read with man gittutorial or git help tutorial, and the documentation of each command with man git-<commandname> or git help <commandname>.

CVS users may also want to read Documentation/gitcvs-migration.txt (man gitcvs-migration or git help cvs-migration if git is installed).

The user discussion and development of Git take place on the Git mailing list -- everyone is welcome to post bug reports, feature requests, comments and patches to git@vger.kernel.org (read Documentation/SubmittingPatches for instructions on patch submission). To subscribe to the list, send an email with just “subscribe git” in the body to majordomo@vger.kernel.org. The mailing list archives are available at https://lore.kernel.org/git/, http://marc.info/?l=git and other archival sites.

Issues which are security relevant should be disclosed privately to the Git Security mailing list git-security@googlegroups.com.

The maintainer frequently sends the “What's cooking” reports that list the current status of various development topics to the mailing list. The discussion following them give a good reference for project status, development direction and remaining tasks.

The name “git” was given by Linus Torvalds when he wrote the very first version. He described the tool as “the stupid content tracker” and the name as (depending on your mood):

  • random three-letter combination that is pronounceable, and not actually used by any common UNIX command. The fact that it is a mispronunciation of “get” may or may not be relevant.
  • stupid. contemptible and despicable. simple. Take your pick from the dictionary of slang.
  • “global information tracker”: you're in a good mood, and it actually works for you. Angels sing, and a light suddenly fills the room.
  • “goddamn idiotic truckload of sh*t”: when it breaks