File tree Expand file tree Collapse file tree 3 files changed +31
-0
lines changed
Expand file tree Collapse file tree 3 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -555,10 +555,25 @@ static int is_dir_empty(const wchar_t *wpath)
555555int mingw_rmdir (const char * pathname )
556556{
557557 int tries = 0 ;
558+ struct stat sb ;
559+
558560 wchar_t wpathname [MAX_LONG_PATH ];
559561 if (xutftowcs_long_path (wpathname , pathname ) < 0 )
560562 return -1 ;
561563
564+ /*
565+ * Contrary to Linux rmdir(), Windows' _wrmdir() and _rmdir()
566+ * will remove the directory at the path if it is a symbolic link
567+ * which leads to issues when symlinks are used in the .git folder
568+ * (in the context of git-repo for instance). So before calling _wrmdir()
569+ * we first check if the path is a symbolic link. If it is, we exit
570+ * and return the same error as Linux rmdir() in this case (ENOTDIR).
571+ */
572+ if (!mingw_lstat (pathname , & sb ) && S_ISLNK (sb .st_mode )) {
573+ errno = ENOTDIR ;
574+ return -1 ;
575+ }
576+
562577 do {
563578 if (!_wrmdir (wpathname )) {
564579 invalidate_lstat_cache ();
Original file line number Diff line number Diff line change @@ -406,4 +406,14 @@ test_expect_success 'refuse to switch to branch checked out elsewhere' '
406406 test_i18ngrep "already checked out" err
407407'
408408
409+ test_expect_success MINGW,SYMLINKS_WINDOWS ' rebase when .git/logs is a symlink' '
410+ git checkout main &&
411+ mv .git/logs actual_logs &&
412+ cmd //c "mklink /D .git\logs ..\actual_logs" &&
413+ git rebase -f HEAD^ &&
414+ test -L .git/logs &&
415+ rm .git/logs &&
416+ mv actual_logs .git/logs
417+ '
418+
409419test_done
Original file line number Diff line number Diff line change @@ -1536,6 +1536,12 @@ test_lazy_prereq SYMLINKS '
15361536 ln -s x y && test -h y
15371537'
15381538
1539+ test_lazy_prereq SYMLINKS_WINDOWS '
1540+ # test whether symbolic links are enabled on Windows
1541+ test_have_prereq MINGW &&
1542+ cmd //c "mklink y x" &> /dev/null && test -h y
1543+ '
1544+
15391545test_lazy_prereq FILEMODE '
15401546 test "$(git config --bool core.filemode)" = true
15411547'
You can’t perform that action at this time.
0 commit comments