From a02b5af1e802e3c05adaf9b84773375d500b4a4d Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Wed, 15 Sep 2021 22:29:30 -0700 Subject: [PATCH] cli: use `RepoCommandHelper::finish_transaction()` for git commands as well I don't know why I hadn't already updated these. Maybe I thought it wasn't necessary. That's probably true right now, but I want to make `jj git fetch` and `jj git refresh` automatically rebase commits when branches were updated on a remote or in the underlying Git repo. We want to make sure that the working copy also gets updated then. --- src/commands.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/commands.rs b/src/commands.rs index 687ca6355..cd813f85d 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -3223,14 +3223,14 @@ fn cmd_git_fetch( _git_matches: &ArgMatches, cmd_matches: &ArgMatches, ) -> Result<(), CommandError> { - let repo_command = command.repo_helper(ui)?; + let mut repo_command = command.repo_helper(ui)?; let repo = repo_command.repo(); let git_repo = get_git_repo(repo.store())?; let remote_name = cmd_matches.value_of("remote").unwrap(); let mut tx = repo_command.start_transaction(&format!("fetch from git remote {}", remote_name)); git::fetch(tx.mut_repo(), &git_repo, remote_name) .map_err(|err| CommandError::UserError(err.to_string()))?; - tx.commit(); + repo_command.finish_transaction(ui, tx)?; Ok(()) } @@ -3305,7 +3305,7 @@ fn cmd_git_push( _git_matches: &ArgMatches, cmd_matches: &ArgMatches, ) -> Result<(), CommandError> { - let repo_command = command.repo_helper(ui)?; + let mut repo_command = command.repo_helper(ui)?; let repo = repo_command.repo(); let remote_name = cmd_matches.value_of("remote").unwrap(); @@ -3402,7 +3402,7 @@ fn cmd_git_push( let mut tx = repo_command.start_transaction("import git refs"); git::import_refs(tx.mut_repo(), &git_repo) .map_err(|err| CommandError::UserError(err.to_string()))?; - tx.commit(); + repo_command.finish_transaction(ui, tx)?; Ok(()) } @@ -3412,13 +3412,13 @@ fn cmd_git_refresh( _git_matches: &ArgMatches, _cmd_matches: &ArgMatches, ) -> Result<(), CommandError> { - let repo_command = command.repo_helper(ui)?; + let mut repo_command = command.repo_helper(ui)?; let repo = repo_command.repo(); let git_repo = get_git_repo(repo.store())?; let mut tx = repo_command.start_transaction("import git refs"); git::import_refs(tx.mut_repo(), &git_repo) .map_err(|err| CommandError::UserError(err.to_string()))?; - tx.commit(); + repo_command.finish_transaction(ui, tx)?; Ok(()) }