t3600: test behavior of reverse-d/f conflict
The previous commit taught "rm" that it is safe to consider "d/f" removed when "d" has become a non-directory. This patch adds a test for the opposite: a file "d" that becomes a directory. In this case, "git rm" does need to complain, because we should not be removing arbitrary content under "d". Git already behaves correctly, but let's make sure that remains the case by protecting the behavior with a test. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Apr 4, 2013 at 15:03 UTC
96ec8ee92aad52b6556e87d0166a7b9c4cd7c324
1 file changed
+12
t/t3600-rm.sh
+12
@@ -647,4 +647,16 @@ test_expect_success SYMLINKS 'rm of d/f when d has become a dangling symlink' '
647
test_path_is_missing d
648
'
649
650
+test_expect_success 'rm of file when it has become a directory' '
651
+ rm -rf d &&
652
+ >d &&
653
+ git add d &&
654
+ rm -f d &&
655
+ mkdir d &&
656
+ >d/f &&
657
+ test_must_fail git rm d &&
658
+ git rev-parse --verify :d &&
659
+ test_path_is_file d/f
660
+'
661
+
662
test_done