Skip to content

Commit

Permalink
unpack-trees(): add CE_WT_REMOVE to remove on worktree alone
Browse files Browse the repository at this point in the history
CE_REMOVE now removes both worktree and index versions. Sparse
checkout must be able to remove worktree version while keep the
index intact when checkout area is narrowed.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Nguyễn Thái Ngọc Duy authored and Junio C Hamano committed Aug 24, 2009
1 parent ed5336a commit e663db2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ struct cache_entry {
#define CE_HASHED (0x100000)
#define CE_UNHASHED (0x200000)

/* Only remove in work directory, not index */
#define CE_WT_REMOVE (0x400000)

/*
* Extended on-disk flags
*/
Expand Down
9 changes: 8 additions & 1 deletion unpack-trees.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ static int check_updates(struct unpack_trees_options *o)
if (o->update && o->verbose_update) {
for (total = cnt = 0; cnt < index->cache_nr; cnt++) {
struct cache_entry *ce = index->cache[cnt];
if (ce->ce_flags & (CE_UPDATE | CE_REMOVE))
if (ce->ce_flags & (CE_UPDATE | CE_REMOVE | CE_WT_REMOVE))
total++;
}

Expand All @@ -92,6 +92,13 @@ static int check_updates(struct unpack_trees_options *o)
for (i = 0; i < index->cache_nr; i++) {
struct cache_entry *ce = index->cache[i];

if (ce->ce_flags & CE_WT_REMOVE) {
display_progress(progress, ++cnt);
if (o->update)
unlink_entry(ce);
continue;
}

if (ce->ce_flags & CE_REMOVE) {
display_progress(progress, ++cnt);
if (o->update)
Expand Down

0 comments on commit e663db2

Please sign in to comment.