Skip to content

Commit

Permalink
Add support for the git merge --no-commit argument (#538)
Browse files Browse the repository at this point in the history
Docs at:
https://git-scm.com/docs/git-merge#Documentation/git-merge.txt---no-commit

Signed-off-by: Jon Dufresne <jon.dufresne@gmail.com>
  • Loading branch information
jdufresne committed Dec 17, 2021
1 parent 1023f85 commit ff98c42
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
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

0 comments on commit ff98c42

Please sign in to comment.