From 5ebbaff61d90eb2696621881757fd8376d78ec65 Mon Sep 17 00:00:00 2001 From: Chuck Hagenbuch Date: Sat, 27 Nov 2010 22:54:26 -0500 Subject: [PATCH] Fix showing diffs for adding files on the first revision in the repository --- framework/Vcs/lib/Horde/Vcs.php | 3 +-- framework/Vcs/lib/Horde/Vcs/Git.php | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/framework/Vcs/lib/Horde/Vcs.php b/framework/Vcs/lib/Horde/Vcs.php index 22c49552e..3ac0eff76 100644 --- a/framework/Vcs/lib/Horde/Vcs.php +++ b/framework/Vcs/lib/Horde/Vcs.php @@ -261,8 +261,7 @@ class Horde_Vcs 'ws' => true ), $opts); - $this->assertValidRevision($rev1); - $this->assertValidRevision($rev2); + if ($rev1) { $this->assertValidRevision($rev1); } $diff = $this->_diff($file, $rev1, $rev2, $opts); return empty($opts['human']) diff --git a/framework/Vcs/lib/Horde/Vcs/Git.php b/framework/Vcs/lib/Horde/Vcs/Git.php index b57ec1d1f..543e9df67 100644 --- a/framework/Vcs/lib/Horde/Vcs/Git.php +++ b/framework/Vcs/lib/Horde/Vcs/Git.php @@ -260,18 +260,21 @@ class Horde_Vcs_Git extends Horde_Vcs $flags .= ' -b -w '; } - switch ($opts['type']) { - case 'unified': - $flags .= '--unified=' . escapeshellarg((int)$opts['num']); - break; - } + if (!$rev1) { + $command = $this->getCommand() . ' show --oneline ' . escapeshellarg($rev2) . ' -- ' . escapeshellarg($file->queryModulePath()) . ' 2>&1'; + } else { + switch ($opts['type']) { + case 'unified': + $flags .= '--unified=' . escapeshellarg((int)$opts['num']); + break; + } - // @TODO: add options for $hr options - however these may not - // be compatible with some diffs. - $command = $this->getCommand() . ' diff -M -C ' . $flags . ' --no-color ' . escapeshellarg($rev1 . '..' . $rev2) . ' -- ' . escapeshellarg($file->queryModulePath()) . ' 2>&1'; + // @TODO: add options for $hr options - however these may not + // be compatible with some diffs. + $command = $this->getCommand() . ' diff -M -C ' . $flags . ' --no-color ' . escapeshellarg($rev1 . '..' . $rev2) . ' -- ' . escapeshellarg($file->queryModulePath()) . ' 2>&1'; + } exec($command, $diff, $retval); - return $diff; } -- 2.11.0