Skip to content

Commit 536ec18

Browse files
tgummerergitster
authored andcommitted
entry: support CE_WT_REMOVE flag in checkout_entry
'checkout_entry()' currently only supports creating new entries in the working tree, but not deleting them. Add the ability to remove entries at the same time if the entry is marked with the CE_WT_REMOVE flag. Currently this doesn't have any effect, as the CE_WT_REMOVE flag is only used in unpack-tree, however we will make use of this in a subsequent step in the series. Signed-off-by: Thomas Gummerer <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b702dd1 commit 536ec18

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

entry.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,17 @@ int checkout_entry(struct cache_entry *ce,
441441
static struct strbuf path = STRBUF_INIT;
442442
struct stat st;
443443

444+
if (ce->ce_flags & CE_WT_REMOVE) {
445+
if (topath)
446+
/*
447+
* No content and thus no path to create, so we have
448+
* no pathname to return.
449+
*/
450+
BUG("Can't remove entry to a path");
451+
unlink_entry(ce);
452+
return 0;
453+
}
454+
444455
if (topath)
445456
return write_entry(ce, topath, state, 1);
446457

0 commit comments

Comments
 (0)