diff options
| author | Edward Thomson <ethomson@github.com> | 2016-06-02 03:08:26 -0500 |
|---|---|---|
| committer | Edward Thomson <ethomson@github.com> | 2016-06-02 03:08:26 -0500 |
| commit | f0ee795ccb552b87637c7973ac64f64437baa041 (patch) | |
| tree | 596562409e83f97384cfcddffc937f117fd86773 /src | |
| parent | 0aaba445933bed0ab046009fe6c4aca1aaf7c6b9 (diff) | |
| parent | 46082c384f6c4872cb2ebef6666e9a65b045b609 (diff) | |
| download | libgit2-f0ee795ccb552b87637c7973ac64f64437baa041.tar.gz | |
Merge pull request #3808 from ethomson/read_index_fixes
`git_index_read_index` fixes
Diffstat (limited to 'src')
| -rw-r--r-- | src/index.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/index.c b/src/index.c index 31cb27d6c..20ab6a19d 100644 --- a/src/index.c +++ b/src/index.c @@ -2968,6 +2968,8 @@ int git_index_read_index( *remove_entry = NULL; int diff; + error = 0; + if (old_entry && new_entry) diff = git_index_entry_cmp(old_entry, new_entry); else if (!old_entry && new_entry) @@ -2985,7 +2987,8 @@ int git_index_read_index( /* Path and stage are equal, if the OID is equal, keep it to * keep the stat cache data. */ - if (git_oid_equal(&old_entry->id, &new_entry->id)) { + if (git_oid_equal(&old_entry->id, &new_entry->id) && + old_entry->mode == new_entry->mode) { add_entry = (git_index_entry *)old_entry; } else { dup_entry = (git_index_entry *)new_entry; @@ -2996,8 +2999,17 @@ int git_index_read_index( if (dup_entry) { if ((error = index_entry_dup_nocache(&add_entry, index, dup_entry)) < 0) goto done; + + index_entry_adjust_namemask(add_entry, + ((struct entry_internal *)add_entry)->pathlen); } + /* invalidate this path in the tree cache if this is new (to + * invalidate the parent trees) + */ + if (dup_entry && !remove_entry && index->tree) + git_tree_cache_invalidate_path(index->tree, dup_entry->path); + if (add_entry) { if ((error = git_vector_insert(&new_entries, add_entry)) == 0) INSERT_IN_MAP_EX(index, new_entries_map, add_entry, error); |
