Skip to content

Commit dbf778c

Browse files
committed
feat: gix remote and gix fetch now fallback to the only available remote if necessary. (#1003)
Just like `git`, but we fail loudly if there are more than one remotes.
1 parent a71b6de commit dbf778c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

gitoxide-core/src/repository/remote.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,9 @@ pub(crate) fn by_name_or_url<'repo>(
346346
None => repo
347347
.head()?
348348
.into_remote(gix::remote::Direction::Fetch)
349-
.context("Cannot find a remote for unborn branch")??,
349+
.transpose()?
350+
.map(Ok)
351+
.or_else(|| repo.find_default_remote(gix::remote::Direction::Fetch))
352+
.context("There was no remote available or too many to choose from")??,
350353
})
351354
}

0 commit comments

Comments
 (0)