Skip to content

Commit fe90056

Browse files
committed
Fixed Commit::getLastModification
If we use gitlib (located in /a/b/gitlib) and try to inspect a project located in /a/b ; Gitlib will not be able to get the log since it run a command like: git log --working-dir /a/b/.git --working-tree /a/b log --format=%H -n 1 THEHASH -- PATH so PATH does not exist in /a/b/gitlib/ (ie /a/b/gitlib/PATH). so the command fails. So i fixed it by preprend the working-dir. Note: I think we should update all commands that use a path in arguments. ping @alexandresalome
1 parent aeca742 commit fe90056

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Gitonomy/Git/Commit.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,11 @@ public function getTree()
260260
*/
261261
public function getLastModification($path)
262262
{
263-
if (preg_match('#^/#', $path)) {
263+
if (0 === strpos($path, '/')) {
264264
$path = StringHelper::substr($path, 1);
265265
}
266266

267+
$path = $this->repository->getWorkingDir().'/'.$path;
267268
$result = $this->repository->run('log', array('--format=%H', '-n', 1, $this->hash, '--', $path));
268269

269270
return $this->repository->getCommit(trim($result));

0 commit comments

Comments
 (0)