cache-tree: Write updated cache-tree after commit
[gitweb.git] / builtin / checkout.c
index 63151e08a4d1b4180e797fd33e23a9bf75c2f79e..054214fe43c8f8e3b815d4afb747408f2524c378 100644 (file)
@@ -553,6 +553,14 @@ static int merge_working_tree(const struct checkout_opts *opts,
                }
        }
 
+       if (!active_cache_tree)
+               active_cache_tree = cache_tree();
+
+       if (!cache_tree_fully_valid(active_cache_tree))
+               cache_tree_update(active_cache_tree,
+                                 (const struct cache_entry * const *)active_cache,
+                                 active_nr, WRITE_TREE_SILENT | WRITE_TREE_REPAIR);
+
        if (write_cache(newfd, active_cache, active_nr) ||
            commit_locked_index(lock_file))
                die(_("unable to write new index file"));
@@ -1095,7 +1103,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
                OPT_BOOL(0, "detach", &opts.force_detach, N_("detach the HEAD at named commit")),
                OPT_SET_INT('t', "track",  &opts.track, N_("set upstream info for new branch"),
                        BRANCH_TRACK_EXPLICIT),
-               OPT_STRING(0, "orphan", &opts.new_orphan_branch, N_("new branch"), N_("new unparented branch")),
+               OPT_STRING(0, "orphan", &opts.new_orphan_branch, N_("new-branch"), N_("new unparented branch")),
                OPT_SET_INT('2', "ours", &opts.writeout_stage, N_("checkout our version for unmerged files"),
                            2),
                OPT_SET_INT('3', "theirs", &opts.writeout_stage, N_("checkout their version for unmerged files"),