diff options
author | Junio C Hamano <gitster@pobox.com> | 2021-08-04 20:28:53 (GMT) |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-08-04 20:28:53 (GMT) |
commit | 506d2a354a9b24c531634094292b11ed8b8c2514 (patch) | |
tree | 2324d28eddd75395949471683f6eeec9781d841d /unpack-trees.c | |
parent | 58705b490314cb9a6f70916b4b69062b66ca7130 (diff) | |
parent | e05cdb17e89a2d3257533d47350b3138bfce8737 (diff) | |
download | git-506d2a354a9b24c531634094292b11ed8b8c2514.zip git-506d2a354a9b24c531634094292b11ed8b8c2514.tar.gz git-506d2a354a9b24c531634094292b11ed8b8c2514.tar.bz2 |
Merge branch 'ds/commit-and-checkout-with-sparse-index'
"git checkout" and "git commit" learn to work without unnecessarily
expanding sparse indexes.
* ds/commit-and-checkout-with-sparse-index:
unpack-trees: resolve sparse-directory/file conflicts
t1092: document bad 'git checkout' behavior
checkout: stop expanding sparse indexes
sparse-index: recompute cache-tree
commit: integrate with sparse-index
p2000: compress repo names
p2000: add 'git checkout -' test and decrease depth
Diffstat (limited to 'unpack-trees.c')
-rw-r--r-- | unpack-trees.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/unpack-trees.c b/unpack-trees.c index afc39db..5786645 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -2608,6 +2608,17 @@ int twoway_merge(const struct cache_entry * const *src, same(current, oldtree) && !same(current, newtree)) { /* 20 or 21 */ return merged_entry(newtree, current, o); + } else if (current && !oldtree && newtree && + S_ISSPARSEDIR(current->ce_mode) != S_ISSPARSEDIR(newtree->ce_mode) && + ce_stage(current) == 0) { + /* + * This case is a directory/file conflict across the sparse-index + * boundary. When we are changing from one path to another via + * 'git checkout', then we want to replace one entry with another + * via merged_entry(). If there are staged changes, then we should + * reject the merge instead. + */ + return merged_entry(newtree, current, o); } else return reject_merge(current, o); } |