From: Chuck Hagenbuch Date: Sun, 28 Nov 2010 03:54:26 +0000 (-0500) Subject: Fix showing diffs for adding files on the first revision in the repository X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=5ebbaff61d90eb2696621881757fd8376d78ec65;p=horde.git Fix showing diffs for adding files on the first revision in the repository --- 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; }