From: Goetz Pfeiffer <Goetz.Pfeiffer@helmholtz-berlin.de>
Date: 1452530217 +0100
Subject: Bugfix: A misconfiguration could update the wrong git working copy.
A function in git.py checked the validity of a git repository by testing
whether the path of the working copy existed. If it did, it called "git
status" to see if the repository was valid. However, if the path existed but
had no ".git" directory in it, "git status" would look in directories further
up the directory hierarchy. If it found a git repository somewhere on the way
it would work on this repository.
In the end this could cause git.valid() returning True where it shouldn't.
Other parts of the source builder then executed "git reset --hard" on the
wrong local repository.
Now the program checks first if a directory ".git" in the given path exists,
and only then tries to execute "git status".
diff -r b18eca73b9d1 -r fe308cb64dde source-builder/sb/git.py
a
|
b
|
|
144 | 144 | return not (len(_status) == 1 and 'branch' in _status) |
145 | 145 | |
146 | 146 | def valid(self): |
147 | | if path.exists(self.path): |
| 147 | # If self.path exists, but self.path+"/.git" does not, git looks for |
| 148 | # the first ".git" directory further up the hierarchy. This is |
| 149 | # definitely not what we want git to do, so we check for the existence |
| 150 | # for self.path+"/.git" and not just self.path: |
| 151 | if path.exists(os.path.join(self.path, ".git")): |
148 | 152 | ec, output = self._run(['status']) |
149 | 153 | return ec == 0 |
150 | 154 | return False |