Skip to content

Commit e663db2

Browse files
pcloudsgitster
authored andcommitted
unpack-trees(): add CE_WT_REMOVE to remove on worktree alone
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ed5336a commit e663db2

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

cache.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,9 @@ struct cache_entry {
177177
#define CE_HASHED (0x100000)
178178
#define CE_UNHASHED (0x200000)
179179

180+
/* Only remove in work directory, not index */
181+
#define CE_WT_REMOVE (0x400000)
182+
180183
/*
181184
* Extended on-disk flags
182185
*/

unpack-trees.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ static int check_updates(struct unpack_trees_options *o)
7878
if (o->update && o->verbose_update) {
7979
for (total = cnt = 0; cnt < index->cache_nr; cnt++) {
8080
struct cache_entry *ce = index->cache[cnt];
81-
if (ce->ce_flags & (CE_UPDATE | CE_REMOVE))
81+
if (ce->ce_flags & (CE_UPDATE | CE_REMOVE | CE_WT_REMOVE))
8282
total++;
8383
}
8484

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

95+
if (ce->ce_flags & CE_WT_REMOVE) {
96+
display_progress(progress, ++cnt);
97+
if (o->update)
98+
unlink_entry(ce);
99+
continue;
100+
}
101+
95102
if (ce->ce_flags & CE_REMOVE) {
96103
display_progress(progress, ++cnt);
97104
if (o->update)

0 commit comments

Comments
 (0)