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
68 bytes.init(None, git::progress::bytes());68 bytes.init(None, git::progress::bytes());
69 69
70 let start = std::time::Instant::now();70 let start = std::time::Instant::now();
71 let no_repo = repo.is_none();
71 let checkout::Outcome {72 let checkout::Outcome {
72 errors,73 errors,
73 collisions,74 collisions,
74 files_updated,75 files_updated,
75 } = match &repo {76 bytes_written,
77 } = match repo {
76 Some(repo) => git::worktree::index::checkout(78 Some(repo) => git::worktree::index::checkout(
77 &mut index,79 &mut index,
78 dest_directory,80 dest_directory,
79 |oid, buf| {81 {
80 repo.objects.find_blob(oid, buf).ok();82 let objects = repo.objects.into_arc()?;
81 if empty_files {83 move |oid, buf| {
82 // We always want to query the ODB here…84 objects.find_blob(oid, buf).ok();
83 repo.objects.find_blob(oid, buf)?;85 if empty_files {
84 buf.clear();86 // We always want to query the ODB here…
85 // …but write nothing87 objects.find_blob(oid, buf)?;
86 Ok(git::objs::BlobRef { data: buf })88 buf.clear();
87 } else {89 // …but write nothing
88 repo.objects.find_blob(oid, buf)90 Ok(git::objs::BlobRef { data: buf })
91 } else {
92 objects.find_blob(oid, buf)
93 }
89 }94 }
90 },95 },
91 &mut files,96 &mut files,
@@ -111,9 +116,9 @@ pub fn checkout_exclusive( · 19 unmodified lines
111 bytes.show_throughput(start);116 bytes.show_throughput(start);
112 117
113 progress.done(format!(118 progress.done(format!(
114 "Created {} {} files{}",119 "Created {} {} files{} ({})",
115 files_updated,120 files_updated,
116 repo.is_none().then(|| "empty").unwrap_or_default(),121 no_repo.then(|| "empty").unwrap_or_default(),
117 should_interrupt122 should_interrupt
118 .load(Ordering::Relaxed)123 .load(Ordering::Relaxed)
119 .then(|| {124 .then(|| {
@@ -123,6 +128,9 @@ pub fn checkout_exclusive( · 3 unmodified lines
123 )128 )
124 })129 })
125 .unwrap_or_default(),130 .unwrap_or_default(),
131 git_features::progress::bytes()
132 .unwrap()
133 .display(bytes_written as usize, None, None)
126 ));134 ));
127 135
128 if !(collisions.is_empty() && errors.is_empty()) {136 if !(collisions.is_empty() && errors.is_empty()) {