+bool GIT::getFileRevisionInfo()
+{
+ TempFile tempfile("lyxvcout");
+ FileName tmpf = tempfile.name();
+ if (tmpf.empty()) {
+ LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
+ return false;
+ }
+
+ doVCCommand("git log -n 1 --pretty=format:%H%n%an%n%ai " + quoteName(onlyFileName(owner_->absFileName()))
+ + " > " + quoteName(tmpf.toFilesystemEncoding()),
+ FileName(owner_->filePath()));
+
+ if (tmpf.empty())
+ return false;
+
+ ifstream ifs(tmpf.toFilesystemEncoding().c_str());
+
+ if (ifs)
+ getline(ifs, rev_file_cache_);
+ if (ifs)
+ getline(ifs, rev_author_cache_);
+ if (ifs) {
+ string line;
+ getline(ifs, line);
+ rev_time_cache_ = split(line, rev_date_cache_, ' ');
+ }
+
+ ifs.close();
+ return !rev_file_cache_.empty();
+}
+
+
+bool GIT::getTreeRevisionInfo()
+{
+ TempFile tempfile("lyxvcout");
+ FileName tmpf = tempfile.name();
+ if (tmpf.empty()) {
+ LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
+ return false;
+ }
+
+ doVCCommand("git describe --abbrev --dirty --long > " + quoteName(tmpf.toFilesystemEncoding()),
+ FileName(owner_->filePath()));
+
+ if (tmpf.empty())
+ return false;
+
+ // only first line in case something bad happens.
+ ifstream ifs(tmpf.toFilesystemEncoding().c_str());
+ getline(ifs, rev_tree_cache_);
+ ifs.close();
+
+ return !rev_tree_cache_.empty();
+}
+
+