History

conversions from Rc to arc for Handle (#301)

Sebastian Thiel committed 4 years ago

Commit c19331e1 parent 5f29c0f4 files · +80 −18Browse files

Showing the changes to gitoxide-core/src (1 of 4 files). Show all

Unified · Split

gitoxide-core/src/index/checkout.rs+21−13
@@ -68,24 +68,29 @@ pub fn checkout_exclusive( · 67 unmodified lines
6868 bytes.init(None, git::progress::bytes());
6969
7070 let start = std::time::Instant::now();
71+ let no_repo = repo.is_none();
7172 let checkout::Outcome {
7273 errors,
7374 collisions,
7475 files_updated,
75− } = match &repo {
76+ bytes_written,
77+ } = match repo {
7678 Some(repo) => git::worktree::index::checkout(
7779 &mut index,
7880 dest_directory,
79− |oid, buf| {
80− repo.objects.find_blob(oid, buf).ok();
81− if empty_files {
82− // We always want to query the ODB here…
83− repo.objects.find_blob(oid, buf)?;
84− buf.clear();
85− // …but write nothing
86− Ok(git::objs::BlobRef { data: buf })
87− } else {
88− repo.objects.find_blob(oid, buf)
81+ {
82+ let objects = repo.objects.into_arc()?;
83+ move |oid, buf| {
84+ objects.find_blob(oid, buf).ok();
85+ if empty_files {
86+ // We always want to query the ODB here…
87+ objects.find_blob(oid, buf)?;
88+ buf.clear();
89+ // …but write nothing
90+ Ok(git::objs::BlobRef { data: buf })
91+ } else {
92+ objects.find_blob(oid, buf)
93+ }
8994 }
9095 },
9196 &mut files,
@@ -111,9 +116,9 @@ pub fn checkout_exclusive( · 19 unmodified lines
111116 bytes.show_throughput(start);
112117
113118 progress.done(format!(
114− "Created {} {} files{}",
119+ "Created {} {} files{} ({})",
115120 files_updated,
116− repo.is_none().then(|| "empty").unwrap_or_default(),
121+ no_repo.then(|| "empty").unwrap_or_default(),
117122 should_interrupt
118123 .load(Ordering::Relaxed)
119124 .then(|| {
@@ -123,6 +128,9 @@ pub fn checkout_exclusive( · 3 unmodified lines
123128 )
124129 })
125130 .unwrap_or_default(),
131+ git_features::progress::bytes()
132+ .unwrap()
133+ .display(bytes_written as usize, None, None)
126134 ));
127135
128136 if !(collisions.is_empty() && errors.is_empty()) {