summaryrefslogtreecommitdiff
path: root/src/tests/test_example_diffs.rs
AgeCommit message (Collapse)Author
2025-08-03Styled zero lines fixmainThomas Otto
With `interactive.diffFilter = delta --color-only` delta is called by e.g. `git add -p`, but in this mode git hides the terminal from the pager. Plus/minus lines correctly use ANSI sequences to paint up to to the end of the line, but zero lines always use spaces. This needs the terminal width, but it is not available for diffFilter. So the fallback of 80 is used, and zero styles did not extend to the full terminal width. Since zero lines are only rarely styled (e.g. via `--zero-style='syntax "#1d1f21" dim'`), this was never noticed. This also crashed delta when a zero line was longer than 80.
2024-07-22Add --max-syntax-highlighting-length, set to 400Thomas Otto
--max-line-length increased to 3000, highlighting now stops after 400 characters. In that case the highlighting may be incorrect until it is reset for the next hunk.
2024-07-09Make relative-paths work with binary filesThomas Otto
`relativize_path_maybe()` was not called in this case. Added test and converted a few existing ones to insta.
2024-07-07tests: set terminal width to 43 (#1741)Thomas Otto
Make tests more deterministic by not allowing them to "see" the current terminal width.
2024-05-04Repair --default-language, and highlight using full filename (#1549)Thomas Otto
* Fix clippy warnings * Repair --default-language, and highlight using full filename Fixed that the "txt" fallback was used instead of --default-language And when looking for syntax highlighting, keep the filename around as long as possible. Using simple custom logic (filename > 4) a Makefile can be highlighted with make syntax, but a 'cc' or 'ini' file does not get treated like a *.cc or *.ini file. Currently the underlying highlighting lib syntect and the sublime syntax definitions can not make this distinction (<http://www.sublimetext.com/docs/syntax.html>).
2024-03-16Honor default-language option (#1655)Pawel Dominiak
* Honor default-language option * Add tests for default-language option --------- Co-authored-by: Dan Davison <dandavison7@gmail.com>
2024-03-12Preserve "Binary files" line in color_only mode (#1649)Pawel Dominiak
Closes #320
2024-03-02Fix headers of modified binary files, closes #1621 (#1629)Paul
2024-02-19Accept clippy suggestions (#1632)Dan Davison
2023-11-20Make hunk header code fragment display optional (#1568)Zack Cerza
Fixes: #1032
2023-08-05Improve binary file added output (#1502)Sondeyy
* added binary file cases tests * add binary file cases handling * remove unnecessary return and comma
2023-06-02Increase number of characters shown in submodule hashesDan Davison
Fixes #1408
2023-05-17Fix warning highlight for trailing whitespace (#1037)William Escande
Fix #137
2023-05-08Fix submodule diff parsing (#1413)Thomas Otto
Added support for an optional -dirty hash suffix which is present in `git diff` output when files were changed in a submodule.
2023-03-03Spelling (#1257)Josh Soref
Corrects misspellings identified by https://github.com/marketplace/actions/check-spelling Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-02-28Fix clippy warnings (#1298)nickelc
* Fix clippy warnings - `clippy::uninlined_format_args` * Fix clippy warnings - `clippy::clone_on_copy` - `clippy::explicit_auto_deref` - `clippy::iter_cloned_collect` - `clippy::map_clone` - `clippy::needless_borrow` - `clippy::needless_lifetimes` - `clippy::needless_return` - `clippy::redundant_clone` - `clippy::redundant_field_names` - `clippy::seek_to_start_instead_of_rewind` - `clippy::unnecessary_cast` - `clippy::unused_unit`
2022-06-22Fix whole-file changes being attributed to the wrong commit in "git log" outputBjörn Steinbrink
The pending buffer for whole-file changes is currently only flushed when encountering a new diff header. This leads to it being carried over across commit boundaries in cases where multiple commits are shown. To fix this, we simply need to flush the buffered data on a commit boundary as well. Fixes #1089
2022-03-30Add support for irreversible-deleteWilliam Escande
Fix #128 Add support for `git diff -D` (aka irreversible delete) The patch is adding a title for removed file, even when there is no file content in the diff output Without the patch, there was no output related to the file at all
2022-03-07Add failing test for #1002Dan Davison
2022-01-16Drop deprecated options (#914)Dan Davison
Drop deprecated options Fixes #891
2022-01-05Handle a mode change on a renamed file. (#875)Wayne Davison
* Handle a mode change on a renamed file. I changed the diff parsing to cache the mode info from the old/new mode lines until the parsing bumps into the start of the actual related diff, finds the diff line for an unrelated diff, or runs out of input. This allows the mode info to be output in conjunction with a file event instead of as a separate heading (that used to have an empty name when the mode change was for a rename). The mode info is passed down into the draw routines as a separate "addendum" string that the draw code can use as it likes. Currently that means that it appends the addendum string to the non-raw string in parens. I imagine that future draw routines could decide to put it in a separate box or some other per-routine method. There is currently a single function in src/handlers/draw.rs that joins the strings in the same way for everyone. A couple examples of how the new code looks: Δ foo.rs (mode +x) ─────────────────────────────────────────────────── renamed: old-longer-name → shorter-name (mode +x) ─────────────────────────────────────────────────── Would it look better on its own line? Δ foo.rs • mode +x ─────────────────────────────────────────────────── renamed: old-longer-name → shorter-name • mode +x ─────────────────────────────────────────────────── Would it look better appended after a "•" character? Δ foo.rs • mode +x ─────────────────────────────────────────────────── renamed: old-longer-name → shorter-name • mode +x ─────────────────────────────────────────────────── Should it be a user option? If so, we can do that later.
2022-01-04DeltaTest improvements (#876)Wayne Davison
* DeltaTest improvements - Added .expect_contains(), .expect_raw_contains(), and .expect_contains_once() member functions to DeltaTestOutput. These functions also output some helpful debug info when the assert fails. - Separated .with_config_and_input() into .with_config() and (the tweaked) .with_input(). - Made .with_config() create a DeltaTest object (like .with() does). - Renamed .with() as .with_args(). - Moved .explain_ansi() from DeltaTestOutput to DeltaTest, which must now be called prior to .with_input() since the latter stashes off both the raw_output & the processed output in the object. - Changed .expect() and .expect_skip() to return Self so that they can continue a chain of multiple expect calls (e.g. a series of partial matches with different skip values). - The processed output text can be accessed via `test_obj.output` (see also `test_obj.raw_output`). - Renamed .expect_skip() to .expect_after_skip(). - Changed .expect() to start at the first line. - Added .expect_after_header() that works like the old .expect(). - Renamed lines_match() to assert_lines_match() and made it match all lines (no skip number). - Added assert_lines_match_after_skip() to work like the old lines_match() function, but with the .expect_after_skip() arg order. - Converted some old-style tests into DeltaTest style tests. - Renamed set_cfg as set_config
2022-01-01Put file-modified label in front of mode changes.Wayne Davison
When using `--navigate` with files that get their mode modified, the file-modified label was not being prefixed, so these changes were not being marked as skip destinations. This is particularly bad if a file has line changes along with the mode change AND the user has an empty hunk label (since that would make the entire file's changes get skipped with an "n"). I added a test of a mode-change with a line-change, and a test for a mode change where the old & new mode values are not one of the two expected value-pairs. I also used format_file() on the mode filenames since the other format() calls were using it.
2021-12-09Store raw_line in HunkZero, as HunkMinus and HunkPlusDan Davison
ref #829
2021-12-05Gracefully handle failure to parse hunk headerDan Davison
Fixes #765
2021-12-05Display merge conflictsDan Davison
2021-12-05Handle combined diff formatDan Davison
With this commit combined diff format (https://git-scm.com/docs/git-diff#_combined_diff_format) is handled appropriately. However, there is no special handling of merge conflict markers. Fixes #189, #736
2021-11-29Rename: FileMeta => DiffHeaderDan Davison
2021-11-22Allow custom colors to be defined in gitconfig (#788)Dan Davison
Similar to 7a64fa5a26314c05c811d7c1276388a4963fa0bd which allowed custom styles. Custom styles must end in -style, but colors can be anything. It unfortunately seems not to be possible currently to store a global reference to git config, hence the size of this commit (passing the reference down the call stack).
2021-11-21Set is_emph explicitly on *-emph-stylesDan Davison
This addresses a bug triggered by doing things like minus-style = minus-emph-style That was causing the is_emph bit to be set on minus-style, with undesirable consequences.
2021-11-17Use file-modified-label consistently.Wayne Davison
When filtering a diff and when directly diffing files/dirs, use the modified label that is output when interpreting git diffs. This gets rid of the "comparing:" prefix (which was otherwise missing from the --navigate regex) and ensures that a direct diff has a label to stop at when --navigate is enabled. One of the unified-diff tests now uses --file-modified-label=comparing: to generate the same output as before, while the other now uses --navigate to get a delta char label.
2021-11-10Remove +/- line prefix instead of substituting a spaceThomas Otto
Simplifies line handling and printing by removing a "magical" 1-offset previously required in various locations. Now explicitly prepend "" in `tokenize()`.
2021-08-23More minimalistic display of submodule (short) diffs (#700)Dan Davison
* Rename state machine state: Submodule -> SubmoduleLog * More minimalistic display of submodule log diffs Partially fixes #662 * Defer emitting hunk header until first true hunk line A consequence is that we do not emit the (pseudo) hunk header in submodule (short) state; see #662.
2021-08-22662 submodule diffs (#699)Dan Davison
2021-08-20Fix empty line highlighting (#642)Thomas Otto
2021-07-22Fix the empty result issue in add -p (#664)norisio
* Strip a neglected CR character in ingest_line * Add test_orphan_carriage_return_is_stripped * Eliminate redundant assignment in if-let-Some
2021-07-10Clippy: don't nest module inside module with same nameDan Davison
2021-07-10Clippy: don't nest module inside module with same nameDan Davison
2021-06-25Fix filenames with spaces (#643)Dan Davison
* Fix parsing of file path from diff line Fixes #625 * Parse diff line only if needed * Add test of diff of filenames with spaces * Strip trailing tab inserted by git when file path contains space git appears to add a trailing tab character when the file name contains a space: $ git diff --no-index b.file 01g\ -\ Text | cat -A diff·--git·a/b.file·b/01g·-·Text␊ index·e69de29..d00491f·100644␊ ---·a/b.file␊ +++·b/01g·-·Text├──┤␊ @@·-0,0·+1·@@␊ +1␊
2021-05-25Add hyperlinks-commit-link-format option (#614)Dan Davison
* Refactor: hyperlinks utility * Add hyperlinks-commit-link-format option Fixes #613
2021-05-20Emit 'mode [-+]x' instead of full file permission bits (#607)Dan Davison
Ref #583
2021-05-20Emit description of file mode change (#605)Dan Davison
Fixes #583
2021-04-23Deprecate --24-bit-color, replacing with --true-color (#571)Dan Davison
Fixes #567
2020-12-31Add styles for file path and line number in hunk headerDan Davison
Fixes #481
2020-12-29Hyperlink file and line number (#479)Dan Davison
Hyperlinks seem to be rendering with just the file path underlined, at least in iTerm2, whereas the intention was for the file and line-number to be rendered jointly (both underlined) as a hyperlink. The link structure is ␛]8;;file-line-column:///Users/dan/src/delta/src/hunk_header.rs:114␛\␛[38;5;1msrc/hunk_header.rs␛[0m:␛[38;5;4m114␛[0m␛]8;;␛\:
2020-12-27Add tests of hunk-header-style special attributesDan Davison
2020-12-27Use special style attribute to control line-number in hunk-headerDan Davison
2020-12-27Fix testsDan Davison
2020-12-27Fix testsDan Davison
2020-12-26Add failing test of hunk header with file and no fragDan Davison
Ref #309