Skip to content

Commit

Permalink
Set worktree for git parser
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanDotPro committed May 24, 2012
1 parent 5772e7b commit 4462e63
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/EdpGit/Parser.php
Expand Up @@ -24,6 +24,13 @@ class Parser
*/
protected $projectPath;

/**
* workTree
*
* @var string
*/
protected $workTree;

/**
* construct
*
Expand All @@ -45,7 +52,7 @@ public function __construct($projectPath)
public function run($command, $projectPath = false)
{
$projectPath = $projectPath ?: $this->getProjectPath();
$cmd = $this->getGitPath() . ' --git-dir=' . escapeshellarg($projectPath) . ' ' . $command;
$cmd = $this->getGitPath() . ' --git-dir=' . escapeshellarg($projectPath) . ' --work-tree=' . escapeshellarg($this->workTree) . ' ' .$command;
$output = `$cmd`;
return trim($output);
}
Expand Down Expand Up @@ -96,6 +103,7 @@ public function setProjectPath($projectPath)
throw new Exception('Given path not a valid git repository: '.$realProjectPath);
}
$this->projectPath = $realProjectPath;
$this->workTree = realpath($projectPath);
return $this;
}

Expand Down

0 comments on commit 4462e63

Please sign in to comment.