Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-08-23 11:32:37 +0400
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-08-23 11:32:37 +0400
commit7ab587a47791e371f5c109c14097a5d1d7776ea5 (patch)
tree6c615edda7c10b040f93baad4161f318cdd18fa4
parenta94b2d1ccfa17f92d2d17f20a23ab86e4456291e (diff)
parent9ec4c2d214b045f3fb207edd67055c4ccaebd381 (diff)
Merge pull request #1263 from dosire/merge_base_for_merge_request
Show only the commits that are newer in the merge request.
-rw-r--r--app/models/merge_request.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb
index 47966d669f6..542817b0eea 100644
--- a/app/models/merge_request.rb
+++ b/app/models/merge_request.rb
@@ -88,8 +88,11 @@ class MergeRequest < ActiveRecord::Base
end
def unmerged_diffs
- commits = project.repo.commits_between(target_branch, source_branch).map {|c| Commit.new(c)}
- diffs = project.repo.diff(commits.first.prev_commit.id, commits.last.id) rescue []
+ # Only show what is new in the source branch compared to the target branch, not the other way around.
+ # The linex below with merge_base is equivalent to diff with three dots (git diff branch1...branch2)
+ # From the git documentation: "git diff A...B" is equivalent to "git diff $(git-merge-base A B) B"
+ common_commit = project.repo.git.native(:merge_base, {}, [target_branch, source_branch]).strip
+ diffs = project.repo.diff(common_commit, source_branch)
end
def last_commit