Make unpack-tree update removed files before any updated files
This is immaterial on sane filesystems, but if you have a broken (aka case-insensitive) filesystem, and the objective is to remove the file 'abc' and replace it with the file 'Abc', then we must make sure to do the removal first. Otherwise, you'd first update the file 'Abc' - which would just overwrite the file 'abc' due to the broken case-insensitive filesystem - and then remove file 'abc' - which would now brokenly remove the just updated file 'Abc' on that broken filesystem. By doing removals first, this won't happen. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Linus Torvalds committed
Mar 22, 2008 at 09:48 UTC
1fa6ead492c81bffdbe336373e5b162d3b5ac6d3
1 file changed
+7
-2
unpack-trees.c
+7
-2
@@ -79,16 +79,21 @@ static int check_updates(struct unpack_trees_options *o)
79
for (i = 0; i < index->cache_nr; i++) {
80
struct cache_entry *ce = index->cache[i];
81
82
- if (ce->ce_flags & (CE_UPDATE | CE_REMOVE))
83
- display_progress(progress, ++cnt);
82
if (ce->ce_flags & CE_REMOVE) {
83
+ display_progress(progress, ++cnt);
84
if (o->update)
85
unlink_entry(ce->name, last_symlink);
86
remove_index_entry_at(&o->result, i);
87
i--;
88
continue;
89
}
90
+ }
91
+
92
+ for (i = 0; i < index->cache_nr; i++) {
93
+ struct cache_entry *ce = index->cache[i];
94
+
95
if (ce->ce_flags & CE_UPDATE) {
96
+ display_progress(progress, ++cnt);
97
ce->ce_flags &= ~CE_UPDATE;
98
if (o->update) {
99
errs |= checkout_entry(ce, &state, NULL);