forked from mirrors/jj
git: when fetching, prune refs that have been deleted on the remote
Otherwise remote-tracking branches just pile up. It seems that both git and libgit2 remove the remote-tracking branch when you push a deletion, so `jj branch --delete foo; jj git push --branch foo` already sees `foo` disappear locally as well. However, if a branch has been deleted on the remote, we would never know before this change.
This commit is contained in:
parent
8b8aff171e
commit
d555e0c326
1 changed files with 2 additions and 0 deletions
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
|
use git2::FetchPrune;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
use crate::commit::Commit;
|
use crate::commit::Commit;
|
||||||
|
@ -144,6 +145,7 @@ pub fn fetch(
|
||||||
});
|
});
|
||||||
let mut fetch_options = git2::FetchOptions::new();
|
let mut fetch_options = git2::FetchOptions::new();
|
||||||
fetch_options.remote_callbacks(callbacks);
|
fetch_options.remote_callbacks(callbacks);
|
||||||
|
fetch_options.prune(FetchPrune::On);
|
||||||
let refspec: &[&str] = &[];
|
let refspec: &[&str] = &[];
|
||||||
remote.fetch(refspec, Some(&mut fetch_options), None)?;
|
remote.fetch(refspec, Some(&mut fetch_options), None)?;
|
||||||
import_refs(mut_repo, git_repo).map_err(|err| match err {
|
import_refs(mut_repo, git_repo).map_err(|err| match err {
|
||||||
|
|
Loading…
Reference in a new issue