/** * openBranch opens and locks the branch for other writing * * @return GitCommit the head commit of the branch or null if empty branch * @author The Young Shepherd **/ public function setTip(GitCommit $commit) { $fBranch = fopen(sprintf('%s/refs/heads/%s', $this->git->getDir(), $this->branchName), 'a+b'); flock($fBranch, LOCK_EX); $commit->write(); ftruncate($fBranch, 0); fwrite($fBranch, $commit->getSha()->hex()); fclose($fBranch); $this->tipCache = $commit; }