summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b05c6df)
raw | patch | inline | side by side (parent: b05c6df)
author | Daniel Barkalow <barkalow@iabervon.org> | |
Thu, 7 Feb 2008 16:39:59 +0000 (11:39 -0500) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sun, 10 Feb 2008 07:16:51 +0000 (23:16 -0800) |
Way back in read-tree.c, we used a mode 0 cache entry to indicate that
an entry had been deleted, so that the update code would remove the
working tree file, and we would just skip it when writing out the
index file afterward.
These days, unpack_trees is a library function, and it is still
leaving these entries in the active cache. Furthermore, unpack_trees
doesn't correctly ignore those entries, and who knows what other code
wouldn't expect them to be there, but just isn't yet called after a
call to unpack_trees. To avoid having other code trip over these
entries, have check_updates() remove them after it removes the working
tree files.
While we're at it, simplify the loop in check_updates(), and avoid
passing global variables as parameters to check_updates(): there is
only one call site anyway.
Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
an entry had been deleted, so that the update code would remove the
working tree file, and we would just skip it when writing out the
index file afterward.
These days, unpack_trees is a library function, and it is still
leaving these entries in the active cache. Furthermore, unpack_trees
doesn't correctly ignore those entries, and who knows what other code
wouldn't expect them to be there, but just isn't yet called after a
call to unpack_trees. To avoid having other code trip over these
entries, have check_updates() remove them after it removes the working
tree files.
While we're at it, simplify the loop in check_updates(), and avoid
passing global variables as parameters to check_updates(): there is
only one call site anyway.
Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
unpack-trees.c | patch | blob | history |
diff --git a/unpack-trees.c b/unpack-trees.c
index f462a56ad26a05d88ac8e2eebf3587b862762e2e..40d41307583daba56e89d56a1dedab3d6eab572c 100644 (file)
--- a/unpack-trees.c
+++ b/unpack-trees.c
}
static struct checkout state;
-static void check_updates(struct cache_entry **src, int nr,
- struct unpack_trees_options *o)
+static void check_updates(struct unpack_trees_options *o)
{
unsigned cnt = 0, total = 0;
struct progress *progress = NULL;
char last_symlink[PATH_MAX];
+ int i;
if (o->update && o->verbose_update) {
- for (total = cnt = 0; cnt < nr; cnt++) {
- struct cache_entry *ce = src[cnt];
+ for (total = cnt = 0; cnt < active_nr; cnt++) {
+ struct cache_entry *ce = active_cache[cnt];
if (ce->ce_flags & (CE_UPDATE | CE_REMOVE))
total++;
}
}
*last_symlink = '\0';
- while (nr--) {
- struct cache_entry *ce = *src++;
+ for (i = 0; i < active_nr; i++) {
+ struct cache_entry *ce = active_cache[i];
if (ce->ce_flags & (CE_UPDATE | CE_REMOVE))
display_progress(progress, ++cnt);
if (ce->ce_flags & CE_REMOVE) {
if (o->update)
unlink_entry(ce->name, last_symlink);
+ remove_cache_entry_at(i);
+ i--;
continue;
}
if (ce->ce_flags & CE_UPDATE) {
error("Merge requires file-level merging");
}
- check_updates(active_cache, active_nr, o);
+ check_updates(o);
return 0;
}