From 1ef85e621aadf540f79793737dc8cd0d16c40fea Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Sat, 8 May 2021 22:06:40 -0700 Subject: [PATCH] cli: don't commit working copy more than once per command --- src/commands.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/commands.rs b/src/commands.rs index 5cadde0f8..de232c46f 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -131,6 +131,7 @@ fn get_repo(ui: &Ui, matches: &ArgMatches) -> Result, CommandE struct RepoCommand { settings: UserSettings, repo: Arc, + working_copy_committed: bool, // Whether the checkout should be updated to an appropriate successor when the transaction // finishes. This should generally be true for commands that rewrite commits. auto_update_checkout: bool, @@ -142,6 +143,7 @@ impl RepoCommand { Ok(RepoCommand { settings: ui.settings().clone(), repo, + working_copy_committed: false, auto_update_checkout: true, }) } @@ -173,8 +175,8 @@ impl RepoCommand { // reference pointing to the working copy commit. If it's a // type of reference that would get updated when the commit gets rewritten, then // we probably should create a new working copy commit. - if revision_str == "@" { - // TODO: Avoid committing every time this function is called. + if revision_str == "@" && !self.working_copy_committed { + self.working_copy_committed = true; self.commit_working_copy(); }