Commit 3d56c98e authored by agrieve's avatar agrieve Committed by Commit bot

Make rebase_path("//foo", "//foo") resolve to "." (not "../foo")

BUG=647679

Review-Url: https://codereview.chromium.org/2346913003
Cr-Commit-Position: refs/heads/master@{#419229}
parent e704807e
......@@ -98,13 +98,23 @@ Value ConvertOnePath(const Scope* scope,
scope->settings()->build_settings()->root_path_utf8());
MakeSlashEndingMatchInput(string_value, &result.string_value());
} else {
result.string_value() = RebasePath(
SourceFile resolved_file =
from_dir.ResolveRelativeFile(value, err,
scope->settings()->build_settings()->root_path_utf8()).value(),
to_dir,
scope->settings()->build_settings()->root_path_utf8());
scope->settings()->build_settings()->root_path_utf8());
if (err->has_error())
return Value();
// Special case:
// rebase_path("//foo", "//bar") ==> "../foo"
// rebase_path("//foo", "//foo") ==> "." and not "../foo"
if (resolved_file.value() ==
to_dir.value().substr(0, to_dir.value().size() - 1)) {
result.string_value() = ".";
} else {
result.string_value() = RebasePath(
resolved_file.value(),
to_dir,
scope->settings()->build_settings()->root_path_utf8());
}
}
return result;
......
......@@ -51,9 +51,7 @@ TEST(RebasePath, Strings) {
EXPECT_EQ("foo/", RebaseOne(scope, "//foo/", "//", "//"));
EXPECT_EQ("../../foo/bar", RebaseOne(scope, "//foo/bar", "//out/Debug", "."));
EXPECT_EQ("./", RebaseOne(scope, "//foo/", "//foo/", "//"));
// Thie one is technically correct but could be simplified to "." if
// necessary.
EXPECT_EQ("../foo", RebaseOne(scope, "//foo", "//foo", "//"));
EXPECT_EQ(".", RebaseOne(scope, "//foo", "//foo", "//"));
// Test slash conversion.
EXPECT_EQ("foo/bar", RebaseOne(scope, "foo/bar", ".", "."));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment