diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-05-29 12:34:40 +0900 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-05-29 12:34:40 +0900 |
commit | 5f074ca7e8ddccb6471e457d7a3f85c1fe00e21a (patch) | |
tree | be3c66e879a0278947e30089b376434c6af3a5d8 /unpack-trees.c | |
parent | 1eb437020a2c098a7c12da4c05082fbea10d98c9 (diff) | |
parent | 35b96d1de8e795aeac8ec281e88e59f2778335e7 (diff) | |
download | git-5f074ca7e8ddccb6471e457d7a3f85c1fe00e21a.tar.gz |
Merge branch 'sb/reset-recurse-submodules'
"git reset" learned "--recurse-submodules" option.
* sb/reset-recurse-submodules:
builtin/reset: add --recurse-submodules switch
submodule.c: submodule_move_head works with broken submodules
submodule.c: uninitialized submodules are ignored in recursive commands
entry.c: submodule recursing: respect force flag correctly
Diffstat (limited to 'unpack-trees.c')
-rw-r--r-- | unpack-trees.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/unpack-trees.c b/unpack-trees.c index aa15111fef..d98a4f4d86 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -252,14 +252,18 @@ static int check_submodule_move_head(const struct cache_entry *ce, const char *new_id, struct unpack_trees_options *o) { + unsigned flags = SUBMODULE_MOVE_HEAD_DRY_RUN; const struct submodule *sub = submodule_from_ce(ce); if (!sub) return 0; + if (o->reset) + flags |= SUBMODULE_MOVE_HEAD_FORCE; + switch (sub->update_strategy.type) { case SM_UPDATE_UNSPECIFIED: case SM_UPDATE_CHECKOUT: - if (submodule_move_head(ce->name, old_id, new_id, SUBMODULE_MOVE_HEAD_DRY_RUN)) + if (submodule_move_head(ce->name, old_id, new_id, flags)) return o->gently ? -1 : add_rejected_path(o, ERROR_WOULD_LOSE_SUBMODULE, ce->name); return 0; @@ -308,6 +312,7 @@ static void unlink_entry(const struct cache_entry *ce) case SM_UPDATE_CHECKOUT: case SM_UPDATE_REBASE: case SM_UPDATE_MERGE: + /* state.force is set at the caller. */ submodule_move_head(ce->name, "HEAD", NULL, SUBMODULE_MOVE_HEAD_FORCE); break; |