Re: [PATCH] Don't update unchanged merge entries
Linus Torvalds <torvalds@linux-foundation.org> writes:
Show 9 quoted lines
> On Sun, 16 Mar 2008, Daniel Barkalow wrote:
>>
>> Well, the top part of the comment suggests that this is just an
>> optimization (don't bother to write out a file that you know is
>> unchanged), when it's actually necessary for correctness (since we don't
>> know if the working tree matches the old index).
>
> Ahh, that part. Yeah, maybe we could expand/clarify it. I don't think the
> comment is wrong per se, but yes, I'm sure it could be improved.
Will squash this in (together with the test updates I sent out earlier).
unpack-trees.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/unpack-trees.c b/unpack-trees.c
index a72ac03..4b359e0 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -602,8 +602,8 @@ static int merged_entry(struct cache_entry *merge, struct cache_entry *old,
* See if we can re-use the old CE directly?
* That way we get the uptodate stat info.
*
- * This also removes the UPDATE flag on
- * a match.
+ * This also removes the UPDATE flag on a match; otherwise
+ * we will end up overwriting local changes in the work tree.
*/
if (same(old, merge)) {
copy_cache_entry(merge, old);