aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoel Rosdahl <joel@rosdahl.net>2020-02-20 21:23:13 +0100
committerJoel Rosdahl <joel@rosdahl.net>2020-02-23 21:31:12 +0100
commit24f72647cc150373ed3a58b077a463d1753663c8 (patch)
treec3ecbc4f33f4808b6b36fb892b2bd36acad91c93
parent7caa6c00710844800763534fa2b6654c5da804f8 (diff)
downloadccache-24f72647cc150373ed3a58b077a463d1753663c8.tar.gz
ccache-24f72647cc150373ed3a58b077a463d1753663c8.tar.bz2
ccache-24f72647cc150373ed3a58b077a463d1753663c8.zip
Let Util::get_apparent_cwd return a normalized CWD
-rw-r--r--src/Util.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/Util.cpp b/src/Util.cpp
index f5ac3700..e59d5a75 100644
--- a/src/Util.cpp
+++ b/src/Util.cpp
@@ -237,16 +237,16 @@ get_apparent_cwd(const std::string& actual_cwd)
return actual_cwd;
}
- auto st_pwd = Stat::stat(pwd);
- auto st_cwd = Stat::stat(actual_cwd);
- if (!st_pwd || !st_cwd) {
- return actual_cwd;
- }
- if (st_pwd.device() == st_cwd.device() && st_pwd.inode() == st_cwd.inode()) {
- return pwd;
- } else {
+ auto pwd_stat = Stat::stat(pwd);
+ auto cwd_stat = Stat::stat(actual_cwd);
+ if (!pwd_stat || !cwd_stat || !pwd_stat.same_inode_as(cwd_stat)) {
return actual_cwd;
}
+ std::string normalized_pwd = normalize_absolute_path(pwd);
+ return normalized_pwd == pwd
+ || Stat::stat(normalized_pwd).same_inode_as(pwd_stat)
+ ? normalized_pwd
+ : pwd;
#endif
}