summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2016-11-15 06:55:54 +0800
committerLin Jen-Shin <godfat@godfat.org>2016-11-15 06:55:54 +0800
commit5de74551ace7b6df9fdb2a3c8aa30c836d693728 (patch)
treebd40866f14929c27b735ba4d607b0cb775fcb743 /app/models
parent30bcc3de41d86e02c27940e0e8e4a1a82183520e (diff)
downloadgitlab-ce-5de74551ace7b6df9fdb2a3c8aa30c836d693728.tar.gz
Branch could be nil if it's an empty repo
Diffstat (limited to 'app/models')
-rw-r--r--app/models/repository.rb13
1 files changed, 9 insertions, 4 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 89293fa8b4d..c4bdc84348e 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -901,10 +901,15 @@ class Repository
branch,
source_branch: source_branch) do |ref|
index = rugged.index
-
- last_commit = find_branch(ref).dereferenced_target
- index.read_tree(last_commit.raw_commit.tree)
- parents = [last_commit.sha]
+ branch_commit = find_branch(ref)
+
+ 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]