From 20641c50c3edf0cc34f793106d76ec2fb75fbb31 Mon Sep 17 00:00:00 2001 From: Allan Odgaard Date: Tue, 5 Feb 2013 08:45:18 +0100 Subject: [PATCH] Disable SCM badges for non-local paths MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also disable it for user’s home folder and root of file system — having to monitor these folders is too expensive. --- Frameworks/scm/src/scm_ng.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Frameworks/scm/src/scm_ng.cc b/Frameworks/scm/src/scm_ng.cc index b716d014..c41337cd 100644 --- a/Frameworks/scm/src/scm_ng.cc +++ b/Frameworks/scm/src/scm_ng.cc @@ -5,6 +5,7 @@ #include #include #include +#include namespace scm { @@ -283,6 +284,11 @@ namespace scm { namespace ng return shared_info_ptr(); } + static bool scm_enabled_for_path (std::string const& path) + { + return path != "" && path != "/" && path[0] == '/' && path != path::home() && path::is_local(path) && settings_for_path(NULL_STR, "", path).get(kSettingsSCMStatusKey, true); + } + void disable () { Disabled = true; @@ -301,7 +307,7 @@ namespace scm { namespace ng std::string root_for_path (std::string const& path) { - if(path == NULL_STR || path == "" || path[0] != '/') + if(!scm_enabled_for_path(path)) return NULL_STR; __block std::string res = NULL_STR; @@ -331,7 +337,7 @@ namespace scm { namespace ng info_ptr info (std::string path) { - if(path == NULL_STR || path == "" || path[0] != '/') + if(!scm_enabled_for_path(path)) return info_ptr(); info_ptr res(new info_t(path));