summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorscott Chacon <schacon@agadorsparticus.(none)>2007-11-27 08:21:28 -0800
committerscott Chacon <schacon@agadorsparticus.(none)>2007-11-27 08:21:28 -0800
commit6a9db968e8563bc27b8f56f9d413159a2e14cf67 (patch)
tree5094084caae36283763eba7a1965f93ad159608a
parent07ebb951368ed31bdaebc2e820c62ced22c8bbe4 (diff)
downloadthird_party-ruby-git-6a9db968e8563bc27b8f56f9d413159a2e14cf67.zip
third_party-ruby-git-6a9db968e8563bc27b8f56f9d413159a2e14cf67.tar.gz
third_party-ruby-git-6a9db968e8563bc27b8f56f9d413159a2e14cf67.tar.xz
fixed issue with running a 'git log' with an object that won't rev-parse (file)
-rw-r--r--camping/gitweb.rb10
-rw-r--r--lib/git/lib.rb6
-rw-r--r--tests/units/test_log.rb3
-rw-r--r--tests/units/test_raw_internals.rb5
4 files changed, 13 insertions, 11 deletions
diff --git a/camping/gitweb.rb b/camping/gitweb.rb
index 3d1b5d6..29a4ab3 100644
--- a/camping/gitweb.rb
+++ b/camping/gitweb.rb
@@ -116,10 +116,7 @@ module GitWeb::Controllers
class Tree < R '/tree/(\d+)/(\w+)'
def get repo_id, sha
@repo = Repository.find repo_id
- logger = Logger.new('/tmp/git.log')
- logger.level = Logger::INFO
-
- @git = Git.bare(@repo.path, :log => logger)
+ @git = Git.bare(@repo.path)
@tree = @git.gtree(sha)
render :tree
end
@@ -128,7 +125,10 @@ module GitWeb::Controllers
class Blob < R '/blob/(\d+)/(.*?)/(\w+)'
def get repo_id, file, sha
@repo = Repository.find repo_id
- @git = Git.bare(@repo.path)
+ logger = Logger.new('/tmp/git.log')
+ logger.level = Logger::INFO
+
+ @git = Git.bare(@repo.path, :log => logger)
@blob = @git.gblob(sha)
@file = file
render :blob
diff --git a/lib/git/lib.rb b/lib/git/lib.rb
index decd6d4..cd24fca 100644
--- a/lib/git/lib.rb
+++ b/lib/git/lib.rb
@@ -81,8 +81,10 @@ module Git
sha = revparse(opts[:object] || branch_current || 'master')
count = opts[:count] || 30
- repo = get_raw_repo
- return process_commit_data(repo.log(sha, count))
+ if /\w{40}/.match(sha) # valid sha
+ repo = get_raw_repo
+ return process_commit_data(repo.log(sha, count))
+ end
end
arr_opts = ['--pretty=raw']
diff --git a/tests/units/test_log.rb b/tests/units/test_log.rb
index 11dcb27..7bcd83b 100644
--- a/tests/units/test_log.rb
+++ b/tests/units/test_log.rb
@@ -1,10 +1,11 @@
#!/usr/bin/env ruby
-
+require 'logger'
require File.dirname(__FILE__) + '/../test_helper'
class TestLog < Test::Unit::TestCase
def setup
set_file_paths
+ #@git = Git.open(@wdir, :log => Logger.new(STDOUT))
@git = Git.open(@wdir)
end
diff --git a/tests/units/test_raw_internals.rb b/tests/units/test_raw_internals.rb
index 03a7916..b37a66d 100644
--- a/tests/units/test_raw_internals.rb
+++ b/tests/units/test_raw_internals.rb
@@ -22,8 +22,7 @@ class TestRawInternals < Test::Unit::TestCase
end
def test_commit_object
- g = Git.bare(@wbare, :log => Logger.new(STDOUT))
-
+ g = Git.bare(@wbare)
c = g.gcommit("v2.5")
assert_equal('test', c.message)
end
@@ -34,7 +33,7 @@ class TestRawInternals < Test::Unit::TestCase
sha = c.sha
repo = Git::Raw::Repository.new(@wbare)
- puts repo.object(sha).inspect
+ assert_equal('ex_dir', repo.object(sha).entry.first.name)
end
def t_log(g)