8 #ifndef __STDC_FORMAT_MACROS
9 #define __STDC_FORMAT_MACROS
33 DiffReporter(
bool show_header,
bool machine_readable,
bool ignore_timediff)
34 : show_header_(show_header)
35 , machine_readable_(machine_readable)
36 , ignore_timediff_(ignore_timediff)
47 if (machine_readable_) {
49 "# line descriptor: A - add, R - remove, M - modify, "
50 "S - statistics; modify flags: S - size, M - mode, T - timestamp, "
51 "C - content, L - symlink target; entry types: F - regular file, "
52 "S - symbolic link, D - directory, N - nested catalog");
55 "DELTA: %s/r%" PRIu64
" (%s) --> %s/r%" PRIu64
" (%s)",
65 std::string operation = machine_readable_ ?
"S " :
"d(";
66 std::string type_file = machine_readable_ ?
"F" :
"# regular files):";
67 std::string type_symlink = machine_readable_ ?
"S" :
"# symlinks):";
68 std::string type_directory = machine_readable_ ?
"D" :
"# directories):";
69 std::string type_catalog = machine_readable_ ?
"N" :
"# catalogs):";
70 int64_t diff_file = delta.
self.regular_files + delta.
subtree.regular_files;
71 int64_t diff_symlink = delta.
self.symlinks + delta.
subtree.symlinks;
72 int64_t diff_catalog = delta.
self.nested_catalogs +
75 int64_t diff_directory = delta.
self.directories +
76 delta.
subtree.directories - diff_catalog;
78 type_file.c_str(), diff_file);
80 type_symlink.c_str(), diff_symlink);
82 type_directory.c_str(), diff_directory);
84 type_catalog.c_str(), diff_catalog);
88 virtual void OnAdd(
const std::string &path,
91 std::string operation = machine_readable_ ?
"A" :
"add";
92 if (machine_readable_) {
94 operation.c_str(), PrintEntryType(entry).c_str(), path.c_str());
102 path.c_str(), operation.c_str(),
103 PrintEntryType(entry).c_str(), entry.
size());
111 std::string operation = machine_readable_ ?
"R" :
"remove";
112 if (machine_readable_) {
114 operation.c_str(), PrintEntryType(entry).c_str(), path.c_str());
122 path.c_str(), operation.c_str(),
123 PrintEntryType(entry).c_str(), entry.
size());
134 if (ignore_timediff_) {
135 diff = diff & ~catalog::DirectoryEntryBase::Difference::kMtime;
140 diff = diff & ~catalog::DirectoryEntryBase::Difference::kSize;
145 std::string type_from = PrintEntryType(entry_from);
146 std::string type_to = PrintEntryType(entry_to);
147 std::string
type = type_from;
148 if (type_from != type_to) {
149 type += machine_readable_ ? type_to : (
"->" + type_to);
152 std::string operation = machine_readable_ ?
"M" :
"modify";
153 if (machine_readable_) {
155 PrintDifferences(diff).c_str(), type.c_str(), path.c_str());
158 operation.c_str(), type.c_str(), PrintDifferences(diff).c_str());
164 std::vector<std::string> result_list;
166 result_list.push_back(machine_readable_ ?
"N" :
"name");
168 result_list.push_back(machine_readable_ ?
"I" :
"link-count");
170 result_list.push_back(machine_readable_ ?
"S" :
"size");
172 result_list.push_back(machine_readable_ ?
"M" :
"mode");
174 result_list.push_back(machine_readable_ ?
"T" :
"timestamp");
176 result_list.push_back(machine_readable_ ?
"L" :
"symlink-target");
178 result_list.push_back(machine_readable_ ?
"C" :
"content");
180 result_list.push_back(machine_readable_ ?
"G" :
"hardlink-group");
184 result_list.push_back(machine_readable_ ?
"N" :
"nested-catalog");
187 result_list.push_back(machine_readable_ ?
"P" :
"chunked-file");
189 result_list.push_back(machine_readable_ ?
"X" :
"xattrs");
191 result_list.push_back(machine_readable_ ?
"E" :
"external-file");
193 result_list.push_back(machine_readable_ ?
"B" :
"bind-mountpoint");
195 result_list.push_back(machine_readable_ ?
"H" :
"hidden");
197 result_list.push_back(machine_readable_ ?
"D" :
"direct-io");
199 result_list.push_back(machine_readable_ ?
"U" :
"uid");
201 result_list.push_back(machine_readable_ ?
"R" :
"gid");
203 return machine_readable_ ? (
"[" +
JoinStrings(result_list,
"") +
"]")
208 if (entry.
IsRegular())
return machine_readable_ ?
"F" :
"file";
209 else if (entry.
IsLink())
return machine_readable_ ?
"S" :
"symlink";
210 else if (entry.
IsDirectory())
return machine_readable_ ?
"D" :
"directory";
212 return machine_readable_ ?
"U" :
"unknown";
228 if (options.
Has(
"worktree")) {
231 settings->SetIsSilent(
true);
232 settings->GetTransaction()->SetDryRun(
true);
233 settings->GetTransaction()->SetPrintChangeset(
true);
245 if (options.
Has(
"keychain")) {
250 DiffReporter diff_reporter(options.
Has(
"header"),
251 options.
Has(
"machine-readable"),
252 options.
Has(
"ignore-timediff"));
253 repository.Diff(from, to, &diff_reporter);
SettingsKeychain * GetKeychain()
static const unsigned int kHardlinkGroup
Differences CompareTo(const DirectoryEntry &other) const
std::string GetStringDefault(const std::string &key, const std::string &default_value) const
static const unsigned int kHiddenFlag
SettingsPublisher * CreateSettingsPublisher(const std::string &ident, bool needs_managed=false)
virtual void OnModify(const std::string &path, const catalog::DirectoryEntry &entry_from, const catalog::DirectoryEntry &entry_to)
virtual void OnAdd(const std::string &path, const catalog::DirectoryEntry &entry)
static const unsigned int kChecksum
void SetKeychainDir(const std::string &keychain_dir)
bool Has(const std::string &key) const
std::string GetString(const std::string &key) const
DiffReporter(bool show_header, bool machine_readable, bool ignore_timediff)
string JoinStrings(const vector< string > &strings, const string &joint)
static const unsigned int kGid
const SettingsPublisher & settings() const
static const unsigned int kDirectIoFlag
std::string PrintDifferences(catalog::DirectoryEntryBase::Differences diff)
const std::vector< Argument > & plain_args() const
virtual void OnInit(const history::History::Tag &from_tag, const history::History::Tag &to_tag)
string StringifyTime(const time_t seconds, const bool utc)
Repository(const SettingsRepository &settings, const bool exists=true)
static const unsigned int kExternalFileFlag
static const unsigned int kHasXattrsFlag
static const unsigned int kName
SettingsRepository CreateSettingsRepository(const std::string &ident)
virtual void OnStats(const catalog::DeltaCounters &delta)
static const unsigned int kNestedCatalogTransitionFlags
static const unsigned int kLinkcount
static const unsigned int kMtime
virtual int Main(const Options &options)
static const unsigned int kChunkedFileFlag
static const unsigned int kSymlink
static const unsigned int kSize
static const unsigned int kMode
Publisher(const SettingsPublisher &settings, const bool exists=true)
static const unsigned int kBindMountpointFlag
std::string PrintEntryType(const catalog::DirectoryEntry &entry)
virtual void OnRemove(const std::string &path, const catalog::DirectoryEntry &entry)
static const unsigned int kUid
CVMFS_EXPORT void LogCvmfs(const LogSource source, const int mask, const char *format,...)