Tommaso Cucinotta wrote:

> Hi,
> 
> I just noticed that GIT::findFile() doesn't seem to work, namely if I open
> with git any file within the lyx sources tree, it always asks me whether I
> want to retrieve the file from the VCS (which in turn causes all test
> cases in autotests to fail, but it's unimportant now).
> 
> I noticed the code was trying to parse the output of
> 
>   git status --porcelain <filename>
> 
> However, such command on my laptop (Ubuntu 12.10, git version 1.7.10.4)
> doesn't really help in figuring out whether the file is under version
> control [1].

I tried this command again and noticed that it does indeed not work for 
nonexisting files. The ?? lines are only output if the file exists locally.

> Searching around and with some help from StackOverflow, I found this
> alternative solution that seems better:
> 
>   git ls-files <filename> --error-unmatch
> 
> which causes an error code if filename is not under version control, plus
> it causes non-null stdout only if filename is under version control [2].
> 
> So, I came up with the attached fix, which fixes the issue on my system.

Looks good. I would however hide stderr, since it will output something in 
case a file does not exist in git, but this is not an error here. Do you 
know whether this behaviour (output something on stdout only if the file is 
know) is as stable as the --porcelain optin for other commands?


Georg

Reply via email to