Skip to content

Commit ff98c42

Browse files
authored
Add support for the git merge --no-commit argument (ruby-git#538)
Docs at: https://git-scm.com/docs/git-merge#Documentation/git-merge.txt---no-commit Signed-off-by: Jon Dufresne <jon.dufresne@gmail.com>
1 parent 1023f85 commit ff98c42

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

lib/git/lib.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,7 @@ def checkout_file(version, file)
772772

773773
def merge(branch, message = nil, opts = {})
774774
arr_opts = []
775+
arr_opts << '--no-commit' if opts[:no_commit]
775776
arr_opts << '--no-ff' if opts[:no_ff]
776777
arr_opts << '-m' << message if message
777778
arr_opts += [branch]

tests/units/test_merge.rb

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,33 @@ def test_no_ff_merge
130130
end
131131
end
132132
end
133+
134+
def test_merge_no_commit
135+
in_temp_dir do |path|
136+
g = Git.clone(@wbare, 'branch_merge_test')
137+
g.chdir do
138+
g.branch('new_branch_1').in_branch('first commit message') do
139+
new_file('new_file_1', 'foo')
140+
g.add
141+
true
142+
end
143+
144+
g.branch('new_branch_2').in_branch('first commit message') do
145+
new_file('new_file_2', 'bar')
146+
g.add
147+
true
148+
end
149+
150+
g.checkout('new_branch_2')
151+
before_merge = g.show
152+
g.merge('new_branch_1', nil, no_commit: true)
153+
# HEAD is the same as before.
154+
assert_equal(before_merge, g.show)
155+
# File has not been merged in.
156+
status = g.status['new_file_1']
157+
assert_equal('new_file_1', status.path)
158+
assert_equal('A', status.type)
159+
end
160+
end
161+
end
133162
end

0 commit comments

Comments
 (0)