mirror of
https://git.proxmox.com/git/libgit2
synced 2026-01-03 18:24:19 +00:00
index: clear uptodate bit on save
The uptodate bit should have a lifecycle of a single read->write on the index. Once the index is written, the files within it should be scanned for racy timestamps against the new index timestamp.
This commit is contained in:
parent
956f4da897
commit
27bc41cf17
17
src/index.c
17
src/index.c
@ -2746,6 +2746,15 @@ static int write_tree_extension(git_index *index, git_filebuf *file)
|
||||
return error;
|
||||
}
|
||||
|
||||
static void clear_uptodate(git_index *index)
|
||||
{
|
||||
git_index_entry *entry;
|
||||
size_t i;
|
||||
|
||||
git_vector_foreach(&index->entries, i, entry)
|
||||
entry->flags_extended &= ~GIT_IDXENTRY_UPTODATE;
|
||||
}
|
||||
|
||||
static int write_index(git_oid *checksum, git_index *index, git_filebuf *file)
|
||||
{
|
||||
git_oid hash_final;
|
||||
@ -2785,7 +2794,13 @@ static int write_index(git_oid *checksum, git_index *index, git_filebuf *file)
|
||||
git_oid_cpy(checksum, &hash_final);
|
||||
|
||||
/* write it at the end of the file */
|
||||
return git_filebuf_write(file, hash_final.id, GIT_OID_RAWSZ);
|
||||
if (git_filebuf_write(file, hash_final.id, GIT_OID_RAWSZ) < 0)
|
||||
return -1;
|
||||
|
||||
/* file entries are no longer up to date */
|
||||
clear_uptodate(index);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int git_index_entry_stage(const git_index_entry *entry)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user