From: Arvin Schnell Date: Wed, 3 Aug 2011 12:25:22 +0000 (+0200) Subject: - show absolute path in diff output X-Git-Tag: v0.1.3~321 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=83a664f8cceacf602fc3a7e147b283170689e92f;p=thirdparty%2Fsnapper.git - show absolute path in diff output --- diff --git a/LIBVERSION b/LIBVERSION index 9084fa2f..26aaba0e 100644 --- a/LIBVERSION +++ b/LIBVERSION @@ -1 +1 @@ -1.1.0 +1.2.0 diff --git a/snapper/File.cc b/snapper/File.cc index da205120..1cbf0be8 100644 --- a/snapper/File.cc +++ b/snapper/File.cc @@ -26,6 +26,7 @@ #include #include #include +#include #include "snapper/File.h" #include "snapper/Snapper.h" @@ -311,6 +312,26 @@ namespace snapper } + Files::iterator + Files::findAbsolutePath(const string& filename) + { + if (!boost::starts_with(filename, getSnapper()->subvolumeDir())) + return end(); + + return find(string(filename, getSnapper()->subvolumeDir().size())); + } + + + Files::const_iterator + Files::findAbsolutePath(const string& filename) const + { + if (!boost::starts_with(filename, getSnapper()->subvolumeDir())) + return end(); + + return find(string(filename, getSnapper()->subvolumeDir().size())); + } + + unsigned int File::getPreToSystemStatus() { diff --git a/snapper/File.h b/snapper/File.h index cda5da0e..ce37c6e6 100644 --- a/snapper/File.h +++ b/snapper/File.h @@ -163,6 +163,9 @@ namespace snapper iterator find(const string& name); const_iterator find(const string& name) const; + iterator findAbsolutePath(const string& name); + const_iterator findAbsolutePath(const string& name) const; + private: void initialize(); diff --git a/tools/snapper.cc b/tools/snapper.cc index eea1100c..2069e631 100644 --- a/tools/snapper.cc +++ b/tools/snapper.cc @@ -568,7 +568,7 @@ command_diff() if ((opt = opts.find("file")) != opts.end()) { - tmp = files.find(opt->second); + tmp = files.findAbsolutePath(opt->second); if (tmp == files.end()) { cerr << sformat(_("File '%s' not included in diff."), opt->second.c_str()) << endl; @@ -591,7 +591,8 @@ command_diff() if (tmp == files.end()) { for (Files::const_iterator it = files.begin(); it != files.end(); ++it) - fprintf(file, "%s %s\n", statusToString(it->getPreToPostStatus()).c_str(), it->getName().c_str()); + fprintf(file, "%s %s\n", statusToString(it->getPreToPostStatus()).c_str(), + it->getAbsolutePath(LOC_SYSTEM).c_str()); } else { @@ -675,7 +676,7 @@ command_rollback() name.erase(0, pos + 1); } - Files::iterator it = files.find(name); + Files::iterator it = files.findAbsolutePath(name); if (it == files.end()) { cerr << sformat(_("File '%s' not found in diff."), name.c_str()) << endl;