When called with a single path, require conflict markers

Fixes #585
pull/614/head
Wilfred Hughes 2023-12-29 19:39:44 +07:00
parent c180fb52a9
commit 8b90c95e01
3 changed files with 14 additions and 7 deletions

@ -12,6 +12,11 @@ annotations in Haskell.
Fixed a rare crash when the last non-blank line had changes for
certain parsers, particularly YAML.
### Command Line Interface
Difftastic now errors if given a single path, unless that file
contains conflict markers. Previously this was a warning.
### Build
Difftastic now requires Rust 1.63 to build.

@ -47,6 +47,7 @@ extern crate log;
use display::style::print_warning;
use log::info;
use mimalloc::MiMalloc;
use options::USAGE;
use crate::conflicts::apply_conflict_markers;
use crate::conflicts::START_LHS_MARKER;
@ -406,13 +407,14 @@ fn diff_conflicts_file(
};
if conflict_files.num_conflicts == 0 {
print_warning(
&format!(
"Expected a file with conflict markers {}, but none were found. See --help for usage instructions.",
START_LHS_MARKER,
),
display_options,
eprintln!(
"error: Difftastic requires two paths, or a single file with conflict markers {}.\n",
START_LHS_MARKER,
);
eprintln!("USAGE:\n\n {}\n", USAGE);
eprintln!("For more information try --help");
std::process::exit(EXIT_BAD_ARGUMENTS);
}
let lhs_name = match conflict_files.lhs_name {

@ -23,7 +23,7 @@ pub(crate) const DEFAULT_PARSE_ERROR_LIMIT: usize = 0;
pub(crate) const DEFAULT_TAB_WIDTH: usize = 8;
const USAGE: &str = concat!(env!("CARGO_BIN_NAME"), " [OPTIONS] OLD-PATH NEW-PATH");
pub(crate) const USAGE: &str = concat!(env!("CARGO_BIN_NAME"), " [OPTIONS] OLD-PATH NEW-PATH");
#[derive(Debug, Clone, Copy)]
pub(crate) enum ColorOutput {