From 7779d469204ac8c83a60e5702142d79da7993380 Mon Sep 17 00:00:00 2001 From: Tommaso Cucinotta Date: Sun, 7 Apr 2013 23:52:39 +0100 Subject: [PATCH] Replacing git status --porcelain along with output parsing, with a simple git ls-files. git ls-files tells me straight whether or not a file-name is in the repo. I cannot say the same of git status --porcelain. See also discussion at: http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg177840.html --- src/VCBackend.cpp | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/src/VCBackend.cpp b/src/VCBackend.cpp index e3cfed3404..cec36fce06 100644 --- a/src/VCBackend.cpp +++ b/src/VCBackend.cpp @@ -1833,32 +1833,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(); -- 2.39.5