X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=entry.c;h=0e4f2f29101f913d0db2c401851f279eac496f02;hb=0b2094b06b8e810ba21348179cb71122faeb9263;hp=6fd72b30c8768677f044923ef5e715949d32fdae;hpb=11494daae7d6101cfb565b2a86b4dacefaeeedd8;p=thirdparty%2Fgit.git diff --git a/entry.c b/entry.c index 6fd72b30c8..0e4f2f2910 100644 --- a/entry.c +++ b/entry.c @@ -441,6 +441,17 @@ int checkout_entry(struct cache_entry *ce, const struct checkout *state, 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); @@ -510,3 +521,18 @@ int checkout_entry(struct cache_entry *ce, const struct checkout *state, (*nr_checkouts)++; return write_entry(ce, path.buf, state, 0); } + +void unlink_entry(const struct cache_entry *ce) +{ + const struct submodule *sub = submodule_from_ce(ce); + if (sub) { + /* state.force is set at the caller. */ + submodule_move_head(ce->name, "HEAD", NULL, + SUBMODULE_MOVE_HEAD_FORCE); + } + if (!check_leading_path(ce->name, ce_namelen(ce))) + return; + if (remove_or_warn(ce->ce_mode, ce->name)) + return; + schedule_dir_for_removal(ce->name, ce_namelen(ce)); +}