mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-15 16:53:25 +00:00
cli: inline diff_util::diff_as_bytes()
I'll add a similar function that uses show_patch() instead of show_diff(), and I don't think it's worth duplicating _as_bytes() part for that.
This commit is contained in:
parent
5076622598
commit
e7d9e1ff9c
2 changed files with 5 additions and 23 deletions
|
@ -58,7 +58,7 @@ use crate::cli_util::{
|
|||
};
|
||||
use crate::config::FullCommandArgs;
|
||||
use crate::diff_util::{self, DiffFormat, DiffFormatArgs};
|
||||
use crate::formatter::Formatter;
|
||||
use crate::formatter::{Formatter, PlainTextFormatter};
|
||||
use crate::graphlog::{AsciiGraphDrawer, Edge};
|
||||
use crate::progress::Progress;
|
||||
use crate::template_parser::TemplateParser;
|
||||
|
@ -2464,7 +2464,9 @@ fn description_template_for_cmd_split(
|
|||
from_tree: &Tree,
|
||||
to_tree: &Tree,
|
||||
) -> Result<String, CommandError> {
|
||||
let diff_summary_bytes = diff_util::diff_as_bytes(
|
||||
let mut diff_summary_bytes = Vec::new();
|
||||
diff_util::show_diff(
|
||||
&mut PlainTextFormatter::new(&mut diff_summary_bytes),
|
||||
workspace_command,
|
||||
from_tree,
|
||||
to_tree,
|
||||
|
|
|
@ -29,7 +29,7 @@ use jujutsu_lib::tree::{Tree, TreeDiffIterator};
|
|||
use jujutsu_lib::{conflicts, diff, files, rewrite, tree};
|
||||
|
||||
use crate::cli_util::{CommandError, WorkspaceCommandHelper};
|
||||
use crate::formatter::{Formatter, PlainTextFormatter};
|
||||
use crate::formatter::Formatter;
|
||||
use crate::ui::Ui;
|
||||
|
||||
#[derive(clap::Args, Clone, Debug)]
|
||||
|
@ -139,26 +139,6 @@ pub fn show_patch(
|
|||
)
|
||||
}
|
||||
|
||||
pub fn diff_as_bytes(
|
||||
workspace_command: &WorkspaceCommandHelper,
|
||||
from_tree: &Tree,
|
||||
to_tree: &Tree,
|
||||
matcher: &dyn Matcher,
|
||||
formats: &[DiffFormat],
|
||||
) -> Result<Vec<u8>, CommandError> {
|
||||
let mut diff_bytes: Vec<u8> = vec![];
|
||||
let mut formatter = PlainTextFormatter::new(&mut diff_bytes);
|
||||
show_diff(
|
||||
&mut formatter,
|
||||
workspace_command,
|
||||
from_tree,
|
||||
to_tree,
|
||||
matcher,
|
||||
formats,
|
||||
)?;
|
||||
Ok(diff_bytes)
|
||||
}
|
||||
|
||||
fn show_color_words_diff_hunks(
|
||||
left: &[u8],
|
||||
right: &[u8],
|
||||
|
|
Loading…
Reference in a new issue