On 10/04/13 00:26, Nico Williams wrote: >> But again, git ls-files seems WAY EASIER. > > This will tell you if a file is tracked, not whether it has unstaged > or uncommitted changes.
Ok, let me be sure of one thing: the usage scenario I got into, is one in which one opens a file-name with LyX: lyx /path/to/name.lyx then, in case the file-name does not exist on the local FS, LyX makes the following (LyXVC.cpp) call *::findFile(), to understand whether a file can be checked out if (foundRCS || foundCVS || foundSVN || foundGIT) { // PROMPT USER if (user agrees) { if (foundRCS) return RCS::retrieve(fn); else if (foundCVS) return CVS::retrieve(fn); else if (foundSVN) return SVN::retrieve(fn); else return GIT::retrieve(fn); } } So, this is very simple, seems VC-independent, and prevents the user from creating new files that can already be checked out. Does anyone see glitches in the behaviour, or thinks it should be changed or improved ? AFAICS, Nico's request might imply a preference option for not even having the question bothering the user. Equivalently, enhancing the question dialog with a checkbox (assume always this answer from now on). Considering a little refactoring, findFile() returns a FileName that doesn't seem very useful: $ find . -name '*.cpp' -exec grep -Hn findFile {} \; ./src/LyXVC.cpp:50: if (!RCS::findFile(fn).empty()) ./src/LyXVC.cpp:52: if (!CVS::findFile(fn).empty()) ./src/LyXVC.cpp:54: if (!SVN::findFile(fn).empty()) ./src/LyXVC.cpp:56: if (!GIT::findFile(fn).empty()) ./src/LyXVC.cpp:66: if (!(found_file = RCS::findFile(fn)).empty()) { ./src/LyXVC.cpp:71: if (!(found_file = CVS::findFile(fn)).empty()) { ./src/LyXVC.cpp:76: if (!(found_file = SVN::findFile(fn)).empty()) { ./src/LyXVC.cpp:81: if (!(found_file = GIT::findFile(fn)).empty()) { ./src/LyXVC.cpp:97: bool foundRCS = !RCS::findFile(fn).empty(); ./src/LyXVC.cpp:98: bool foundCVS = foundRCS ? false : !CVS::findFile(fn).empty(); ./src/LyXVC.cpp:99: bool foundSVN = (foundRCS || foundCVS) ? false : !SVN::findFile(fn).empty(); ./src/LyXVC.cpp:100: bool foundGIT = (foundRCS || foundCVS || foundSVN) ? false : !GIT::findFile(fn).empty(); ./src/VCBackend.cpp:132:FileName const RCS::findFile(FileName const & file) ./src/VCBackend.cpp:524:FileName const CVS::findFile(FileName const & file) ./src/VCBackend.cpp:1151:FileName const SVN::findFile(FileName const & file) ./src/VCBackend.cpp:1821:FileName const GIT::findFile(FileName const & file) So, what about turning that return value into a Boolean ? (I provide the fname as input, what fname would I expect as output ?) T.