]> git.lyx.org Git - lyx.git/blobdiff - src/VCBackend.cpp
installer: further preparation
[lyx.git] / src / VCBackend.cpp
index 5ab61630d3f250ef924f3dfdf7515912d9476679..96b71d81ea32480fcd5c727a051264d1f22bc5ea 100644 (file)
@@ -34,7 +34,6 @@ using namespace std;
 using namespace lyx::support;
 
 
-
 namespace lyx {
 
 
@@ -99,23 +98,21 @@ 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();
-       FileName tocheck = FileName(addName(dirname.absFileName(),pathname));
-       LYXERR(Debug::LYXVC, "check file: " << tocheck.absFileName());
-       bool result = tocheck.exists();
-       while ( !result && !dirname.empty() ) {
+       do {
+               FileName tocheck = FileName(addName(dirname.absFileName(), vcsdir));
+               LYXERR(Debug::LYXVC, "check file: " << tocheck.absFileName());
+               if (tocheck.exists())
+                       return true;
                //this construct because of #8295
                dirname = FileName(dirname.absFileName()).parentPath();
-               LYXERR(Debug::LYXVC, "check directory: " << dirname.absFileName());
-               tocheck = FileName(addName(dirname.absFileName(),pathname));
-               result = tocheck.exists();
-       }
-       return result;
+       } while (!dirname.empty());
+       return false;
 }
 
-       
+
 /////////////////////////////////////////////////////////////////////
 //
 // RCS
@@ -1835,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();