Skip to content

Commit 55cf980

Browse files
committed
fix(git): Respect --frozen like --offline
1 parent 52a271f commit 55cf980

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/cargo/sources/git/source.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -299,10 +299,16 @@ impl<'gctx> Source for GitSource<'gctx> {
299299
// If we're in offline mode, we're not locked, and we have a
300300
// database, then try to resolve our reference with the preexisting
301301
// repository.
302-
(Revision::Deferred(git_ref), Some(db)) if self.gctx.offline() => {
302+
(Revision::Deferred(git_ref), Some(db)) if !self.gctx.network_allowed() => {
303+
let offline_flag = self
304+
.gctx
305+
.offline_flag()
306+
.expect("always present when `!network_allowed`");
303307
let rev = db.resolve(&git_ref).with_context(|| {
304-
"failed to lookup reference in preexisting repository, and \
305-
can't check for updates in offline mode (--offline)"
308+
format!(
309+
"failed to lookup reference in preexisting repository, and \
310+
can't check for updates in offline mode ({offline_flag})"
311+
)
306312
})?;
307313
(db, rev)
308314
}
@@ -312,9 +318,9 @@ impl<'gctx> Source for GitSource<'gctx> {
312318
// situation that we have a locked revision but the database
313319
// doesn't have it.
314320
(locked_rev, db) => {
315-
if self.gctx.offline() {
321+
if let Some(offline_flag) = self.gctx.offline_flag() {
316322
anyhow::bail!(
317-
"can't checkout from '{}': you are in the offline mode (--offline)",
323+
"can't checkout from '{}': you are in the offline mode ({offline_flag})",
318324
self.remote.url()
319325
);
320326
}

0 commit comments

Comments
 (0)