File tree Expand file tree Collapse file tree 3 files changed +67
-2
lines changed
Expand file tree Collapse file tree 3 files changed +67
-2
lines changed Original file line number Diff line number Diff line change @@ -110,7 +110,7 @@ static int check_local_mod(unsigned char *head, int index_only)
110110 ce = active_cache [pos ];
111111
112112 if (lstat (ce -> name , & st ) < 0 ) {
113- if (errno != ENOENT )
113+ if (errno != ENOENT && errno != ENOTDIR )
114114 warning ("'%s': %s" , ce -> name , strerror (errno ));
115115 /* It already vanished from the working tree */
116116 continue ;
Original file line number Diff line number Diff line change @@ -1647,7 +1647,7 @@ int remove_path(const char *name)
16471647{
16481648 char * slash ;
16491649
1650- if (unlink (name ) && errno != ENOENT )
1650+ if (unlink (name ) && errno != ENOENT && errno != ENOTDIR )
16511651 return -1 ;
16521652
16531653 slash = strrchr (name , '/' );
Original file line number Diff line number Diff line change @@ -622,4 +622,69 @@ test_expect_success 'rm of a populated nested submodule with a nested .git direc
622622 rm -rf submod
623623'
624624
625+ test_expect_success ' rm of d/f when d has become a non-directory' '
626+ rm -rf d &&
627+ mkdir d &&
628+ >d/f &&
629+ git add d &&
630+ rm -rf d &&
631+ >d &&
632+ git rm d/f &&
633+ test_must_fail git rev-parse --verify :d/f &&
634+ test_path_is_file d
635+ '
636+
637+ test_expect_success SYMLINKS ' rm of d/f when d has become a dangling symlink' '
638+ rm -rf d &&
639+ mkdir d &&
640+ >d/f &&
641+ git add d &&
642+ rm -rf d &&
643+ ln -s nonexistent d &&
644+ git rm d/f &&
645+ test_must_fail git rev-parse --verify :d/f &&
646+ test -h d &&
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_expect_success SYMLINKS ' rm across a symlinked leading path (no index)' '
663+ rm -rf d e &&
664+ mkdir e &&
665+ echo content >e/f &&
666+ ln -s e d &&
667+ git add -A e d &&
668+ git commit -m "symlink d to e, e/f exists" &&
669+ test_must_fail git rm d/f &&
670+ git rev-parse --verify :d &&
671+ git rev-parse --verify :e/f &&
672+ test -h d &&
673+ test_path_is_file e/f
674+ '
675+
676+ test_expect_failure SYMLINKS ' rm across a symlinked leading path (w/ index)' '
677+ rm -rf d e &&
678+ mkdir d &&
679+ echo content >d/f &&
680+ git add -A e d &&
681+ git commit -m "d/f exists" &&
682+ mv d e &&
683+ ln -s e d &&
684+ test_must_fail git rm d/f &&
685+ git rev-parse --verify :d/f &&
686+ test -h d &&
687+ test_path_is_file e/f
688+ '
689+
625690test_done
You can’t perform that action at this time.
0 commit comments