summaryrefslogtreecommitdiff
path: root/entry.c
diff options
context:
space:
mode:
authorThomas Gummerer <t.gummerer@gmail.com>2018-12-20 13:48:15 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-01-02 23:28:05 (GMT)
commit536ec1839dbde8b9a6b38e6ccb5ab01b2b6311f9 (patch)
tree2a89182bfc236ec4c27f2b9121df93b2ce115b0d /entry.c
parentb702dd12d52816e192578c6206db5e6c332ba49b (diff)
downloadgit-536ec1839dbde8b9a6b38e6ccb5ab01b2b6311f9.zip
git-536ec1839dbde8b9a6b38e6ccb5ab01b2b6311f9.tar.gz
git-536ec1839dbde8b9a6b38e6ccb5ab01b2b6311f9.tar.bz2
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 <t.gummerer@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'entry.c')
-rw-r--r--entry.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/entry.c b/entry.c
index b9eef57..3d3701e 100644
--- a/entry.c
+++ b/entry.c
@@ -441,6 +441,17 @@ int checkout_entry(struct cache_entry *ce,
static struct strbuf path = STRBUF_INIT;
struct stat st;
+ if (ce->ce_flags & CE_WT_REMOVE) {
+ if (topath)
+ /*
+ * No content and thus no path to create, so we have
+ * no pathname to return.
+ */
+ BUG("Can't remove entry to a path");
+ unlink_entry(ce);
+ return 0;
+ }
+
if (topath)
return write_entry(ce, topath, state, 1);