mirror of
https://git.proxmox.com/git/libgit2
synced 2025-06-23 09:10:46 +00:00
Merge pull request #1477 from ethomson/checkout_modified_use_cache
checkout: use cache when possible to determine if workdir item is dirty
This commit is contained in:
commit
526882a30a
@ -119,6 +119,7 @@ static bool checkout_is_workdir_modified(
|
|||||||
const git_index_entry *wditem)
|
const git_index_entry *wditem)
|
||||||
{
|
{
|
||||||
git_oid oid;
|
git_oid oid;
|
||||||
|
const git_index_entry *ie;
|
||||||
|
|
||||||
/* handle "modified" submodule */
|
/* handle "modified" submodule */
|
||||||
if (wditem->mode == GIT_FILEMODE_COMMIT) {
|
if (wditem->mode == GIT_FILEMODE_COMMIT) {
|
||||||
@ -140,6 +141,17 @@ static bool checkout_is_workdir_modified(
|
|||||||
return (git_oid_cmp(&baseitem->oid, sm_oid) != 0);
|
return (git_oid_cmp(&baseitem->oid, sm_oid) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Look at the cache to decide if the workdir is modified. If not,
|
||||||
|
* we can simply compare the oid in the cache to the baseitem instead
|
||||||
|
* of hashing the file.
|
||||||
|
*/
|
||||||
|
if ((ie = git_index_get_bypath(data->index, wditem->path, 0)) != NULL) {
|
||||||
|
if (wditem->mtime.seconds == ie->mtime.seconds &&
|
||||||
|
wditem->mtime.nanoseconds == ie->mtime.nanoseconds &&
|
||||||
|
wditem->file_size == ie->file_size)
|
||||||
|
return (git_oid_cmp(&baseitem->oid, &ie->oid) != 0);
|
||||||
|
}
|
||||||
|
|
||||||
/* depending on where base is coming from, we may or may not know
|
/* depending on where base is coming from, we may or may not know
|
||||||
* the actual size of the data, so we can't rely on this shortcut.
|
* the actual size of the data, so we can't rely on this shortcut.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user