When trying to determine whether a file changed, we try to avoid heavy operations by fist taking a look at the index, seeing whether the index entry is modified already. This doesn't seem to cut it, though, as we currently have the racy checkout::index::can_disable_pathspec_match test case: sometimes the files get restored to their original contents, sometimes they aren't. The issue is caused by a racy index [1]: in case we modify a file, add it to the index and then modify it again in-place without changing its file, then we may end up with a modified file that has the same stat(3P) info as we've currently got it in its corresponding index entry. The mitigation for this is to treat files with the same mtime as the index are treated as racily modified. We already have this logic in place for the index, but not when doing a checkout. Fix the issue by only consulting the index entry in case it has an older mtime as the index. Previously, the following script reliably had at least 20 failures, while now there is no failure to be observed anymore: ```bash j=0 for i in $(seq 100) do if ! ./libgit2_clar -scheckout::index::can_disable_pathspec_match >/dev/null then j=$(($j + 1)) fi done echo "Failures: $j" ``` [1]: https://git-scm.com/docs/racy-git
Name |
Last commit
|
Last update |
---|---|---|
.. | ||
allocators | Loading commit data... | |
hash | Loading commit data... | |
streams | Loading commit data... | |
transports | Loading commit data... | |
unix | Loading commit data... | |
win32 | Loading commit data... | |
xdiff | Loading commit data... | |
CMakeLists.txt | Loading commit data... | |
alloc.c | Loading commit data... | |
alloc.h | Loading commit data... | |
annotated_commit.c | Loading commit data... | |
annotated_commit.h | Loading commit data... | |
apply.c | Loading commit data... | |
apply.h | Loading commit data... | |
array.h | Loading commit data... | |
assert_safe.h | Loading commit data... | |
attr.c | Loading commit data... | |
attr.h | Loading commit data... | |
attr_file.c | Loading commit data... | |
attr_file.h | Loading commit data... | |
attrcache.c | Loading commit data... | |
attrcache.h | Loading commit data... | |
bitvec.h | Loading commit data... | |
blame.c | Loading commit data... | |
blame.h | Loading commit data... | |
blame_git.c | Loading commit data... | |
blame_git.h | Loading commit data... | |
blob.c | Loading commit data... | |
blob.h | Loading commit data... | |
branch.c | Loading commit data... | |
branch.h | Loading commit data... | |
buf_text.c | Loading commit data... | |
buf_text.h | Loading commit data... | |
buffer.c | Loading commit data... | |
buffer.h | Loading commit data... | |
cache.c | Loading commit data... | |
cache.h | Loading commit data... | |
cc-compat.h | Loading commit data... | |
checkout.c | Loading commit data... | |
checkout.h | Loading commit data... | |
cherrypick.c | Loading commit data... | |
clone.c | Loading commit data... | |
clone.h | Loading commit data... | |
commit.c | Loading commit data... | |
commit.h | Loading commit data... | |
commit_list.c | Loading commit data... | |
commit_list.h | Loading commit data... | |
common.h | Loading commit data... | |
config.c | Loading commit data... | |
config.h | Loading commit data... | |
config_backend.h | Loading commit data... | |
config_cache.c | Loading commit data... | |
config_entries.c | Loading commit data... | |
config_entries.h | Loading commit data... | |
config_file.c | Loading commit data... | |
config_mem.c | Loading commit data... | |
config_parse.c | Loading commit data... | |
config_parse.h | Loading commit data... | |
config_snapshot.c | Loading commit data... | |
crlf.c | Loading commit data... | |
date.c | Loading commit data... | |
delta.c | Loading commit data... | |
delta.h | Loading commit data... | |
describe.c | Loading commit data... | |
diff.c | Loading commit data... | |
diff.h | Loading commit data... | |
diff_driver.c | Loading commit data... | |
diff_driver.h | Loading commit data... | |
diff_file.c | Loading commit data... | |
diff_file.h | Loading commit data... | |
diff_generate.c | Loading commit data... | |
diff_generate.h | Loading commit data... | |
diff_parse.c | Loading commit data... | |
diff_parse.h | Loading commit data... | |
diff_print.c | Loading commit data... | |
diff_stats.c | Loading commit data... | |
diff_tform.c | Loading commit data... | |
diff_tform.h | Loading commit data... | |
diff_xdiff.c | Loading commit data... | |
diff_xdiff.h | Loading commit data... | |
errors.c | Loading commit data... | |
errors.h | Loading commit data... | |
features.h.in | Loading commit data... | |
fetch.c | Loading commit data... | |
fetch.h | Loading commit data... | |
fetchhead.c | Loading commit data... | |
fetchhead.h | Loading commit data... | |
filebuf.c | Loading commit data... | |
filebuf.h | Loading commit data... | |
filter.c | Loading commit data... | |
filter.h | Loading commit data... | |
futils.c | Loading commit data... | |
futils.h | Loading commit data... | |
global.c | Loading commit data... | |
global.h | Loading commit data... | |
graph.c | Loading commit data... | |
hash.c | Loading commit data... | |
hash.h | Loading commit data... | |
hashsig.c | Loading commit data... | |
ident.c | Loading commit data... | |
idxmap.c | Loading commit data... | |
idxmap.h | Loading commit data... | |
ignore.c | Loading commit data... | |
ignore.h | Loading commit data... | |
index.c | Loading commit data... | |
index.h | Loading commit data... | |
indexer.c | Loading commit data... | |
indexer.h | Loading commit data... | |
integer.h | Loading commit data... | |
iterator.c | Loading commit data... | |
iterator.h | Loading commit data... | |
khash.h | Loading commit data... | |
mailmap.c | Loading commit data... | |
mailmap.h | Loading commit data... | |
map.h | Loading commit data... | |
merge.c | Loading commit data... | |
merge.h | Loading commit data... | |
merge_driver.c | Loading commit data... | |
merge_driver.h | Loading commit data... | |
merge_file.c | Loading commit data... | |
message.c | Loading commit data... | |
message.h | Loading commit data... | |
mwindow.c | Loading commit data... | |
mwindow.h | Loading commit data... | |
net.c | Loading commit data... | |
net.h | Loading commit data... | |
netops.c | Loading commit data... | |
netops.h | Loading commit data... | |
notes.c | Loading commit data... | |
notes.h | Loading commit data... | |
object.c | Loading commit data... | |
object.h | Loading commit data... | |
object_api.c | Loading commit data... | |
odb.c | Loading commit data... | |
odb.h | Loading commit data... | |
odb_loose.c | Loading commit data... | |
odb_mempack.c | Loading commit data... | |
odb_pack.c | Loading commit data... | |
offmap.c | Loading commit data... | |
offmap.h | Loading commit data... | |
oid.c | Loading commit data... | |
oid.h | Loading commit data... | |
oidarray.c | Loading commit data... | |
oidarray.h | Loading commit data... | |
oidmap.c | Loading commit data... | |
oidmap.h | Loading commit data... | |
pack-objects.c | Loading commit data... | |
pack-objects.h | Loading commit data... | |
pack.c | Loading commit data... | |
pack.h | Loading commit data... | |
parse.c | Loading commit data... | |
parse.h | Loading commit data... | |
patch.c | Loading commit data... | |
patch.h | Loading commit data... | |
patch_generate.c | Loading commit data... | |
patch_generate.h | Loading commit data... | |
patch_parse.c | Loading commit data... | |
patch_parse.h | Loading commit data... | |
path.c | Loading commit data... | |
path.h | Loading commit data... | |
pathspec.c | Loading commit data... | |
pathspec.h | Loading commit data... | |
pool.c | Loading commit data... | |
pool.h | Loading commit data... | |
posix.c | Loading commit data... | |
posix.h | Loading commit data... | |
pqueue.c | Loading commit data... | |
pqueue.h | Loading commit data... | |
proxy.c | Loading commit data... | |
proxy.h | Loading commit data... | |
push.c | Loading commit data... | |
push.h | Loading commit data... | |
reader.c | Loading commit data... | |
reader.h | Loading commit data... | |
rebase.c | Loading commit data... | |
refdb.c | Loading commit data... | |
refdb.h | Loading commit data... | |
refdb_fs.c | Loading commit data... | |
reflog.c | Loading commit data... | |
reflog.h | Loading commit data... | |
refs.c | Loading commit data... | |
refs.h | Loading commit data... | |
refspec.c | Loading commit data... | |
refspec.h | Loading commit data... | |
regexp.c | Loading commit data... | |
regexp.h | Loading commit data... | |
remote.c | Loading commit data... | |
remote.h | Loading commit data... | |
repo_template.h | Loading commit data... | |
repository.c | Loading commit data... | |
repository.h | Loading commit data... | |
reset.c | Loading commit data... | |
revert.c | Loading commit data... | |
revparse.c | Loading commit data... | |
revwalk.c | Loading commit data... | |
revwalk.h | Loading commit data... | |
settings.c | Loading commit data... | |
signature.c | Loading commit data... | |
signature.h | Loading commit data... | |
sortedcache.c | Loading commit data... | |
sortedcache.h | Loading commit data... | |
stash.c | Loading commit data... | |
status.c | Loading commit data... | |
status.h | Loading commit data... | |
stream.h | Loading commit data... | |
strmap.c | Loading commit data... | |
strmap.h | Loading commit data... | |
strnlen.h | Loading commit data... | |
submodule.c | Loading commit data... | |
submodule.h | Loading commit data... | |
sysdir.c | Loading commit data... | |
sysdir.h | Loading commit data... | |
tag.c | Loading commit data... | |
tag.h | Loading commit data... | |
thread-utils.c | Loading commit data... | |
thread-utils.h | Loading commit data... | |
trace.c | Loading commit data... | |
trace.h | Loading commit data... | |
trailer.c | Loading commit data... | |
transaction.c | Loading commit data... | |
transaction.h | Loading commit data... | |
transport.c | Loading commit data... | |
tree-cache.c | Loading commit data... | |
tree-cache.h | Loading commit data... | |
tree.c | Loading commit data... | |
tree.h | Loading commit data... | |
tsort.c | Loading commit data... | |
userdiff.h | Loading commit data... | |
util.c | Loading commit data... | |
util.h | Loading commit data... | |
varint.c | Loading commit data... | |
varint.h | Loading commit data... | |
vector.c | Loading commit data... | |
vector.h | Loading commit data... | |
wildmatch.c | Loading commit data... | |
wildmatch.h | Loading commit data... | |
worktree.c | Loading commit data... | |
worktree.h | Loading commit data... | |
zstream.c | Loading commit data... | |
zstream.h | Loading commit data... |