From ebda6f466950013d8256fb3eb11c7329af757176 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 23 May 2024 22:59:49 +0300 Subject: Fix --- bpkg/fetch-git.cxx | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/bpkg/fetch-git.cxx b/bpkg/fetch-git.cxx index 87e30fb..f1ebc31 100644 --- a/bpkg/fetch-git.cxx +++ b/bpkg/fetch-git.cxx @@ -2536,15 +2536,24 @@ namespace bpkg // even though .gitattributes indicates that it should. Thus, let's just // remove all the symlinks prior to git-reset on Windows. // -#ifdef _WIN32 +//#ifdef _WIN32 for (const auto& l: find_symlinks (co, dir, prefix)) { - // Note: try_rmsymlink() implementation actually doesn't distinguish - // between the directory and file symlinks. + // Note that we could potentially replace the filesystem-agnostic + // symlinks with hardlinks and thus we need to check the type of a + // filesystem entry prior to the removal. Also note try_rmsymlink() + // implementation actually doesn't distinguish between the directory and + // file symlinks. // - try_rmsymlink (dir / l.first, false /* dir */, true /* ignore_error */); + path p (dir / l.first); + + const auto& e ( + path_entry (p, false /* follow_symlink */, true /* ignore_error */)); + + if (e.first && e.second.type == entry_stat::symlink) + try_rmsymlink (p, false /* dir */, true /* ignore_error */); } -#endif +//#endif // For some (probably valid) reason the hard reset command doesn't remove // a submodule directory that is not plugged into the repository anymore. -- cgit v1.1