X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FVCBackend.cpp;h=96b71d81ea32480fcd5c727a051264d1f22bc5ea;hb=4db3e641ed6765e005343010cb90ee8af26f8f99;hp=e3cfed340446f590b2b2c816bc4ecc7d6b6b4464;hpb=34dfe2d71e146a5300235df0a51b261a3dc5a09b;p=lyx.git diff --git a/src/VCBackend.cpp b/src/VCBackend.cpp index e3cfed3404..96b71d81ea 100644 --- a/src/VCBackend.cpp +++ b/src/VCBackend.cpp @@ -34,7 +34,6 @@ using namespace std; using namespace lyx::support; - namespace lyx { @@ -99,11 +98,11 @@ bool VCS::makeRCSRevision(string const &version, string &revis) const } -bool VCS::checkparentdirs(FileName const & file, std::string const & pathname) +bool VCS::checkparentdirs(FileName const & file, std::string const & vcsdir) { FileName dirname = file.onlyPath(); do { - FileName tocheck = FileName(addName(dirname.absFileName(), pathname)); + FileName tocheck = FileName(addName(dirname.absFileName(), vcsdir)); LYXERR(Debug::LYXVC, "check file: " << tocheck.absFileName()); if (tocheck.exists()) return true; @@ -1833,32 +1832,14 @@ FileName const GIT::findFile(FileName const & file) return FileName(); } - // --porcelain selects a format that is supposed to be stable across - // git versions string const fname = onlyFileName(file.absFileName()); LYXERR(Debug::LYXVC, "LyXVC: Checking if file is under git control for `" << fname << '\''); - bool found = 0 == doVCCommandCall("git status --porcelain " + - quoteName(fname) + " > " + - quoteName(tmpf.toFilesystemEncoding()), + doVCCommandCall("git ls-files " + + quoteName(fname) + " > " + + quoteName(tmpf.toFilesystemEncoding()), file.onlyPath()); - if (found) - { - // The output is empty for file names NOT in repo. - // The output contains a line starting with "??" for unknown - // files, no line for known unmodified files and a line - // starting with "M" or something else for modified/deleted - // etc. files. - if (tmpf.isFileEmpty()) - found = false; - else { - ifstream ifs(tmpf.toFilesystemEncoding().c_str()); - string test; - if ((ifs >> test)) - found = (test != "??"); - // else is no error - } - } + bool found = !tmpf.isFileEmpty(); tmpf.removeFile(); LYXERR(Debug::LYXVC, "GIT control: " << (found ? "enabled" : "disabled")); return found ? file : FileName();