From 484c72679abc0827a0fdb568fe835d22df479eb0 Mon Sep 17 00:00:00 2001 From: Klaus Silveira Date: Thu, 7 Jun 2012 02:32:30 -0300 Subject: [PATCH] Better filename handling in commit logs, fixes #35 --- lib/Git/Model/Diff.php | 6 +++++- lib/Git/Repository.php | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/Git/Model/Diff.php b/lib/Git/Model/Diff.php index 17fa0e6..f20abb0 100644 --- a/lib/Git/Model/Diff.php +++ b/lib/Git/Model/Diff.php @@ -45,7 +45,6 @@ class Diff public function setNew($new) { $this->new = $new; - $this->file = substr($new, 6); } public function getNew() @@ -53,6 +52,11 @@ class Diff return $this->new; } + public function setFile($file) + { + $this->file = $file; + } + public function getFile() { return $this->file; diff --git a/lib/Git/Repository.php b/lib/Git/Repository.php index ec7d64d..de453c4 100644 --- a/lib/Git/Repository.php +++ b/lib/Git/Repository.php @@ -341,6 +341,8 @@ class Repository } $diff = new Diff; + preg_match('/^diff --[\S]+ (a\/)?([\S]+)( b\/)?/', $log, $name); + $diff->setFile($name[2]); continue; }