From 2842632b498dacd4d057c0d48b3183a75e989b94 Mon Sep 17 00:00:00 2001 From: Ilya Grigoriev Date: Thu, 11 May 2023 18:17:18 -0700 Subject: [PATCH] export_refs: add or edit some comments (no-op) This is supposed to make `export_refs` a little more readable. --- lib/src/git.rs | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/lib/src/git.rs b/lib/src/git.rs index 2c45c5e818..a5d15a8a4e 100644 --- a/lib/src/git.rs +++ b/lib/src/git.rs @@ -237,9 +237,17 @@ pub enum GitExportError { InternalGitError(#[from] git2::Error), } -/// Reflect changes made in the Jujutsu repo compared to our current view of the -/// Git repo in `mut_repo.view().git_refs()`. Returns a list of names of -/// branches that failed to export. +/// Export changes to branches made in the Jujutsu repo compared to our last +/// seen view of the Git repo in `mut_repo.view().git_refs()`. Returns a list of +/// names of branches that failed to export. +/// +/// We ignore changed branches that are conflicted (were also changed in the Git +/// repo compared to our last remembered view of the Git repo). These will be +/// marked conflicted by the next `jj git import`. +/// +/// We do not export tags and other refs at the moment, since these aren't +/// supposed to be modified by JJ. For them, the Git state is considered +/// authoritative. // TODO: Also indicate why we failed to export these branches pub fn export_refs( mut_repo: &mut MutableRepo, @@ -330,8 +338,8 @@ pub fn export_refs( let success = match old_oid { None => { if let Ok(git_ref) = git_repo.find_reference(&git_ref_name) { - // The branch was added in jj and in git. Iff git already pointed it to our - // desired target, we're good + // The branch was added in jj and in git. We're good if and only if git + // pointed it to our desired target. git_ref.target() == Some(new_oid) } else { // The branch was added in jj but still doesn't exist in git, so add it @@ -352,10 +360,10 @@ pub fn export_refs( } else { // The reference was probably updated in git if let Ok(git_ref) = git_repo.find_reference(&git_ref_name) { - // Iff it was updated to our desired target, we still consider it a success + // We still consider this a success if it was updated to our desired target git_ref.target() == Some(new_oid) } else { - // The reference was deleted in git + // The reference was deleted in git and moved in jj false } }