Branch could be nil if it's an empty repo

This commit is contained in:
Lin Jen-Shin 2016-11-15 06:55:54 +08:00
parent 30bcc3de41
commit 5de74551ac
1 changed files with 8 additions and 3 deletions

View File

@ -901,10 +901,15 @@ class Repository
branch,
source_branch: source_branch) do |ref|
index = rugged.index
branch_commit = find_branch(ref)
last_commit = find_branch(ref).dereferenced_target
index.read_tree(last_commit.raw_commit.tree)
parents = [last_commit.sha]
parents = if branch_commit
last_commit = branch_commit.dereferenced_target
index.read_tree(last_commit.raw_commit.tree)
[last_commit.sha]
else
[]
end
actions.each do |action|
case action[:action]