Use helper function for copying index entry information

We used to just memcpy() the index entry when we copied the stat() and
SHA1 hash information, which worked well enough back when the index
entry was just an exact bit-for-bit representation of the information on
disk.

However, these days we actually have various management information in
the cache entry too, and we should be careful to not overwrite it when
we copy the stat information from another index entry.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Linus Torvalds
2008-02-22 20:41:17 -08:00
committed by Junio C Hamano
parent d070e3a31b
commit eb7a2f1d50
2 changed files with 18 additions and 2 deletions

View File

@ -590,7 +590,7 @@ static int merged_entry(struct cache_entry *merge, struct cache_entry *old,
* a match.
*/
if (same(old, merge)) {
memcpy(merge, old, offsetof(struct cache_entry, name));
copy_cache_entry(merge, old);
} else {
verify_uptodate(old, o);
invalidate_ce_path(old);