mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-09 22:39:38 +00:00
Only write index if updated when passing GIT_DIFF_UPDATE_INDEX
When diffing the index with the workdir and GIT_DIFF_UPDATE_INDEX has been passed, the previous implementation was always writing the index to disk even if it wasn't modified.
This commit is contained in:
parent
619423f238
commit
c2e1b0581a
@ -664,8 +664,10 @@ int git_diff__oid_for_entry(
|
|||||||
updated_entry.mode = mode;
|
updated_entry.mode = mode;
|
||||||
git_oid_cpy(&updated_entry.id, out);
|
git_oid_cpy(&updated_entry.id, out);
|
||||||
|
|
||||||
if (!(error = git_repository_index__weakptr(&idx, diff->repo)))
|
if (!(error = git_repository_index__weakptr(&idx, diff->repo))) {
|
||||||
error = git_index_add(idx, &updated_entry);
|
error = git_index_add(idx, &updated_entry);
|
||||||
|
diff->index_updated = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
git_buf_free(&full_path);
|
git_buf_free(&full_path);
|
||||||
@ -1360,7 +1362,7 @@ int git_diff_index_to_workdir(
|
|||||||
&b, repo, index, NULL, GIT_ITERATOR_DONT_AUTOEXPAND, pfx, pfx)
|
&b, repo, index, NULL, GIT_ITERATOR_DONT_AUTOEXPAND, pfx, pfx)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!error && DIFF_FLAG_IS_SET(*diff, GIT_DIFF_UPDATE_INDEX))
|
if (!error && DIFF_FLAG_IS_SET(*diff, GIT_DIFF_UPDATE_INDEX) && (*diff)->index_updated)
|
||||||
error = git_index_write(index);
|
error = git_index_write(index);
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
|
@ -64,6 +64,7 @@ struct git_diff {
|
|||||||
git_iterator_type_t new_src;
|
git_iterator_type_t new_src;
|
||||||
uint32_t diffcaps;
|
uint32_t diffcaps;
|
||||||
git_diff_perfdata perf;
|
git_diff_perfdata perf;
|
||||||
|
bool index_updated;
|
||||||
|
|
||||||
int (*strcomp)(const char *, const char *);
|
int (*strcomp)(const char *, const char *);
|
||||||
int (*strncomp)(const char *, const char *, size_t);
|
int (*strncomp)(const char *, const char *, size_t);
|
||||||
|
Loading…
Reference in New Issue
Block a user