Skip to content

Commit

Permalink
Merge remote-tracking branches 'p/diff-submodule' and 'p/set-url-push…
Browse files Browse the repository at this point in the history
…' into mine

* p/diff-submodule:
  Support --submodule option to git diff.

* p/set-url-push:
  Add :push option to remote_set_url.
  • Loading branch information
p committed Jun 24, 2021
2 parents ca4c15d + 7b79863 commit 0e14f9c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 5 additions & 2 deletions lib/git/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -414,11 +414,14 @@ def add_remote(name, url, opts = {})
# sets the url for a remote
# url can be a git url or a Git::Base object if it's a local reference
#
# accepts options:
# :push
#
# @git.set_remote_url('scotts_git', 'git://repo.or.cz/rubygit.git')
#
def set_remote_url(name, url)
def set_remote_url(name, url, opts = {})
url = url.repo.path if url.is_a?(Git::Base)
self.lib.remote_set_url(name, url)
self.lib.remote_set_url(name, url, opts)
Git::Remote.new(self, name)
end

Expand Down
5 changes: 4 additions & 1 deletion lib/git/lib.rb
Original file line number Diff line number Diff line change
Expand Up @@ -817,10 +817,13 @@ def remote_add(name, url, opts = {})
command('remote', arr_opts)
end

def remote_set_url(name, url)
# accepts options:
# :push
def remote_set_url(name, url, opts = {})
arr_opts = ['set-url']
arr_opts << name
arr_opts << url
arr_opts << '--push' if opts[:push]

command('remote', arr_opts)
end
Expand Down

0 comments on commit 0e14f9c

Please sign in to comment.