Remove --missing-as-empty

pull/502/head
Wilfred Hughes 2023-03-17 08:40:21 +07:00
parent 3263612150
commit 1e9f437688
4 changed files with 7 additions and 23 deletions

@ -1,5 +1,10 @@
## 0.46 (unreleased)
### Command Line Interface
Removed the option `--missing-as-empty`. This is no longer needed as
difftastic handles `/dev/null` gracefully on all platforms.
### Parsing
Added support for Ada.

@ -3,7 +3,6 @@
use std::io::Read;
use std::{
fs,
io::ErrorKind::*,
path::{Path, PathBuf},
};
@ -13,11 +12,7 @@ use walkdir::WalkDir;
use crate::exit_codes::EXIT_BAD_ARGUMENTS;
use crate::options::FileArgument;
pub fn read_files_or_die(
lhs_path: &FileArgument,
rhs_path: &FileArgument,
missing_as_empty: bool,
) -> (Vec<u8>, Vec<u8>) {
pub fn read_files_or_die(lhs_path: &FileArgument, rhs_path: &FileArgument) -> (Vec<u8>, Vec<u8>) {
let lhs_res = read_file_arg(lhs_path);
let rhs_res = read_file_arg(rhs_path);
@ -25,12 +20,6 @@ pub fn read_files_or_die(
// Both files exist, the happy case.
(Ok(lhs_src), Ok(rhs_src)) => (lhs_src, rhs_src),
// Proceed if we've been given two paths and only one
// exists. This is important for mercurial diffs when a file
// has been removed.
(Ok(lhs_src), Err(e)) if missing_as_empty && e.kind() == NotFound => (lhs_src, vec![]),
(Err(e), Ok(rhs_src)) if missing_as_empty && e.kind() == NotFound => (vec![], rhs_src),
(lhs_res, rhs_res) => {
// Something else went wrong. Print both errors
// encountered.

@ -171,7 +171,6 @@ fn main() {
Mode::Diff {
diff_options,
display_options,
missing_as_empty,
set_exit_code,
language_override,
lhs_path,
@ -238,7 +237,6 @@ fn main() {
&rhs_path,
&display_options,
&diff_options,
missing_as_empty,
language_override,
);
print_diff_result(&display_options, &diff_result);
@ -282,10 +280,9 @@ fn diff_file(
rhs_path: &FileArgument,
display_options: &DisplayOptions,
diff_options: &DiffOptions,
missing_as_empty: bool,
language_override: Option<parse::guess_language::Language>,
) -> DiffResult {
let (lhs_bytes, rhs_bytes) = read_files_or_die(lhs_path, rhs_path, missing_as_empty);
let (lhs_bytes, rhs_bytes) = read_files_or_die(lhs_path, rhs_path);
diff_file_content(
lhs_display_path,
rhs_display_path,
@ -621,7 +618,6 @@ fn diff_directories<'a>(
&FileArgument::NamedPath(rhs_path),
&display_options,
&diff_options,
true,
language_override,
)
})

@ -326,7 +326,6 @@ pub enum Mode {
Diff {
diff_options: DiffOptions,
display_options: DisplayOptions,
missing_as_empty: bool,
set_exit_code: bool,
language_override: Option<guess_language::Language>,
/// The path where we can read the LHS file. This is often a
@ -518,10 +517,6 @@ pub fn parse_args() -> Mode {
let print_unchanged = !matches.is_present("skip-unchanged");
// TODO: is this necessary now we handle /dev/null as an empty
// file on all platforms?
let missing_as_empty = matches.is_present("missing-as-empty");
let set_exit_code = matches.is_present("exit-code");
let check_only = matches.is_present("check-only");
@ -549,7 +544,6 @@ pub fn parse_args() -> Mode {
Mode::Diff {
diff_options,
display_options,
missing_as_empty,
set_exit_code,
language_override,
lhs_path,