1use std::fmt::Display;
5use std::path::{Path, PathBuf};
6use std::str::{self};
7use std::sync::LazyLock;
8
9use anyhow::{Context, Result, anyhow};
10use cargo_util::{ProcessBuilder, paths};
11use owo_colors::OwoColorize;
12use tracing::{debug, instrument, warn};
13use url::Url;
14
15use uv_fs::Simplified;
16use uv_git_types::{GitOid, GitReference};
17use uv_redacted::DisplaySafeUrl;
18use uv_static::EnvVars;
19use uv_warnings::warn_user_once;
20
21const CHECKOUT_READY_LOCK: &str = ".ok";
24
25#[derive(Debug, thiserror::Error)]
26pub enum GitError {
27 #[error("Git executable not found. Ensure that Git is installed and available.")]
28 GitNotFound,
29 #[error("Git LFS extension not found. Ensure that Git LFS is installed and available.")]
30 GitLfsNotFound,
31 #[error("Is Git LFS configured? Run `{}` to initialize Git LFS.", "git lfs install".green())]
32 GitLfsNotConfigured,
33 #[error(transparent)]
34 Other(#[from] which::Error),
35 #[error(
36 "Remote Git fetches are not allowed because network connectivity is disabled (i.e., with `--offline`)"
37 )]
38 TransportNotAllowed,
39}
40
41pub static GIT: LazyLock<Result<ProcessBuilder, GitError>> = LazyLock::new(|| {
46 let path = which::which("git").map_err(|err| match err {
47 which::Error::CannotFindBinaryPath => GitError::GitNotFound,
48 err => GitError::Other(err),
49 })?;
50
51 let mut cmd = ProcessBuilder::new(path);
52
53 cmd.env_remove(EnvVars::GIT_DIR)
60 .env_remove(EnvVars::GIT_WORK_TREE)
61 .env_remove(EnvVars::GIT_INDEX_FILE)
62 .env_remove(EnvVars::GIT_OBJECT_DIRECTORY)
63 .env_remove(EnvVars::GIT_ALTERNATE_OBJECT_DIRECTORIES)
64 .env_remove(EnvVars::GIT_COMMON_DIR);
65
66 Ok(cmd)
67});
68
69enum RefspecStrategy {
71 All,
73 First,
75}
76
77#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
79enum ReferenceOrOid<'reference> {
80 Reference(&'reference GitReference),
82 Oid(GitOid),
84}
85
86impl ReferenceOrOid<'_> {
87 fn resolve(&self, repo: &GitRepository) -> Result<GitOid> {
89 let refkind = self.kind_str();
90 let result = match self {
91 Self::Reference(GitReference::Tag(s)) => {
96 repo.rev_parse(&format!("refs/remotes/origin/tags/{s}^0"))
97 }
98
99 Self::Reference(GitReference::Branch(s)) => repo.rev_parse(&format!("origin/{s}^0")),
101
102 Self::Reference(GitReference::BranchOrTag(s)) => repo
104 .rev_parse(&format!("origin/{s}^0"))
105 .or_else(|_| repo.rev_parse(&format!("refs/remotes/origin/tags/{s}^0"))),
106
107 Self::Reference(GitReference::BranchOrTagOrCommit(s)) => repo
109 .rev_parse(&format!("origin/{s}^0"))
110 .or_else(|_| repo.rev_parse(&format!("refs/remotes/origin/tags/{s}^0")))
111 .or_else(|_| repo.rev_parse(&format!("{s}^0"))),
112
113 Self::Reference(GitReference::DefaultBranch) => {
115 repo.rev_parse("refs/remotes/origin/HEAD")
116 }
117
118 Self::Reference(GitReference::NamedRef(s)) => repo.rev_parse(&format!("{s}^0")),
120
121 Self::Oid(s) => repo.rev_parse(&format!("{s}^0")),
123 };
124
125 result.with_context(|| anyhow::format_err!("failed to find {refkind} `{self}`"))
126 }
127
128 fn kind_str(&self) -> &str {
130 match self {
131 Self::Reference(reference) => reference.kind_str(),
132 Self::Oid(_) => "commit",
133 }
134 }
135
136 fn as_rev(&self) -> &str {
138 match self {
139 Self::Reference(r) => r.as_rev(),
140 Self::Oid(rev) => rev.as_str(),
141 }
142 }
143}
144
145impl Display for ReferenceOrOid<'_> {
146 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
147 match self {
148 Self::Reference(reference) => write!(f, "{reference}"),
149 Self::Oid(oid) => write!(f, "{oid}"),
150 }
151 }
152}
153
154#[derive(PartialEq, Clone, Debug)]
156pub(crate) struct GitRemote {
157 url: DisplaySafeUrl,
159}
160
161pub(crate) struct GitDatabase {
164 remote: GitRemote,
166 repo: GitRepository,
168 lfs_ready: Option<bool>,
170}
171
172pub(crate) struct GitCheckout {
174 revision: GitOid,
176 repo: GitRepository,
178 lfs_ready: Option<bool>,
180}
181
182pub(crate) struct GitRepository {
184 path: PathBuf,
186}
187
188impl GitRepository {
189 fn open(path: &Path) -> Result<Self> {
191 GIT.as_ref()
193 .cloned()?
194 .arg("rev-parse")
195 .cwd(path)
196 .exec_with_output()?;
197
198 Ok(Self {
199 path: path.to_path_buf(),
200 })
201 }
202
203 fn init(path: &Path) -> Result<Self> {
205 GIT.as_ref()
213 .cloned()?
214 .arg("init")
215 .cwd(path)
216 .exec_with_output()?;
217
218 Ok(Self {
219 path: path.to_path_buf(),
220 })
221 }
222
223 fn rev_parse(&self, refname: &str) -> Result<GitOid> {
225 let result = GIT
226 .as_ref()
227 .cloned()?
228 .arg("rev-parse")
229 .arg(refname)
230 .cwd(&self.path)
231 .exec_with_output()?;
232
233 let mut result = String::from_utf8(result.stdout)?;
234 result.truncate(result.trim_end().len());
235 Ok(result.parse()?)
236 }
237
238 #[instrument(skip_all, fields(path = %self.path.user_display(), refname = %refname))]
240 fn lfs_fsck_objects(&self, refname: &str) -> bool {
241 let mut cmd = if let Ok(lfs) = GIT_LFS.as_ref() {
242 lfs.clone()
243 } else {
244 warn!("Git LFS is not available, skipping LFS fetch");
245 return false;
246 };
247
248 let result = cmd
250 .arg("fsck")
251 .arg("--objects")
252 .arg(refname)
253 .cwd(&self.path)
254 .exec_with_output();
255
256 match result {
257 Ok(_) => true,
258 Err(err) => {
259 let lfs_error = err.to_string();
260 if lfs_error.contains("unknown flag: --objects") {
261 warn_user_once!(
262 "Skipping Git LFS validation as Git LFS extension is outdated. \
263 Upgrade to `git-lfs>=3.0.2` or manually verify git-lfs objects were \
264 properly fetched after the current operation finishes."
265 );
266 true
267 } else {
268 debug!("Git LFS validation failed: {err}");
269 false
270 }
271 }
272 }
273 }
274}
275
276impl GitRemote {
277 pub(crate) fn new(url: DisplaySafeUrl) -> Self {
279 Self { url }
280 }
281
282 pub(crate) fn url(&self) -> &DisplaySafeUrl {
284 &self.url
285 }
286
287 pub(crate) fn checkout(
300 self,
301 into: &Path,
302 db: Option<GitDatabase>,
303 reference: &GitReference,
304 locked_rev: Option<GitOid>,
305 disable_ssl: bool,
306 offline: bool,
307 with_lfs: bool,
308 ) -> Result<(GitDatabase, GitOid)> {
309 let reference = locked_rev
310 .map(ReferenceOrOid::Oid)
311 .unwrap_or(ReferenceOrOid::Reference(reference));
312 if let Some(mut db) = db {
313 fetch(&mut db.repo, &self.url, reference, disable_ssl, offline)
314 .with_context(|| format!("failed to fetch into: {}", into.user_display()))?;
315
316 let resolved_commit_hash = match locked_rev {
317 Some(rev) => db.contains(rev).then_some(rev),
318 None => reference.resolve(&db.repo).ok(),
319 };
320
321 if let Some(rev) = resolved_commit_hash {
322 if with_lfs {
323 let lfs_ready = fetch_lfs(&mut db.repo, &self.url, &rev, disable_ssl)
324 .with_context(|| format!("failed to fetch LFS objects at {rev}"))?;
325 db = db.with_lfs_ready(Some(lfs_ready));
326 }
327 return Ok((db, rev));
328 }
329 }
330
331 match fs_err::remove_dir_all(into) {
335 Ok(()) => {}
336 Err(e) if e.kind() == std::io::ErrorKind::NotFound => {}
337 Err(e) => return Err(e.into()),
338 }
339
340 fs_err::create_dir_all(into)?;
341 let mut repo = GitRepository::init(into)?;
342 fetch(&mut repo, &self.url, reference, disable_ssl, offline)
343 .with_context(|| format!("failed to clone into: {}", into.user_display()))?;
344 let rev = match locked_rev {
345 Some(rev) => rev,
346 None => reference.resolve(&repo)?,
347 };
348 let lfs_ready = with_lfs
349 .then(|| {
350 fetch_lfs(&mut repo, &self.url, &rev, disable_ssl)
351 .with_context(|| format!("failed to fetch LFS objects at {rev}"))
352 })
353 .transpose()?;
354
355 Ok((
356 GitDatabase {
357 remote: self,
358 repo,
359 lfs_ready,
360 },
361 rev,
362 ))
363 }
364
365 pub(crate) fn db_at(&self, db_path: &Path) -> Result<GitDatabase> {
367 let repo = GitRepository::open(db_path)?;
368 Ok(GitDatabase {
369 remote: self.clone(),
370 repo,
371 lfs_ready: None,
372 })
373 }
374}
375
376impl GitDatabase {
377 pub(crate) fn copy_to(&self, rev: GitOid, destination: &Path) -> Result<GitCheckout> {
379 let checkout = match GitRepository::open(destination)
384 .ok()
385 .map(|repo| GitCheckout::new(rev, repo))
386 .filter(GitCheckout::is_fresh)
387 {
388 Some(co) => co.with_lfs_ready(self.lfs_ready),
389 None => GitCheckout::clone_into(destination, self, rev, self.remote.url())?,
390 };
391 Ok(checkout)
392 }
393
394 pub(crate) fn to_short_id(&self, revision: GitOid) -> Result<String> {
396 let output = GIT
397 .as_ref()
398 .cloned()?
399 .arg("rev-parse")
400 .arg("--short")
401 .arg(revision.as_str())
402 .cwd(&self.repo.path)
403 .exec_with_output()?;
404
405 let mut result = String::from_utf8(output.stdout)?;
406 result.truncate(result.trim_end().len());
407 Ok(result)
408 }
409
410 pub(crate) fn contains(&self, oid: GitOid) -> bool {
412 self.repo.rev_parse(&format!("{oid}^0")).is_ok()
413 }
414
415 pub(crate) fn contains_lfs_artifacts(&self, oid: GitOid) -> bool {
417 self.repo.lfs_fsck_objects(&format!("{oid}^0"))
418 }
419
420 #[must_use]
422 pub(crate) fn with_lfs_ready(mut self, lfs: Option<bool>) -> Self {
423 self.lfs_ready = lfs;
424 self
425 }
426}
427
428impl GitCheckout {
429 fn new(revision: GitOid, repo: GitRepository) -> Self {
434 Self {
435 revision,
436 repo,
437 lfs_ready: None,
438 }
439 }
440
441 fn clone_into(
444 into: &Path,
445 database: &GitDatabase,
446 revision: GitOid,
447 original_remote_url: &DisplaySafeUrl,
448 ) -> Result<Self> {
449 let dirname = into.parent().unwrap();
450 fs_err::create_dir_all(dirname)?;
451 match fs_err::remove_dir_all(into) {
452 Ok(()) => {}
453 Err(e) if e.kind() == std::io::ErrorKind::NotFound => {}
454 Err(e) => return Err(e.into()),
455 }
456
457 let res = GIT
461 .as_ref()
462 .cloned()?
463 .arg("clone")
464 .arg("--local")
465 .arg(database.repo.path.simplified_display().to_string())
469 .arg(into.simplified_display().to_string())
470 .exec_with_output();
471
472 if let Err(e) = res {
473 debug!("Cloning git repo with --local failed, retrying without hardlinks: {e}");
474
475 GIT.as_ref()
476 .cloned()?
477 .arg("clone")
478 .arg("--no-hardlinks")
479 .arg(database.repo.path.simplified_display().to_string())
480 .arg(into.simplified_display().to_string())
481 .exec_with_output()?;
482 }
483
484 let repo = GitRepository::open(into)?;
485 let checkout = Self::new(revision, repo);
486 let lfs_ready = checkout.reset(database.lfs_ready, original_remote_url)?;
487 Ok(checkout.with_lfs_ready(lfs_ready))
488 }
489
490 fn is_fresh(&self) -> bool {
492 match self.repo.rev_parse("HEAD") {
493 Ok(id) if id == self.revision => {
494 self.repo.path.join(CHECKOUT_READY_LOCK).exists()
496 }
497 _ => false,
498 }
499 }
500
501 pub(crate) fn lfs_ready(&self) -> Option<bool> {
503 self.lfs_ready
504 }
505
506 #[must_use]
508 fn with_lfs_ready(mut self, lfs: Option<bool>) -> Self {
509 self.lfs_ready = lfs;
510 self
511 }
512
513 fn reset(
529 &self,
530 with_lfs: Option<bool>,
531 original_remote_url: &DisplaySafeUrl,
532 ) -> Result<Option<bool>> {
533 let ok_file = self.repo.path.join(CHECKOUT_READY_LOCK);
534 let _ = paths::remove_file(&ok_file);
535
536 let lfs_skip_smudge = if with_lfs == Some(true) { "0" } else { "1" };
540
541 debug!("Reset {} to {}", self.repo.path.display(), self.revision);
542
543 GIT.as_ref()
545 .cloned()?
546 .arg("reset")
547 .arg("--hard")
548 .arg(self.revision.as_str())
549 .env(EnvVars::GIT_LFS_SKIP_SMUDGE, lfs_skip_smudge)
550 .cwd(&self.repo.path)
551 .exec_with_output()?;
552
553 let mut submodule_update = GIT.as_ref().cloned()?;
562 for config in submodule_update_config(original_remote_url) {
563 submodule_update.arg("-c").arg(config);
564 }
565
566 submodule_update
567 .arg("submodule")
568 .arg("update")
569 .arg("--init")
570 .env(EnvVars::GIT_LFS_SKIP_SMUDGE, lfs_skip_smudge)
571 .cwd(&self.repo.path)
572 .exec_with_output()
573 .map(drop)?;
574
575 let mut submodule_update = GIT.as_ref().cloned()?;
579 for config in submodule_auth_config(original_remote_url) {
580 submodule_update.arg("-c").arg(config);
581 }
582
583 submodule_update
584 .arg("submodule")
585 .arg("update")
586 .arg("--recursive")
587 .arg("--init")
588 .env(EnvVars::GIT_LFS_SKIP_SMUDGE, lfs_skip_smudge)
589 .cwd(&self.repo.path)
590 .exec_with_output()
591 .map(drop)?;
592
593 let lfs_validation = match with_lfs {
596 None => None,
597 Some(false) => Some(false),
598 Some(true) => Some(self.repo.lfs_fsck_objects(self.revision.as_str())),
599 };
600
601 if with_lfs.is_none() || lfs_validation == Some(true) {
605 paths::create(ok_file)?;
606 }
607
608 Ok(lfs_validation)
609 }
610}
611
612fn submodule_update_config(original_remote_url: &DisplaySafeUrl) -> Vec<String> {
620 let remote_url = original_remote_url.without_credentials();
621 let mut config = vec![format!("remote.origin.url={}", remote_url.as_str())];
622
623 config.extend(submodule_auth_config(original_remote_url));
624 config
625}
626
627fn submodule_auth_config(original_remote_url: &DisplaySafeUrl) -> Vec<String> {
633 let remote_url = original_remote_url.without_credentials();
634 let mut config = Vec::new();
635
636 if remote_url.as_str() != original_remote_url.as_str() {
637 let safe_root = remote_url_root(remote_url.into_owned());
638 let credentialed_root = remote_url_root((**original_remote_url).clone());
639
640 if safe_root.as_str() != credentialed_root.as_str() {
641 config.push(format!(
642 "url.{}.insteadOf={}",
643 credentialed_root.as_str(),
644 safe_root.as_str()
645 ));
646 }
647 }
648
649 config
650}
651
652fn remote_url_root(mut url: Url) -> Url {
658 url.set_path("/");
659 url.set_query(None);
660 url.set_fragment(None);
661 url
662}
663
664fn fetch(
673 repo: &mut GitRepository,
674 remote_url: &DisplaySafeUrl,
675 reference: ReferenceOrOid<'_>,
676 disable_ssl: bool,
677 offline: bool,
678) -> Result<()> {
679 let oid_to_fetch = if let ReferenceOrOid::Oid(rev) = reference {
680 let local_object = reference.resolve(repo).ok();
681 if let Some(local_object) = local_object {
682 if rev == local_object {
683 return Ok(());
684 }
685 }
686
687 Some(rev)
690 } else {
691 None
692 };
693
694 let mut refspecs = Vec::new();
697 let mut tags = false;
698 let mut refspec_strategy = RefspecStrategy::All;
699 match reference {
703 ReferenceOrOid::Reference(GitReference::Branch(branch)) => {
706 refspecs.push(format!("+refs/heads/{branch}:refs/remotes/origin/{branch}"));
707 }
708
709 ReferenceOrOid::Reference(GitReference::Tag(tag)) => {
710 refspecs.push(format!("+refs/tags/{tag}:refs/remotes/origin/tags/{tag}"));
711 }
712
713 ReferenceOrOid::Reference(GitReference::BranchOrTag(branch_or_tag)) => {
714 refspecs.push(format!(
715 "+refs/heads/{branch_or_tag}:refs/remotes/origin/{branch_or_tag}"
716 ));
717 refspecs.push(format!(
718 "+refs/tags/{branch_or_tag}:refs/remotes/origin/tags/{branch_or_tag}"
719 ));
720 refspec_strategy = RefspecStrategy::First;
721 }
722
723 ReferenceOrOid::Reference(GitReference::BranchOrTagOrCommit(branch_or_tag_or_commit)) => {
726 if let Some(oid_to_fetch) =
730 oid_to_fetch.filter(|oid| is_short_hash_of(branch_or_tag_or_commit, *oid))
731 {
732 refspecs.push(format!("+{oid_to_fetch}:refs/commit/{oid_to_fetch}"));
733 } else {
734 refspecs.push(String::from("+refs/heads/*:refs/remotes/origin/*"));
738 refspecs.push(String::from("+HEAD:refs/remotes/origin/HEAD"));
739 tags = true;
740 }
741 }
742
743 ReferenceOrOid::Reference(GitReference::DefaultBranch) => {
744 refspecs.push(String::from("+HEAD:refs/remotes/origin/HEAD"));
745 }
746
747 ReferenceOrOid::Reference(GitReference::NamedRef(rev)) => {
748 refspecs.push(format!("+{rev}:{rev}"));
749 }
750
751 ReferenceOrOid::Oid(rev) => {
752 refspecs.push(format!("+{rev}:refs/commit/{rev}"));
753 }
754 }
755
756 debug!("Performing a Git fetch for: {remote_url}");
757 let result = match refspec_strategy {
758 RefspecStrategy::All => fetch_with_cli(
759 repo,
760 remote_url,
761 refspecs.as_slice(),
762 tags,
763 disable_ssl,
764 offline,
765 ),
766 RefspecStrategy::First => {
767 let mut errors = refspecs
769 .iter()
770 .map_while(|refspec| {
771 let fetch_result = fetch_with_cli(
772 repo,
773 remote_url,
774 std::slice::from_ref(refspec),
775 tags,
776 disable_ssl,
777 offline,
778 );
779
780 match fetch_result {
782 Err(ref err) => {
783 debug!("Failed to fetch refspec `{refspec}`: {err}");
784 Some(fetch_result)
785 }
786 Ok(()) => None,
787 }
788 })
789 .collect::<Vec<_>>();
790
791 if errors.len() == refspecs.len() {
792 if let Some(result) = errors.pop() {
793 result
795 } else {
796 Ok(())
798 }
799 } else {
800 Ok(())
801 }
802 }
803 };
804 match reference {
805 ReferenceOrOid::Reference(GitReference::DefaultBranch) => result,
807 _ => result.with_context(|| {
808 format!(
809 "failed to fetch {} `{}`",
810 reference.kind_str(),
811 reference.as_rev()
812 )
813 }),
814 }
815}
816
817fn fetch_with_cli(
819 repo: &mut GitRepository,
820 url: &DisplaySafeUrl,
821 refspecs: &[String],
822 tags: bool,
823 disable_ssl: bool,
824 offline: bool,
825) -> Result<()> {
826 let mut cmd = GIT.as_ref().cloned()?;
827 cmd.env(EnvVars::GIT_TERMINAL_PROMPT, "0");
831
832 cmd.arg("fetch");
833 if tags {
834 cmd.arg("--tags");
835 }
836 if disable_ssl {
837 debug!("Disabling SSL verification for Git fetch via `GIT_SSL_NO_VERIFY`");
838 cmd.env(EnvVars::GIT_SSL_NO_VERIFY, "true");
839 }
840 if offline {
841 debug!("Disabling remote protocols for Git fetch via `GIT_ALLOW_PROTOCOL=file`");
842 cmd.env(EnvVars::GIT_ALLOW_PROTOCOL, "file");
843 }
844 cmd.arg("--force") .arg("--update-head-ok") .arg(url.as_str())
847 .args(refspecs)
848 .cwd(&repo.path);
849
850 cmd.exec_with_output().map_err(|err| {
854 let msg = err.to_string();
855 if msg.contains("transport '") && msg.contains("' not allowed") && offline {
856 return GitError::TransportNotAllowed.into();
857 }
858 err
859 })?;
860
861 Ok(())
862}
863
864pub static GIT_LFS: LazyLock<Result<ProcessBuilder>> = LazyLock::new(|| {
875 if std::env::var_os(EnvVars::UV_INTERNAL__TEST_LFS_DISABLED).is_some() {
876 return Err(anyhow!("Git LFS extension has been forcefully disabled."));
877 }
878
879 let mut cmd = GIT.as_ref()?.clone();
880 cmd.arg("lfs");
881
882 cmd.clone().arg("version").exec_with_output()?;
884 Ok(cmd)
885});
886
887fn fetch_lfs(
889 repo: &mut GitRepository,
890 url: &DisplaySafeUrl,
891 revision: &GitOid,
892 disable_ssl: bool,
893) -> Result<bool> {
894 let mut cmd = if let Ok(lfs) = GIT_LFS.as_ref() {
895 debug!("Fetching Git LFS objects");
896 lfs.clone()
897 } else {
898 warn!("Git LFS is not available, skipping LFS fetch");
900 return Ok(false);
901 };
902
903 if disable_ssl {
904 debug!("Disabling SSL verification for Git LFS");
905 cmd.env(EnvVars::GIT_SSL_NO_VERIFY, "true");
906 }
907
908 cmd.arg("fetch")
909 .arg(url.as_str())
910 .arg(revision.as_str())
911 .env_remove(EnvVars::GIT_LFS_SKIP_SMUDGE)
914 .cwd(&repo.path);
915
916 cmd.exec_with_output()?;
917
918 let validation_result = repo.lfs_fsck_objects(revision.as_str());
926
927 Ok(validation_result)
928}
929
930fn is_short_hash_of(rev: &str, oid: GitOid) -> bool {
932 let long_hash = oid.to_string();
933 match long_hash.get(..rev.len()) {
934 Some(truncated_long_hash) => truncated_long_hash.eq_ignore_ascii_case(rev),
935 None => false,
936 }
937}
938
939#[cfg(test)]
940mod tests {
941 use super::*;
942
943 #[test]
944 fn submodule_update_config_strips_credentials_from_origin_override() {
945 let url = DisplaySafeUrl::parse("https://user:password@example.com/org/repo.git").unwrap();
946
947 assert_eq!(
948 submodule_update_config(&url),
949 vec![
950 "remote.origin.url=https://example.com/org/repo.git".to_string(),
951 "url.https://user:password@example.com/.insteadOf=https://example.com/".to_string(),
952 ]
953 );
954 }
955
956 #[test]
957 fn submodule_update_config_preserves_git_ssh_user() {
958 let url = DisplaySafeUrl::parse("ssh://git@example.com/org/repo.git").unwrap();
959
960 assert_eq!(
961 submodule_update_config(&url),
962 vec!["remote.origin.url=ssh://git@example.com/org/repo.git".to_string()]
963 );
964 }
965}