From 4f94053c21196b3445c117130e3556463e4ca1d0 Mon Sep 17 00:00:00 2001
From: Lin Jen-Shin <godfat@godfat.org>
Date: Thu, 8 Dec 2016 15:22:32 +0800
Subject: [PATCH] We still need it for empty repo for web UI!

We shouldn't pass a non-existing branch to source_branch.
Checkout test for:

* spec/features/tags/master_views_tags_spec.rb:24
* spec/features/projects/files/project_owner_sees_link_to_create_license_file_in_empty_project_spec.rb:13
---
 app/controllers/concerns/creates_commit.rb | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/app/controllers/concerns/creates_commit.rb b/app/controllers/concerns/creates_commit.rb
index dacb5679dd3..5d11f286e9a 100644
--- a/app/controllers/concerns/creates_commit.rb
+++ b/app/controllers/concerns/creates_commit.rb
@@ -4,9 +4,10 @@ module CreatesCommit
   def create_commit(service, success_path:, failure_path:, failure_view: nil, success_notice: nil)
     set_commit_variables
 
+    source_branch = @ref if @ref && @repository.find_branch(@ref)
     commit_params = @commit_params.merge(
       source_project: @project,
-      source_branch: @ref,
+      source_branch: source_branch,
       target_branch: @target_branch
     )
 
-- 
GitLab