Merge branch 'ab/grep-preparatory-cleanup' into sb/submodule-blanket-recursive
[gitweb.git] / unpack-trees.c
index aa15111fefc8ca333edeeeb3ac77a8b946e4c6a5..d98a4f4d8668d989d34e5b938947704836ae8c84 100644 (file)
@@ -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;