diff options
author | Junio C Hamano <gitster@pobox.com> | 2019-03-07 09:59:51 +0900 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-03-07 09:59:51 +0900 |
commit | 7d0c1f4556ad89b2f7eae97d31ea85c3bfdf7c87 (patch) | |
tree | cce91296a436de34b3f81fe0ea4b433110ec69b5 /entry.c | |
parent | 36eb1cb9cfe327583128a4b0abdf9516c2ca815b (diff) | |
parent | e92aa0e4ef5a91781530449f9466a45c16c91f7f (diff) | |
download | git-7d0c1f4556ad89b2f7eae97d31ea85c3bfdf7c87.tar.gz |
Merge branch 'tg/checkout-no-overlay'
"git checkout --no-overlay" can be used to trigger a new mode of
checking out paths out of the tree-ish, that allows paths that
match the pathspec that are in the current index and working tree
and are not in the tree-ish.
* tg/checkout-no-overlay:
revert "checkout: introduce checkout.overlayMode config"
checkout: introduce checkout.overlayMode config
checkout: introduce --{,no-}overlay option
checkout: factor out mark_cache_entry_for_checkout function
checkout: clarify comment
read-cache: add invalidate parameter to remove_marked_cache_entries
entry: support CE_WT_REMOVE flag in checkout_entry
entry: factor out unlink_entry function
move worktree tests to t24*
Diffstat (limited to 'entry.c')
-rw-r--r-- | entry.c | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -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)); +} |