summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/diff/position.rb12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/gitlab/diff/position.rb b/lib/gitlab/diff/position.rb
index 2fdcf8d7838..088e105d771 100644
--- a/lib/gitlab/diff/position.rb
+++ b/lib/gitlab/diff/position.rb
@@ -139,13 +139,19 @@ module Gitlab
private
def find_diff_file(repository)
- diffs = Gitlab::Git::Compare.new(
+ compare = Gitlab::Git::Compare.new(
repository.raw_repository,
start_sha,
head_sha
- ).diffs(paths: paths)
+ )
+
+ # We're at the initial commit, so just get that.
+ if start_sha == Gitlab::Git::BLANK_SHA && compare.commits.empty?
+ compare = Gitlab::Git::Commit.find(repository.raw_repository, head_sha)
+ end
+
+ diff = compare.diffs(paths: paths).first
- diff = diffs.first
return unless diff
Gitlab::Diff::File.new(diff, repository: repository, diff_refs: diff_refs)