From 1330381fc67bd1e0d2db206d801d0b9c328cf226 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Fri, 26 Jan 2024 17:13:34 +0900 Subject: [PATCH] cli: add inline comment about racy Git HEAD updates This is the source of the problem I noticed when debugging #924 and #1608. I don't think this can be easily fixed, so let's document it. --- cli/src/cli_util.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cli/src/cli_util.rs b/cli/src/cli_util.rs index bf07a5ba2..828787d7a 100644 --- a/cli/src/cli_util.rs +++ b/cli/src/cli_util.rs @@ -841,6 +841,16 @@ impl WorkspaceCommandHelper { return Ok(()); } + // TODO: There are various ways to get duplicated working-copy + // commits. Some of them could be mitigated by checking the working-copy + // operation id after acquiring the lock, but that isn't enough. + // + // - moved HEAD was observed by multiple jj processes, and new working-copy + // commits are created concurrently. + // - new HEAD was exported by jj, but the operation isn't committed yet. + // - new HEAD was exported by jj, but the new working-copy commit isn't checked + // out yet. + let mut tx = tx.into_inner(); let old_git_head = self.repo().view().git_head().clone(); let new_git_head = tx.mut_repo().view().git_head().clone();