Showing the changes to src (4 of 8 files). Show all
Unified · Split
| @@ -22,15 +22,10 @@ pub fn main() -> Result<()> { · 21 unmodified lines | |||
| 22 | repository, | 22 | repository, |
| 23 | expansion, | 23 | expansion, |
| 24 | tips, | 24 | tips, |
| 25 | output_directory, | ||
| 25 | }) => { | 26 | }) => { |
| 26 | let (_handle, progress) = prepare(verbose, "pack-create", Some(core::pack::create::PROGRESS_RANGE)); | 27 | let (_handle, progress) = prepare(verbose, "pack-create", Some(core::pack::create::PROGRESS_RANGE)); |
| 27 | let has_tips = !tips.is_empty(); | 28 | let has_tips = !tips.is_empty(); |
| 28 | let stdout = stdout(); | ||
| 29 | let stdout_lock = stdout.lock(); | ||
| 30 | #[cfg(feature = "atty")] | ||
| 31 | if atty::is(atty::Stream::Stdout) { | ||
| 32 | anyhow::bail!("Refusing to output pack data stream to stdout.") | ||
| 33 | } | ||
| 34 | let input = if has_tips { | 29 | let input = if has_tips { |
| 35 | None | 30 | None |
| 36 | } else { | 31 | } else { |
| @@ -51,7 +46,7 @@ pub fn main() -> Result<()> { · 14 unmodified lines | |||
| 51 | repository.unwrap_or_else(|| PathBuf::from(".")), | 46 | repository.unwrap_or_else(|| PathBuf::from(".")), |
| 52 | tips, | 47 | tips, |
| 53 | input, | 48 | input, |
| 54 | stdout_lock, | 49 | output_directory, |
| 55 | DoOrDiscard::from(progress), | 50 | DoOrDiscard::from(progress), |
| 56 | core::pack::create::Context { | 51 | core::pack::create::Context { |
| 57 | expansion, | 52 | expansion, |
| @@ -176,6 +176,10 @@ pub struct PackCreate { · 175 unmodified lines | |||
| 176 | /// Possible values are "none" and "tree-traversal". Default is "none". | 176 | /// Possible values are "none" and "tree-traversal". Default is "none". |
| 177 | pub expansion: Option<core::pack::create::ObjectExpansion>, | 177 | pub expansion: Option<core::pack::create::ObjectExpansion>, |
| 178 | 178 | ||
| 179 | /// the directory into which to write the pack file. | ||
| 180 | #[argh(option, short = 'o')] | ||
| 181 | pub output_directory: PathBuf, | ||
| 182 | |||
| 179 | /// the tips from which to start the commit graph iteration. | 183 | /// the tips from which to start the commit graph iteration. |
| 180 | /// | 184 | /// |
| 181 | /// If empty, we expect to read objects on stdin and default to 'none' as expansion mode. | 185 | /// If empty, we expect to read objects on stdin and default to 'none' as expansion mode. |
| @@ -28,23 +28,16 @@ pub fn main() -> Result<()> { · 27 unmodified lines | |||
| 28 | repository, | 28 | repository, |
| 29 | expansion, | 29 | expansion, |
| 30 | tips, | 30 | tips, |
| 31 | output_directory, | ||
| 31 | } => { | 32 | } => { |
| 32 | let has_tips = !tips.is_empty(); | 33 | let has_tips = !tips.is_empty(); |
| 33 | let has_tui = progress; | ||
| 34 | if atty::is(if has_tui { | ||
| 35 | atty::Stream::Stderr | ||
| 36 | } else { | ||
| 37 | atty::Stream::Stdout | ||
| 38 | }) { | ||
| 39 | anyhow::bail!("Refusing to output pack data stream to stderr.") | ||
| 40 | } | ||
| 41 | prepare_and_run( | 34 | prepare_and_run( |
| 42 | "pack-create", | 35 | "pack-create", |
| 43 | verbose, | 36 | verbose, |
| 44 | progress, | 37 | progress, |
| 45 | progress_keep_open, | 38 | progress_keep_open, |
| 46 | core::pack::create::PROGRESS_RANGE, | 39 | core::pack::create::PROGRESS_RANGE, |
| 47 | move |progress, out, err| { | 40 | move |progress, _out, _err| { |
| 48 | let input = if has_tips { | 41 | let input = if has_tips { |
| 49 | None | 42 | None |
| 50 | } else { | 43 | } else { |
| @@ -67,11 +60,7 @@ pub fn main() -> Result<()> { · 16 unmodified lines | |||
| 67 | }), | 60 | }), |
| 68 | }; | 61 | }; |
| 69 | let progress = git_features::progress::DoOrDiscard::from(progress); | 62 | let progress = git_features::progress::DoOrDiscard::from(progress); |
| 70 | if has_tui { | 63 | core::pack::create(repository, tips, input, output_directory, progress, context) |
| 71 | core::pack::create(repository, tips, input, err, progress, context) | ||
| 72 | } else { | ||
| 73 | core::pack::create(repository, tips, input, out, progress, context) | ||
| 74 | } | ||
| 75 | }, | 64 | }, |
| 76 | ) | 65 | ) |
| 77 | } | 66 | } |
| @@ -56,6 +56,10 @@ pub enum Subcommands { · 55 unmodified lines | |||
| 56 | /// Possible values are "none" and "tree-traversal". Default is "none". | 56 | /// Possible values are "none" and "tree-traversal". Default is "none". |
| 57 | expansion: Option<core::pack::create::ObjectExpansion>, | 57 | expansion: Option<core::pack::create::ObjectExpansion>, |
| 58 | 58 | ||
| 59 | /// The directory into which to write the pack file. | ||
| 60 | #[clap(long, short = 'o')] | ||
| 61 | output_directory: PathBuf, | ||
| 62 | |||
| 59 | /// the tips from which to start the commit graph iteration. | 63 | /// the tips from which to start the commit graph iteration. |
| 60 | /// | 64 | /// |
| 61 | /// If empty, we expect to read objects on stdin and default to 'none' as expansion mode. | 65 | /// If empty, we expect to read objects on stdin and default to 'none' as expansion mode. |