forked from mirrors/jj
cli: extract helper that resolves diff arguments for log-like commands
This commit is contained in:
parent
cdf3bfa55f
commit
b4d6c9e8da
2 changed files with 6 additions and 4 deletions
|
@ -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(),
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue