]> git.lyx.org Git - lyx.git/commitdiff
Now LyX correctly asks to retrieve non-existing file from GIT repo only if the file...
authorTommaso Cucinotta <tommaso@lyx.org>
Sat, 6 Apr 2013 15:12:06 +0000 (16:12 +0100)
committerTommaso Cucinotta <tommaso@lyx.org>
Sat, 6 Apr 2013 15:12:06 +0000 (16:12 +0100)
See also discussion at: http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg177840.html

src/VCBackend.cpp

index 753bd63890cb119e7545f1c66f5fc922b82221b3..72148f728321d7deb6158b6f080b74364104c63e 100644 (file)
@@ -1844,15 +1844,20 @@ FileName const GIT::findFile(FileName const & file)
                        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.
-               ifstream ifs(tmpf.toFilesystemEncoding().c_str());
-               string test;
-               if ((ifs >> test))
-                       found = (test != "??");
-               // else is no error
+               if (tmpf.isFileEmpty())
+                       found = false;
+               else {
+                       ifstream ifs(tmpf.toFilesystemEncoding().c_str());
+                       string test;
+                       if ((ifs >> test))
+                               found = (test != "??");
+                       // else is no error
+               }
        }
        tmpf.removeFile();
        LYXERR(Debug::LYXVC, "GIT control: " << (found ? "enabled" : "disabled"));