ok/jj
1
0
Fork 0
forked from mirrors/jj

cli: extract helper that resolves diff arguments for log-like commands

This commit is contained in:
Yuya Nishihara 2022-12-13 23:08:03 +09:00
parent cdf3bfa55f
commit b4d6c9e8da
2 changed files with 6 additions and 4 deletions

View file

@ -1513,8 +1513,7 @@ fn cmd_log(ui: &mut Ui, command: &CommandHelper, args: &LogArgs) -> Result<(), C
};
let store = repo.store();
let diff_format = (args.patch || args.diff_format.git || args.diff_format.summary)
.then(|| diff_util::diff_format_for(ui, &args.diff_format));
let diff_format = diff_util::diff_format_for_log(ui, &args.diff_format, args.patch);
let template_string = match &args.template {
Some(value) => value.to_string(),
@ -1654,8 +1653,7 @@ fn cmd_obslog(ui: &mut Ui, command: &CommandHelper, args: &ObslogArgs) -> Result
.view()
.get_wc_commit_id(&workspace_id);
let diff_format = (args.patch || args.diff_format.git || args.diff_format.summary)
.then(|| diff_util::diff_format_for(ui, &args.diff_format));
let diff_format = diff_util::diff_format_for_log(ui, &args.diff_format, args.patch);
let template_string = match &args.template {
Some(value) => value.to_string(),

View file

@ -66,6 +66,10 @@ pub fn diff_format_for(ui: &Ui, args: &DiffFormatArgs) -> DiffFormat {
}
}
pub fn diff_format_for_log(ui: &Ui, args: &DiffFormatArgs, patch: bool) -> Option<DiffFormat> {
(patch || args.git || args.summary).then(|| diff_format_for(ui, args))
}
fn default_diff_format(ui: &Ui) -> DiffFormat {
match ui.settings().config().get_string("diff.format").as_deref() {
Ok("summary") => DiffFormat::Summary,