aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2020-11-21 21:55:30 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2020-11-23 12:29:41 +0300
commit81150339ba6c143c95517b1b5815de7ace177768 (patch)
treecd8f19eee91ee42721bb71b5ffce94469a1e047e
parent09702fc27c673066c87193879d2fdbc19ab9b33f (diff)
On Windows convert repo canonical name path part to lower case
-rw-r--r--libbpkg/manifest.cxx21
-rw-r--r--tests/repository-location/driver.cxx12
2 files changed, 29 insertions, 4 deletions
diff --git a/libbpkg/manifest.cxx b/libbpkg/manifest.cxx
index 016e88c..210aa3b 100644
--- a/libbpkg/manifest.cxx
+++ b/libbpkg/manifest.cxx
@@ -3766,6 +3766,19 @@ namespace bpkg
//
path sp;
+ // Convert the local repository location path to lower case on Windows.
+ //
+ // Note that we need to do that prior to stripping the special path
+ // components to match them case-insensitively, so, for example, the
+ // c:\pkg\1\stable and c:\Pkg\1\stable (or c:\repo.git and c:\repo.Git)
+ // repository locations end up with the same canonical name.
+ //
+ #ifdef _WIN32
+ const path& p (local () ? path (lcase (up.string ())) : up);
+ #else
+ const path& p (up);
+ #endif
+
switch (type_)
{
case repository_type::pkg:
@@ -3773,7 +3786,7 @@ namespace bpkg
// Produce the pkg repository canonical name <prefix>/<path> part (see
// the Repository Chaining documentation for more details).
//
- sp = strip_path (up,
+ sp = strip_path (p,
remote ()
? strip_mode::component
: strip_mode::path);
@@ -3783,7 +3796,7 @@ namespace bpkg
// stripping just the version component.
//
if (absolute () && sp.empty ())
- sp = strip_path (up, strip_mode::version);
+ sp = strip_path (p, strip_mode::version);
break;
}
@@ -3791,7 +3804,7 @@ namespace bpkg
{
// For dir repository we use the absolute (normalized) path.
//
- sp = up;
+ sp = p;
break;
}
case repository_type::git:
@@ -3799,7 +3812,7 @@ namespace bpkg
// For git repository we use the absolute (normalized) path, stripping
// the .git extension if present.
//
- sp = strip_path (up, strip_mode::extension);
+ sp = strip_path (p, strip_mode::extension);
break;
}
}
diff --git a/tests/repository-location/driver.cxx b/tests/repository-location/driver.cxx
index 32f5b8e..3eb8101 100644
--- a/tests/repository-location/driver.cxx
+++ b/tests/repository-location/driver.cxx
@@ -765,6 +765,18 @@ namespace bpkg
assert (l1.string () == l2.string ());
assert (l1.canonical_name () == l2.canonical_name ());
}
+ {
+ repository_location l1 (loc ("c:/var/pkg/1/misc"));
+ repository_location l2 (loc ("c:/var/Pkg/1/Misc"));
+ assert (l1.canonical_name () == "pkg:misc");
+ assert (l2.canonical_name () == l1.canonical_name ());
+ }
+ {
+ repository_location l1 (loc ("c:\\repo.git", repository_type::git));
+ repository_location l2 (loc ("C:/Repo.Git", repository_type::git));
+ assert (l1.canonical_name () == "git:c:\\repo");
+ assert (l2.canonical_name () == l1.canonical_name ());
+ }
#endif
{
repository_location l1 (loc ("http://www.cppget.org/1/stable"));