lib/gitlab_git/blob.rb in gitlab_git-10.6.4 vs lib/gitlab_git/blob.rb in gitlab_git-10.6.5

- old
+ new

@@ -129,10 +129,11 @@ commit = options[:commit] repo = repository.rugged ref = commit[:branch] update_ref = commit[:update_ref].nil? ? true : commit[:update_ref] parents = [] + mode = 0o100644 unless ref.start_with?('refs/') ref = 'refs/heads/' + ref end @@ -152,20 +153,21 @@ end if action == :remove index.remove(filename) else + file_entry = index.get(filename) + if action == :rename old_path_name = PathHelper.normalize_path(file[:previous_path]) old_filename = old_path_name.to_s - index.remove(old_filename) + file_entry = index.get(old_filename) + index.remove(old_filename) unless file_entry.blank? end - mode = 0o100644 - file_entry = index.get(filename) - if file_entry raise Repository::InvalidBlobName.new("Filename already exists; update not allowed") unless update + # Preserve the current file mode if one is available mode = file_entry[:mode] if file_entry[:mode] end content = file[:content]