Skip to content

Commit aae56b1

Browse files
Add support for --update-head-ok to fetch
Signed-off-by: Dylan Rainwater <dylancrainwater@gmail.com>
1 parent b53d308 commit aae56b1

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ g.fetch
311311
g.fetch(g.remotes.first)
312312
g.fetch('origin', {:ref => 'some/ref/head'} )
313313
g.fetch(all: true, force: true, depth: 2)
314+
g.fetch('origin', {:'update-head-ok' => true})
314315

315316
g.pull
316317
g.pull(Git::Repo, Git::Branch) # fetch and a merge

lib/git/lib.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -951,6 +951,7 @@ def fetch(remote, opts)
951951
arr_opts << '--prune' if opts[:p] || opts[:prune]
952952
arr_opts << '--prune-tags' if opts[:P] || opts[:'prune-tags']
953953
arr_opts << '--force' if opts[:f] || opts[:force]
954+
arr_opts << '--update-head-ok' if opts[:u] || opts[:'update-head-ok']
954955
arr_opts << '--unshallow' if opts[:unshallow]
955956
arr_opts << '--depth' << opts[:depth] if opts[:depth]
956957
arr_opts << '--' if remote || opts[:ref]

tests/units/test_remotes.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,13 @@ def test_fetch_cmd_with_all_with_other_args
147147
assert_command_line(expected_command_line, git_cmd, git_cmd_args)
148148
end
149149

150+
def test_fetch_cmd_with_update_head_ok
151+
expected_command_line = ['fetch', '--update-head-ok']
152+
git_cmd = :fetch
153+
git_cmd_args = [:'update-head-ok' => true]
154+
assert_command_line(expected_command_line, git_cmd, git_cmd_args)
155+
end
156+
150157
def test_fetch_command_injection
151158
test_file = 'VULNERABILITY_EXISTS'
152159
vulnerability_exists = false

0 commit comments

Comments
 (0)