aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Kummerlaender2015-12-24 10:38:42 +0100
committerAdrian Kummerlaender2015-12-24 10:38:42 +0100
commita8157a2acf5ac23e58aa18fe3ddf855341790d5f (patch)
tree9a85f2d06edd94cee49ddde3c84143269295d0b4
parent50e1bb1a194c06ed0110bd13b5cca769a38c4157 (diff)
downloadchange-a8157a2acf5ac23e58aa18fe3ddf855341790d5f.tar
change-a8157a2acf5ac23e58aa18fe3ddf855341790d5f.tar.gz
change-a8157a2acf5ac23e58aa18fe3ddf855341790d5f.tar.bz2
change-a8157a2acf5ac23e58aa18fe3ddf855341790d5f.tar.lz
change-a8157a2acf5ac23e58aa18fe3ddf855341790d5f.tar.xz
change-a8157a2acf5ac23e58aa18fe3ddf855341790d5f.tar.zst
change-a8157a2acf5ac23e58aa18fe3ddf855341790d5f.zip
Add path label for the file provided via standard input
-rw-r--r--src/tracking/change_tracker.cc13
1 files changed, 11 insertions, 2 deletions
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::child>(
boost::process::launch_shell(
- this->diff_cmd_ + " - " + file_path,
+ getDiffCommand(this->diff_cmd_, full_file_path),
getDefaultContext()
)
)