@matheusbsbs / matheus-bagliano / commits / f8f0b1f0e7
Fork 0

checkout -f failed to check out a file if an existing directory interfered.

When path foo/bar existed in the working tree, checkout -f to switch to a branch that has a file foo silently did a wrong thing. It failed to remove the directory foo, did not check out the file foo, and the worst of all it did not report any errors. Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Jul 16, 2006 at 23:25 UTC f8f0b1f0e7e96bf996c657d2c5c15e0ba3a4eeac
1 file changed +2 -2
builtin-read-tree.c
+2 -2
@@ -507,7 +507,7 @@ static int merged_entry(struct cache_entry *merge, struct cache_entry *old)
507 }
508
509 merge->ce_flags &= ~htons(CE_STAGEMASK);
510 - add_cache_entry(merge, ADD_CACHE_OK_TO_ADD);
510 + add_cache_entry(merge, ADD_CACHE_OK_TO_ADD|ADD_CACHE_OK_TO_REPLACE);
511 return 1;
512 }
513
@@ -518,7 +518,7 @@ static int deleted_entry(struct cache_entry *ce, struct cache_entry *old)
518 else
519 verify_absent(ce->name, "removed");
520 ce->ce_mode = 0;
521 - add_cache_entry(ce, ADD_CACHE_OK_TO_ADD);
521 + add_cache_entry(ce, ADD_CACHE_OK_TO_ADD|ADD_CACHE_OK_TO_REPLACE);
522 invalidate_ce_path(ce);
523 return 1;
524 }