using namespace lyx::support;
-
namespace lyx {
}
-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;
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();