diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/models/repository.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb index 414b82516bc..83605982933 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -1040,7 +1040,11 @@ class Repository raise CommitError.new('Failed to create commit') end - oldrev = rugged.lookup(newrev).parent_ids.first || Gitlab::Git::BLANK_SHA + if rugged.lookup(newrev).parent_ids.empty? || target_branch.nil? + oldrev = Gitlab::Git::BLANK_SHA + else + oldrev = rugged.merge_base(newrev, target_branch.target.sha) + end GitHooksService.new.execute(current_user, path_to_repo, oldrev, newrev, ref) do update_ref!(ref, newrev, oldrev) |