equal
deleted
inserted
replaced
550 ) -> Result<(), CommandError> { |
550 ) -> Result<(), CommandError> { |
551 paths.sort_unstable(); |
551 paths.sort_unstable(); |
552 // TODO: get the stdout lock once for the whole loop |
552 // TODO: get the stdout lock once for the whole loop |
553 // instead of in each write |
553 // instead of in each write |
554 for StatusPath { path, copy_source } in paths { |
554 for StatusPath { path, copy_source } in paths { |
555 let relative; |
555 let relative_path; |
556 let path = if let Some(relativize) = &self.relativize { |
556 let relative_source; |
557 relative = relativize.relativize(&path); |
557 let (path, copy_source) = if let Some(relativize) = |
558 &*relative |
558 &self.relativize |
|
559 { |
|
560 relative_path = relativize.relativize(&path); |
|
561 relative_source = |
|
562 copy_source.as_ref().map(|s| relativize.relativize(s)); |
|
563 (&*relative_path, relative_source.as_deref()) |
559 } else { |
564 } else { |
560 path.as_bytes() |
565 (path.as_bytes(), copy_source.as_ref().map(|s| s.as_bytes())) |
561 }; |
566 }; |
562 // TODO: Add a way to use `write_bytes!` instead of `format_bytes!` |
567 // TODO: Add a way to use `write_bytes!` instead of `format_bytes!` |
563 // in order to stream to stdout instead of allocating an |
568 // in order to stream to stdout instead of allocating an |
564 // itermediate `Vec<u8>`. |
569 // itermediate `Vec<u8>`. |
565 if !self.no_status { |
570 if !self.no_status { |
568 let linebreak = if self.print0 { b"\x00" } else { b"\n" }; |
573 let linebreak = if self.print0 { b"\x00" } else { b"\n" }; |
569 self.ui.write_stdout_labelled( |
574 self.ui.write_stdout_labelled( |
570 &format_bytes!(b"{}{}", path, linebreak), |
575 &format_bytes!(b"{}{}", path, linebreak), |
571 label, |
576 label, |
572 )?; |
577 )?; |
573 if let Some(source) = copy_source { |
578 if let Some(source) = copy_source.filter(|_| !self.no_status) { |
574 let label = "status.copied"; |
579 let label = "status.copied"; |
575 self.ui.write_stdout_labelled( |
580 self.ui.write_stdout_labelled( |
576 &format_bytes!(b" {}{}", source.as_bytes(), linebreak), |
581 &format_bytes!(b" {}{}", source, linebreak), |
577 label, |
582 label, |
578 )? |
583 )? |
579 } |
584 } |
580 } |
585 } |
581 Ok(()) |
586 Ok(()) |