diff options
Diffstat (limited to 'build/diagnostics.cxx')
-rw-r--r-- | build/diagnostics.cxx | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/build/diagnostics.cxx b/build/diagnostics.cxx index 34bbee8..f5802de 100644 --- a/build/diagnostics.cxx +++ b/build/diagnostics.cxx @@ -21,14 +21,31 @@ namespace build if (p == work) return "."; - path rp (relative_work (p)); +#ifndef _WIN32 + if (p == home) + return "~"; +#endif + + path rw (relative_work (p)); #ifndef _WIN32 - if (rp.absolute () && rp.sub (home)) - return "~/" + rp.leaf (home).string (); + if (rw.relative ()) + { + // See if the original path with the ~/ shortcut is better + // that the relative to work. + // + if (p.sub (home)) + { + path rh (p.leaf (home)); + if (rw.string ().size () > rh.string ().size () + 2) // 2 for '~/' + return "~/" + rh.string (); + } + } + else if (rw.sub (home)) + return "~/" + rw.leaf (home).string (); #endif - return rp.string (); + return rw.string (); } return p.string (); |