diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2025-09-16 18:16:05 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2025-09-16 18:16:05 +0100 |
commit | 430e397f8400f5b4a80bc398388c4383654df920 (patch) | |
tree | 967e38711cee1c23d2e9d4040d4334f4acc19c5e | |
parent | Remove unnecessary coverage variant definition (diff) | |
download | netfs-gitfs-430e397f8400f5b4a80bc398388c4383654df920.tar.bz2 netfs-gitfs-430e397f8400f5b4a80bc398388c4383654df920.tar.xz netfs-gitfs-430e397f8400f5b4a80bc398388c4383654df920.zip |
Include . and .. in readdir results
-rw-r--r-- | src/dir.cpp | 4 | ||||
-rw-r--r-- | unittests/core.cpp | 10 |
2 files changed, 8 insertions, 6 deletions
diff --git a/src/dir.cpp b/src/dir.cpp index b2de780..c608259 100644 --- a/src/dir.cpp +++ b/src/dir.cpp @@ -50,7 +50,9 @@ GitFS::Directory::readdir(const ::Ice::Current &) const auto subTree = getSubtree(); NetFS::NameList list; auto idx = git_tree_entrycount(subTree.get()); - list.reserve(idx); + list.reserve(idx + 2); + list.emplace_back("."); + list.emplace_back(".."); while (idx--) { const auto entry = git_tree_entry_byindex(subTree.get(), idx); list.emplace_back(git_tree_entry_name(entry)); diff --git a/unittests/core.cpp b/unittests/core.cpp index 960b491..f6a2341 100644 --- a/unittests/core.cpp +++ b/unittests/core.cpp @@ -257,11 +257,11 @@ BOOST_DATA_TEST_CASE(openDirNotDir, REGPATHS + LINKPATHS + EXECPATHS, path) } const auto DIRCONTENTS = btdata::make<std::vector<std::string>>({ - {".gitignore", "Jamroot.jam", "src", "unittests"}, - {"Jamfile.jam", "blob.cpp", "blob.h", "dir.cpp", "dir.h", "git.cpp", "git.h", "main.cpp", "repo.cpp", "repo.h", - "repoList.cpp", "repoList.h"}, - {"Jamfile.jam", "core.cpp", "fixtures", "mockDefs.cpp", "mockDefs.h"}, - {"executable", "symlink"}, + {".", "..", ".gitignore", "Jamroot.jam", "src", "unittests"}, + {".", "..", "Jamfile.jam", "blob.cpp", "blob.h", "dir.cpp", "dir.h", "git.cpp", "git.h", "main.cpp", "repo.cpp", + "repo.h", "repoList.cpp", "repoList.h"}, + {".", "..", "Jamfile.jam", "core.cpp", "fixtures", "mockDefs.cpp", "mockDefs.h"}, + {".", "..", "executable", "symlink"}, }); BOOST_DATA_TEST_CASE(openDirRead, DIRPATHS ^ DIRCONTENTS, path, contents) |