Skip to content

Commit 235236c

Browse files
committed
Merge branch 'maint-1.6.2' into maint
* maint-1.6.2: Revert "checkout branch: prime cache-tree fully"
2 parents ec00d6e + a83502f commit 235236c

File tree

2 files changed

+29
-8
lines changed

2 files changed

+29
-8
lines changed

builtin-checkout.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -365,17 +365,14 @@ static int merge_working_tree(struct checkout_opts *opts,
365365
int ret;
366366
struct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file));
367367
int newfd = hold_locked_index(lock_file, 1);
368-
int reprime_cache_tree = 0;
369368

370369
if (read_cache() < 0)
371370
return error("corrupt index file");
372371

373-
cache_tree_free(&active_cache_tree);
374372
if (opts->force) {
375373
ret = reset_tree(new->commit->tree, opts, 1);
376374
if (ret)
377375
return ret;
378-
reprime_cache_tree = 1;
379376
} else {
380377
struct tree_desc trees[2];
381378
struct tree *tree;
@@ -411,9 +408,7 @@ static int merge_working_tree(struct checkout_opts *opts,
411408
init_tree_desc(&trees[1], tree->buffer, tree->size);
412409

413410
ret = unpack_trees(2, trees, &topts);
414-
if (ret != -1) {
415-
reprime_cache_tree = 1;
416-
} else {
411+
if (ret == -1) {
417412
/*
418413
* Unpack couldn't do a trivial merge; either
419414
* give up or do a real merge, depending on
@@ -457,8 +452,6 @@ static int merge_working_tree(struct checkout_opts *opts,
457452
}
458453
}
459454

460-
if (reprime_cache_tree)
461-
prime_cache_tree(&active_cache_tree, new->commit->tree);
462455
if (write_cache(newfd, active_cache, active_nr) ||
463456
commit_locked_index(lock_file))
464457
die("unable to write new index file");

t/t2014-switch.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/sh
2+
3+
test_description='Peter MacMillan'
4+
. ./test-lib.sh
5+
6+
test_expect_success setup '
7+
echo Hello >file &&
8+
git add file &&
9+
test_tick &&
10+
git commit -m V1 &&
11+
echo Hello world >file &&
12+
git add file &&
13+
git checkout -b other
14+
'
15+
16+
test_expect_success 'check all changes are staged' '
17+
git diff --exit-code
18+
'
19+
20+
test_expect_success 'second commit' '
21+
git commit -m V2
22+
'
23+
24+
test_expect_success 'check' '
25+
git diff --cached --exit-code
26+
'
27+
28+
test_done

0 commit comments

Comments
 (0)