]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Let Util::get_apparent_cwd return a normalized CWD
authorJoel Rosdahl <joel@rosdahl.net>
Thu, 20 Feb 2020 20:23:13 +0000 (21:23 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 23 Feb 2020 20:31:12 +0000 (21:31 +0100)
src/Util.cpp

index f5ac3700861c1d651519363d2155cf5743fca7e1..e59d5a7594fee75362c8a90ddfa2554cff26aa13 100644 (file)
@@ -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
 }