Skip to content

Commit

Permalink
export_refs: add or edit some comments (no-op)
Browse files Browse the repository at this point in the history
This is supposed to make `export_refs` a little more readable.
  • Loading branch information
ilyagr committed May 14, 2023
1 parent 88ed724 commit df46428
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions lib/src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,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,
Expand Down Expand Up @@ -329,8 +337,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
Expand All @@ -351,10 +359,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
}
}
Expand Down

0 comments on commit df46428

Please sign in to comment.