monotone-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Monotone-devel] spurious warning from cd / ; mtn --root=.


From: Roland McGrath
Subject: [Monotone-devel] spurious warning from cd / ; mtn --root=.
Date: Sun, 13 Jan 2008 13:35:14 -0800 (PST)

When cwd is / and --root=. is used, . is expanded to // instead of /
and then mtn complains:

        mtn: warning: current directory '/' is not below root '//'

The patch below fixed that case for me, though I certainly won't claim it
looks like the proper way to do it.  I tried a few permutations of things
trying to use operator/ instead.  But the tangle of C++ hooey is too much
for me.


Thanks,
Roland

--- paths.cc    old
+++ paths.cc    new
@@ -765,7 +765,10 @@ system_path::system_path(any_path const 
         wr = working_root.get();
       else
         wr = working_root.get_but_unused();
-      data = normalize_path(wr.as_internal() + "/" + other.as_internal());
+      string s = wr.as_internal();
+      if (s != "/")
+        s = s + "/";
+      data = normalize_path(s + other.as_internal());
     }
 }
 
@@ -776,8 +779,12 @@ static inline string const_system_path(u
   if (is_absolute_here(expanded))
     return normalize_path(expanded);
   else
-    return normalize_path(initial_abs_path.get().as_internal()
-                          + "/" + path());
+    {
+      string s = initial_abs_path.get().as_internal();
+      if (s != "/")
+        s = s + "/";
+      return normalize_path(s + path());
+    }
 }
 
 system_path::system_path(string const & path)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]