From e76173038b03c660a498d9f38b07797b453f1e7f Mon Sep 17 00:00:00 2001
From: Lin Jen-Shin <godfat@godfat.org>
Date: Thu, 8 Dec 2016 01:13:16 +0800
Subject: [PATCH] Restore the check for update in commit_file

---
 app/models/repository.rb | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/app/models/repository.rb b/app/models/repository.rb
index 6246630300c..8a94fbf3ecc 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -783,6 +783,14 @@ class Repository
     user, path, content, message, branch, update,
     author_email: nil, author_name: nil,
     source_branch: nil, source_project: project)
+    if branch_exists?(branch) && update == false
+      # tree_entry is private
+      if raw_repository.send(:tree_entry, commit(branch), path)
+        raise Gitlab::Git::Repository::InvalidBlobName.new(
+          "Filename already exists; update not allowed")
+      end
+    end
+
     multi_action(
       user: user,
       branch: branch,
-- 
GitLab