diff --git a/cli/src/cli_util.rs b/cli/src/cli_util.rs index 18a46bfd7..8bc3e9905 100644 --- a/cli/src/cli_util.rs +++ b/cli/src/cli_util.rs @@ -595,7 +595,7 @@ impl CommandHelper { #[instrument(skip(self, ui))] pub fn workspace_helper(&self, ui: &mut Ui) -> Result { let mut workspace_command = self.workspace_helper_no_snapshot(ui)?; - workspace_command.snapshot(ui)?; + workspace_command.maybe_snapshot(ui)?; Ok(workspace_command) } @@ -795,7 +795,7 @@ impl WorkspaceCommandHelper { /// Snapshot the working copy if allowed, and import Git refs if the working /// copy is collocated with Git. #[instrument(skip_all)] - pub fn snapshot(&mut self, ui: &mut Ui) -> Result<(), CommandError> { + pub fn maybe_snapshot(&mut self, ui: &mut Ui) -> Result<(), CommandError> { if self.may_update_working_copy { if self.working_copy_shared_with_git { self.import_git_refs_and_head(ui)?; @@ -1297,7 +1297,7 @@ Set which revision the branch points to with `jj branch set {branch_name} -r Result<(), CommandError> { + fn snapshot_working_copy(&mut self, ui: &mut Ui) -> Result<(), CommandError> { let workspace_id = self.workspace_id().to_owned(); let get_wc_commit = |repo: &ReadonlyRepo| -> Result, _> { repo.view() diff --git a/cli/src/commands/init.rs b/cli/src/commands/init.rs index b261903c2..b30998003 100644 --- a/cli/src/commands/init.rs +++ b/cli/src/commands/init.rs @@ -81,7 +81,7 @@ pub(crate) fn cmd_init( Workspace::init_external_git(command.settings(), &wc_path, &git_store_path)?; let mut workspace_command = command.for_loaded_repo(ui, workspace, repo)?; git::maybe_add_gitignore(&workspace_command)?; - workspace_command.snapshot(ui)?; + workspace_command.maybe_snapshot(ui)?; if !workspace_command.working_copy_shared_with_git() { let mut tx = workspace_command.start_transaction(); let stats = jj_lib::git::import_some_refs( diff --git a/cli/src/commands/workspace.rs b/cli/src/commands/workspace.rs index cd413a300..c15f5614f 100644 --- a/cli/src/commands/workspace.rs +++ b/cli/src/commands/workspace.rs @@ -290,7 +290,7 @@ fn cmd_workspace_update_stale( // fine if we picked the new wc_commit_id. let known_wc_commit = { let mut workspace_command = command.for_stale_working_copy(ui)?; - workspace_command.snapshot(ui)?; + workspace_command.maybe_snapshot(ui)?; let wc_commit_id = workspace_command.get_wc_commit_id().unwrap(); workspace_command.repo().store().get_commit(wc_commit_id)? };