mirror of
https://github.com/martinvonz/jj.git
synced 2024-09-11 13:56:29 +03:00
cli git remote add/set-url
: use sanitize_git_url_if_path
It seems like an oversight that the algorithm from `jj git clone` wasn't used in them before
This commit is contained in:
parent
1d6dc32bbd
commit
bed1ca1019
@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use jj_lib::git;
|
||||
use jj_lib::git::{self, sanitize_git_url_if_path};
|
||||
use jj_lib::repo::Repo;
|
||||
|
||||
use crate::cli_util::CommandHelper;
|
||||
@ -37,6 +37,10 @@ pub fn cmd_git_remote_add(
|
||||
let workspace_command = command.workspace_helper(ui)?;
|
||||
let repo = workspace_command.repo();
|
||||
let git_repo = get_git_repo(repo.store())?;
|
||||
git::add_remote(&git_repo, &args.remote, &args.url)?;
|
||||
git::add_remote(
|
||||
&git_repo,
|
||||
&args.remote,
|
||||
&sanitize_git_url_if_path(command.cwd(), &args.url),
|
||||
)?;
|
||||
Ok(())
|
||||
}
|
||||
|
@ -37,6 +37,6 @@ pub fn cmd_git_remote_set_url(
|
||||
let workspace_command = command.workspace_helper(ui)?;
|
||||
let repo = workspace_command.repo();
|
||||
let git_repo = get_git_repo(repo.store())?;
|
||||
git::set_remote_url(&git_repo, &args.remote, &args.url)?;
|
||||
git::set_remote_url(&git_repo, &args.remote, &args.url, command.cwd())?;
|
||||
Ok(())
|
||||
}
|
||||
|
@ -1180,6 +1180,7 @@ pub fn set_remote_url(
|
||||
git_repo: &git2::Repository,
|
||||
remote_name: &str,
|
||||
new_remote_url: &str,
|
||||
cwd: &Path,
|
||||
) -> Result<(), GitRemoteManagementError> {
|
||||
if remote_name == REMOTE_NAME_FOR_LOCAL_GIT_REPO {
|
||||
return Err(GitRemoteManagementError::RemoteReservedForLocalGitRepo);
|
||||
@ -1197,7 +1198,7 @@ pub fn set_remote_url(
|
||||
})?;
|
||||
|
||||
git_repo
|
||||
.remote_set_url(remote_name, new_remote_url)
|
||||
.remote_set_url(remote_name, &sanitize_git_url_if_path(cwd, new_remote_url))
|
||||
.map_err(GitRemoteManagementError::InternalGitError)?;
|
||||
Ok(())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user