git: remove workaround for "branch forget && git fetch"

As we now diff incoming git refs against our known remote branches, the problem
described in the comment no longer occurs. test_branch_forget_fetched_branch()
passes, and the inline comments in the test are still valid.
This commit is contained in:
Yuya Nishihara 2023-10-09 23:58:19 +09:00
parent 7d78ef60d1
commit 6bc19bfa95

View file

@ -960,43 +960,6 @@ pub fn fetch(
move |branch: &str| regex.as_ref().map(|r| r.is_match(branch)).unwrap_or(true)
};
// In non-colocated repositories, it's possible that `jj branch forget` was run
// at some point and no `jj git export` happened since.
//
// This would mean that remote-tracking branches, forgotten in the jj repo,
// still exist in the git repo. If the branches didn't move on the remote, and
// we fetched them, jj would think that they are unmodified and wouldn't
// resurrect them.
//
// Export will delete the remote-tracking branches in the git repo, so it's
// possible to fetch them again.
//
// For more details, see the `test_branch_forget_fetched_branch` test, and PRs
// #1714 and #1771
//
// Apart from `jj branch forget`, jj doesn't provide commands to manipulate
// remote-tracking branches, and local git branches don't affect fetch
// behaviors. So, it's unnecessary to export anything else.
//
// TODO: Create a command the user can use to reset jj's
// branch state to the git repo's state. In this case, `jj branch forget`
// doesn't work as it tries to delete the latter. One possible name is `jj
// git import --reset BRANCH`.
// TODO: Once the command described above exists, it should be mentioned in `jj
// help branch forget`.
let nonempty_branches: HashSet<_> = mut_repo
.view()
.local_branches()
.map(|(branch, _target)| branch.to_owned())
.collect();
// TODO: Inform the user if the export failed? In most cases, export is not
// essential for fetch to work.
let _ = export_some_refs(mut_repo, git_repo, |ref_name| {
to_remote_branch(ref_name, remote_name)
.map(|branch| branch_name_filter(branch) && !nonempty_branches.contains(branch))
.unwrap_or(false)
});
// Perform a `git fetch` on the local git repo, updating the remote-tracking
// branches in the git repo.
let mut remote = git_repo.find_remote(remote_name).map_err(|err| {