fix(sync): use stderr for log prints

This commit is contained in:
qwjyh 2025-03-02 01:23:35 +09:00
parent d86d6fb898
commit 377bf82083

View file

@ -142,13 +142,13 @@ where
}) })
.transfer_progress(|progress| { .transfer_progress(|progress| {
if progress.received_objects() == progress.total_objects() { if progress.received_objects() == progress.total_objects() {
print!( eprint!(
"Resolving deltas {}/{}\r", "Resolving deltas {}/{}\r",
progress.indexed_deltas(), progress.indexed_deltas(),
progress.total_deltas() progress.total_deltas()
); );
} else { } else {
print!( eprint!(
"Received {}/{} objects ({}) in {} bytes\r", "Received {}/{} objects ({}) in {} bytes\r",
progress.received_objects(), progress.received_objects(),
progress.total_objects(), progress.total_objects(),
@ -156,7 +156,7 @@ where
progress.received_bytes(), progress.received_bytes(),
); );
} }
io::stdout().flush().unwrap(); io::stderr().flush().unwrap();
true true
}) })
.sideband_progress(|text| { .sideband_progress(|text| {
@ -210,7 +210,7 @@ fn pull(
.context("Failed to fetch (pull)")?; .context("Failed to fetch (pull)")?;
let stats = remote.stats(); let stats = remote.stats();
if stats.local_objects() > 0 { if stats.local_objects() > 0 {
println!( eprintln!(
"\rReceived {}/{} objects in {} bytes (used {} local objects)", "\rReceived {}/{} objects in {} bytes (used {} local objects)",
stats.indexed_objects(), stats.indexed_objects(),
stats.total_objects(), stats.total_objects(),
@ -218,7 +218,7 @@ fn pull(
stats.local_objects(), stats.local_objects(),
); );
} else { } else {
println!( eprintln!(
"\rReceived {}/{} objects in {} bytes", "\rReceived {}/{} objects in {} bytes",
stats.indexed_objects(), stats.indexed_objects(),
stats.total_objects(), stats.total_objects(),
@ -259,7 +259,7 @@ fn pull(
None => String::from_utf8_lossy(ref_remote.name_bytes()).to_string(), None => String::from_utf8_lossy(ref_remote.name_bytes()).to_string(),
}; };
let msg = format!("Fast-Forward: Setting {} to id: {}", name, fetch_head.id()); let msg = format!("Fast-Forward: Setting {} to id: {}", name, fetch_head.id());
println!("{}", msg); eprintln!("{}", msg);
ref_remote ref_remote
.set_target(fetch_head.id(), &msg) .set_target(fetch_head.id(), &msg)
.context("failed to set target")?; .context("failed to set target")?;