| Age | Commit message (Collapse) | Author |
|
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.
|
|
--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.
|
|
`relativize_path_maybe()` was not called in this case. Added
test and converted a few existing ones to insta.
|
|
Make tests more deterministic by not allowing them
to "see" the current terminal width.
|
|
Insta makes writing new tests or performing changes which update the
expected value(s) easier. The new reference data can be reviewed
and inserted/updated automatically by `cargo insta review` (after
`cargo install cargo-insta`, but that tool is optional).
The snapshots are stored inline using the `@""` syntax and not in
separate files because the delta test output is small and designed to
be human readable.
See https://insta.rs/#hello-snapshot-testing
and https://docs.rs/insta/1.39.0/insta/
|
|
* Fix unused variables
* Don't read git files when --no-gitconfig is given
Despite starting delta with `--no-gitconfig`, strace still shows
that `.git/config` etc. files are accessed. By no longer doing
that it is very clear that no config options are read from there.
|
|
|
|
* 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>).
|
|
* Honor default-language option
* Add tests for default-language option
---------
Co-authored-by: Dan Davison <dandavison7@gmail.com>
|
|
Closes #320
|
|
|
|
|
|
Fixes: #1032
|
|
* added binary file cases tests
* add binary file cases handling
* remove unnecessary return and comma
|
|
Fixes #1408
|
|
Fix #137
|
|
Added support for an optional -dirty hash suffix which is present
in `git diff` output when files were changed in a submodule.
|
|
|
|
Corrects misspellings identified by https://github.com/marketplace/actions/check-spelling
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
|
|
* 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`
|
|
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
|
|
This allow to no longer ignore some tests (marked previously as FIXME)
by storing the env at the start of the program (Or creating a custom env
for test purpose)
This centralize almost alls calls to std::env inside one wrapper
Add a test profile to increase speed for testing (5min -> 20sec on my
machine)
clean a few code style like this:
```
if Some(value) = ...
if value
```
to
```
if Some(true) = ...
```
Co-authored-by: William Escande <wescande@google.com>
|
|
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
|
|
|
|
Fix file paths and hyperlinks
With this commit the target of a hyperlink should always be an absolute path. This should be true for all file hyperlinks, e.g.
- File hyperlink
- Hunk header hyperlink
- Line number hyperlink
Fixes #890
|
|
There is no such thing as "Center Align" with discrete terminal cells. In
some cases a decision has to be made whether to use the left or the right
cell, e.g. when centering one char in 4 cells: "_X__" or "__X_".
The format!() center/^ default is left, but when padding numbers these
are now aligned to the right if required. Strings remain left-aligned.
|
|
Drop deprecated options
Fixes #891
|
|
* 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.
|
|
Only cloneable when testing, the types git2::Config and
git2::Repository in GitConfig contain C pointers and can't
really be cloned.
|
|
* 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
|
|
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.
|
|
|
|
|
|
|
|
|
|
|
|
ref #829
|
|
Using a syntax similar to the builder pattern:
`DeltaTest::with([config options]).with_input(DIFF).expect(lines)`
plus `.explain_ansi()` to pretty-print ansi codes and `.inspect()` to
print the to-be-tested output.
Rewrite a few tests using it and add ansi tests for
--line-fill-method=<spaces|ansi>
|
|
Fixes #765
|
|
|
|
|
|
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
|
|
|
|
|
|
- Factor out a new function update_diff_style_sections
- Use MinusPlus construct more
|
|
Unify handling of styles parsed from raw line and computed diff
styles. This enables syntax highlighting to be used in color-moved
sections.
Fixes #72
|
|
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).
|
|
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.
|
|
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.
|
|
Simplifies line handling and printing by removing a "magical"
1-offset previously required in various locations.
Now explicitly prepend "" in `tokenize()`.
|