<div dir="ltr"><div>Sir, </div><div><br></div><div>I have made the changes suggested by you in the code and hopefully, the issue will be resolved as if the .git file is not found in the directory, the process will not go ahead and hence the wrong git repository will not be changed.</div><div>I request to please guide me whether anything more is to be done in the code or should I proceed with a pull request.</div><div><br></div><div>Thanks and Regards </div><div>Abhinav Jain</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Feb 19, 2018 at 3:10 AM, Chris Johns <span dir="ltr"><<a href="mailto:chrisj@rtems.org" target="_blank">chrisj@rtems.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Abhinav<br>
<br>
I have broken the mail thread as we have switched from contributing to the<br>
project to a specific fix.<br>
<br>
> I have gone through the code concerning the issue raised. I also read about the<br>
> working of git status command and the problem that I am able to figure out is<br>
> that although the existing code is able to check whether the current path exists<br>
> or not but since it is relying on git status to check whether the .git file is<br>
> available or not, a problem is there. The git status checks the current<br>
> directory for the .git file but in case the current directory doesn't have the<br>
> .git file, it will look for it in the parent directory and if found there it<br>
> will return True, which voids the purpose.<br>
> So, I think, if a second check is given to validate whether the current<br>
> directory contains .git file or not will solve the issue.<br>
> So the code may be:<br>
> def valid(self):<br>
>         if path.exists(self.path):<br>
> if path.exists(path.join(self.<wbr>path, ".git")):<br>
>            ec, output = self._run(['status'])<br>
>            return ec == 0<br>
>         return False<br>
> I request you to please guide me whether I proceeded in a right way or not.<br>
<br>
I am a little confused by the situation that leads to this happening. If the RSB<br>
is being run from a git repo and the build references a git repo the RSB will<br>
clone and update the repo so a 'valid' check to repo within the RSB's clone<br>
should not fail. This is happening because it has been working for a long time.<br>
I can see this happening if someone plays the source/git tree of files or maybe<br>
a clone failed for some reason and a directory is left. Maybe git does that.<br>
<br>
To make things more robust a check for the .git directory makes sense. There is<br>
no need to check the path twice, a single check is all that is needed. I suggest<br>
a new function be added to the class call '_valid_repo_path' which is:<br>
<br>
    def _valid_repo_path(self):<br>
        return path.exists(path.join(self.<wbr>path, '.git')<br>
<br>
and all 'path.exists(self.path)' in the class be replaced by this call.<br>
<br>
Thanks<br>
<span class="HOEnZb"><font color="#888888">Chris<br>
</font></span></blockquote></div><br></div>