From a8157a2acf5ac23e58aa18fe3ddf855341790d5f Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Thu, 24 Dec 2015 10:38:42 +0100 Subject: Add path label for the file provided via standard input --- src/tracking/change_tracker.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/tracking/change_tracker.cc b/src/tracking/change_tracker.cc index 490d7cb..92be10c 100644 --- a/src/tracking/change_tracker.cc +++ b/src/tracking/change_tracker.cc @@ -20,6 +20,11 @@ boost::process::context getDefaultContext() { return context; } +std::string getDiffCommand( + const std::string& diff_cmd, const std::string& full_path) { + return diff_cmd + " --label " + full_path + " - " + full_path; +} + } namespace tracking { @@ -73,11 +78,15 @@ bool ChangeTracker::is_tracked(const std::string& file_path) const { // file provided if the second file argument is standard input // bool ChangeTracker::track(const std::string& file_path) { + const std::string full_file_path{ + boost::filesystem::canonical(file_path).string() + }; + auto result = this->children_.emplace( - boost::filesystem::canonical(file_path).string(), + full_file_path, std::make_unique( boost::process::launch_shell( - this->diff_cmd_ + " - " + file_path, + getDiffCommand(this->diff_cmd_, full_file_path), getDefaultContext() ) ) -- cgit v1.2.3