Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for the git merge --no-commit argument #538

Merged
merged 2 commits into from Dec 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/git/lib.rb
Expand Up @@ -772,6 +772,7 @@ def checkout_file(version, file)

def merge(branch, message = nil, opts = {})
arr_opts = []
arr_opts << '--no-commit' if opts[:no_commit]
arr_opts << '--no-ff' if opts[:no_ff]
arr_opts << '-m' << message if message
arr_opts += [branch]
Expand Down
29 changes: 29 additions & 0 deletions tests/units/test_merge.rb
Expand Up @@ -130,4 +130,33 @@ def test_no_ff_merge
end
end
end

def test_merge_no_commit
in_temp_dir do |path|
g = Git.clone(@wbare, 'branch_merge_test')
g.chdir do
g.branch('new_branch_1').in_branch('first commit message') do
new_file('new_file_1', 'foo')
g.add
true
end

g.branch('new_branch_2').in_branch('first commit message') do
new_file('new_file_2', 'bar')
g.add
true
end

g.checkout('new_branch_2')
before_merge = g.show
g.merge('new_branch_1', nil, no_commit: true)
# HEAD is the same as before.
assert_equal(before_merge, g.show)
# File has not been merged in.
status = g.status['new_file_1']
assert_equal('new_file_1', status.path)
assert_equal('A', status.type)
end
end
end
end