diff options
author | Sean McGivern <sean@gitlab.com> | 2016-08-19 15:05:47 +0100 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2016-08-19 15:05:47 +0100 |
commit | 91336f399bdd716aece8bcd8d28fdd354f86695b (patch) | |
tree | b8e3d21ea677a39a098c303a17aeb86f9ebc5c55 /lib | |
parent | 12e9df327042f3b368878d14f6e18e51b9f668b9 (diff) | |
download | gitlab-ce-20895-inline-comments-for-first-commit.tar.gz |
Fix line commenting for the initial commit20895-inline-comments-for-first-commit
The initial commit doesn't have a parent, so explicitly pass the blank
SHA and handle that when calculating the position.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/diff/position.rb | 12 |
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) |