Skip to content

Commit 6a9db96

Browse files
author
scott Chacon
committed
fixed issue with running a 'git log' with an object that won't rev-parse (file)
1 parent 07ebb95 commit 6a9db96

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

camping/gitweb.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,7 @@ def get repo_id, sha
116116
class Tree < R '/tree/(\d+)/(\w+)'
117117
def get repo_id, sha
118118
@repo = Repository.find repo_id
119-
logger = Logger.new('/tmp/git.log')
120-
logger.level = Logger::INFO
121-
122-
@git = Git.bare(@repo.path, :log => logger)
119+
@git = Git.bare(@repo.path)
123120
@tree = @git.gtree(sha)
124121
render :tree
125122
end
@@ -128,7 +125,10 @@ def get repo_id, sha
128125
class Blob < R '/blob/(\d+)/(.*?)/(\w+)'
129126
def get repo_id, file, sha
130127
@repo = Repository.find repo_id
131-
@git = Git.bare(@repo.path)
128+
logger = Logger.new('/tmp/git.log')
129+
logger.level = Logger::INFO
130+
131+
@git = Git.bare(@repo.path, :log => logger)
132132
@blob = @git.gblob(sha)
133133
@file = file
134134
render :blob

lib/git/lib.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,10 @@ def full_log_commits(opts = {})
8181
sha = revparse(opts[:object] || branch_current || 'master')
8282
count = opts[:count] || 30
8383

84-
repo = get_raw_repo
85-
return process_commit_data(repo.log(sha, count))
84+
if /\w{40}/.match(sha) # valid sha
85+
repo = get_raw_repo
86+
return process_commit_data(repo.log(sha, count))
87+
end
8688
end
8789

8890
arr_opts = ['--pretty=raw']

tests/units/test_log.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
#!/usr/bin/env ruby
2-
2+
require 'logger'
33
require File.dirname(__FILE__) + '/../test_helper'
44

55
class TestLog < Test::Unit::TestCase
66
def setup
77
set_file_paths
8+
#@git = Git.open(@wdir, :log => Logger.new(STDOUT))
89
@git = Git.open(@wdir)
910
end
1011

tests/units/test_raw_internals.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ def test_packed_log
2222
end
2323

2424
def test_commit_object
25-
g = Git.bare(@wbare, :log => Logger.new(STDOUT))
26-
25+
g = Git.bare(@wbare)
2726
c = g.gcommit("v2.5")
2827
assert_equal('test', c.message)
2928
end
@@ -34,7 +33,7 @@ def test_lstree
3433
sha = c.sha
3534

3635
repo = Git::Raw::Repository.new(@wbare)
37-
puts repo.object(sha).inspect
36+
assert_equal('ex_dir', repo.object(sha).entry.first.name)
3837
end
3938

4039
def t_log(g)

0 commit comments

Comments
 (0)