X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=builtin%2Freset.c;h=8c2c1d52a227334a3d6456bf0989cd561628ffa0;hb=c4a01a3cbbd8b642a3ffc6bc550b68ac63d500ed;hp=811e8e252c1c6a54e65179557203daf2bc42bdb9;hpb=9ef569791f967c1559b498d8f77a2c42a14be2ed;p=git.git diff --git a/builtin/reset.c b/builtin/reset.c index 811e8e252..8c2c1d52a 100644 --- a/builtin/reset.c +++ b/builtin/reset.c @@ -43,6 +43,7 @@ static int reset_index_file(const unsigned char *sha1, int reset_type, int quiet int nr = 1; int newfd; struct tree_desc desc[2]; + struct tree *tree; struct unpack_trees_options opts; struct lock_file *lock = xcalloc(1, sizeof(struct lock_file)); @@ -84,6 +85,12 @@ static int reset_index_file(const unsigned char *sha1, int reset_type, int quiet return error(_("Failed to find tree of %s."), sha1_to_hex(sha1)); if (unpack_trees(nr, desc, &opts)) return -1; + + if (reset_type == MIXED || reset_type == HARD) { + tree = parse_tree_indirect(sha1); + prime_cache_tree(&active_cache_tree, tree); + } + if (write_cache(newfd, active_cache, active_nr) || commit_locked_index(lock)) return error(_("Could not write new index file."));