Age | Commit message (Collapse) | Author |
|
|
|
|
|
* Move tabs logic into utils
* Re-use buffer returned by tabs::expand
* Add TabCfg to configure tabs
Use the String from this config for the tab replacement. This avoids
creating a new String for each processed line.
* Avoid unicode segmentation for each line just to remove a prefix
In some code paths no prefix is removed, and in almost all other
cases the prefix is just ascii.
This simplifies a lot of calls.
* Set default tab with to 8
Editors like vim, emacs, nano and most terminal emulators set
this value as the default tab display width.
|
|
|
|
Fix #137
|
|
Added support for an optional -dirty hash suffix which is present
in `git diff` output when files were changed in a submodule.
|
|
The `error_chain` crate is now deprecated for a long time and `anyhow`
has proven to be a popular replacement for applications.
This also improves the current error messages for panics.
```
PAGER='"less' git show
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: \
Error(Msg("Could not parse pager command."), State { next_error: Some(ParseError), \
backtrace: InternalBacktrace })', src/main.rs:136:88
```
```
PAGER='"less' git show
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Could not parse pager command.
Caused by:
missing closing quote', src/main.rs:125:88
```
|
|
|
|
Signed-off-by: Alexander Seiler <seileralex@gmail.com>
|
|
The `Clone`, `Copy`, `Debug` and `PartialEq` traits are no longer
derived automatically by the macro.
|
|
Fixes #1316
|
|
The `try_create_from_path` function and the `from_path` function for
tests can be merged into a single function.
|
|
|
|
The `GitConfigEntry` enum has been removed from the module and now only
contains the `GitRemoteRepo` type.
|
|
|
|
|
|
* feat: Added config option.
|
|
The type is unnecessarily wrapped and it's the only use for
`GitConfigEntry::GitRemote` enum variant.
|
|
* Update direct dependencies
* Update transient dependencies
* Switch back to `dirs` crate
The `dirs`/`dirs-sys` repositories are unarchived and the crates are
maintained again, while `dirs-next` crates aren't.
|
|
* Move theme iteration logic to `GitConfig`
The `git2::Config` type is now encapsulated and the regex is given to
`libgit2` to filter the config entries.
* Move remote url getter to `GitConfig`
|
|
* Update to clap 4
* Add help, usage, error-context features to clap
* Add wrap_help clap feature
* Remove DeriveDisplayOrder as it is now default
* Update ValueSource using statement
* Update #[clap(...)] to #[command(...)]
* Update #[clap(...)] to #[arg(...)]
* Update #[structopt(...)] to #[arg(...)]
* Remove value_parser because it is now default
* Return option & argument names as `String` due to lifetime issues
* Remove leading hyphens from arguments long definition
Leading hyphens are no longer accepted.
* Argument names are derived from field names and `snake_case`
* `help` & `version` are no longer added automatically
* Update `clap` to 4.1.8
---------
Co-authored-by: tjquillan <tjquillan@gmail.com>
|
|
Corrects misspellings identified by https://github.com/marketplace/actions/check-spelling
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
|
|
|
|
Removed "configuration" chapter in 6f0bcbd504b397479eab97a5026ef96f3ad10eb3.
|
|
The command failed because the two empty arguments for the internal `Opt`
parsing actually meant "<binary> <minus_file>" and since `minus_file` is now
parsed with `PathBufValueParser` and the value parser rejects empty values.
|
|
The colors are already sorted and can be returned as they are defined.
|
|
* 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`
|
|
* Address deprecated clap features
* Move to Arg::get_id from Arg::get_name
* Move to ArgMatches::value_source
* Run rustfmt
|
|
* try fix bad alignment in unicode (#1144)
* use width instead of count in wrap_line
* fix fmt
* 3 tests do not need fail
* fix tests
Co-authored-by: Thomas Otto <th1000s@posteo.net>
|
|
* Stop ignoring a passing test
edits::tests::test_infer_edits_12 passes so there is no need to ignore
it.
* Refactor Levenshtein tests
Reduce the amount of repetition and specify the Levenshtein distance
explicitly in preparation for changing the Levenshtein calculation and
adding more tests in a future commit. As there are quite a few inputs to
each test use a struct rather than a plain function for the tests as
this effectively provides named parameters for the inputs.
* Highlight deletions before insertions
When a token has moved within a line try to highlight it as a deletion
followed by an insertion. Currently
-'b '
+' b'
is highlighted as
-'b[ ]'
+'[ ]b'
as if the space has moved to the left, instead highlight it as
-'[b] '
+' [b]'
as if the "b" has moved to the right. As the changes to the tests show
this also tends to favor a longer match at the start of the line.
* Don't highlight an unchanged trailing space
Only unchanged space between changed tokens should be highlighted, if
the line ends with an unchanged space then the space should not be
highlighted.
* Try to group highlighted changes together
Sometimes the highlighting of a change is not as clear as it could
be. For example the change
-printf "%s\n" s y y ...
+test_write_lines s y n ...
is highlighted as
-[printf "%]s[\n"] [s ]y y ...
+[test_write_lines ]s y y ...
rather than
-[printf "%s\n"] s y n ...
+[test_write_lines] s y y ...
This is because the Levenshtein distance calculation only checks if
the current tokens match without considering if the previous tokens
matched or not. Adding a small penalty for starting a run of changed
tokens forces the changes to be grouped together whenever possible. A
knock on effect of adding the penalty is that the cost a substitution
needs to be increased relative to the cost of an insertion/deletion
otherwise the lowest cost for "ab" -> "ba" is two substitutions rather
than an insertion, match and deletion.
There are several changes to the tests
- the Levenshtein distance is updated to reflect the new calculation in
tests::align::*
- several new tests are added to tests::align to check the grouping of
different combinations of insertions and deletions
- tests::edits::test_infer_edits_10 shows an improvement in the
highlighting as the unchanged space at the end of the changed tokens
is no longer highlighted. This is because it is no longer considered
to be deleted by the Levenshtein matching as deleting the space
between the deleted words now has a lower cost.
- there is a new test in tests::edits using the example in this
message.
* Stop using substitutions in Levenshtein calculation
Now that the lowest cost edit path groups deletions and insertions
together there seems to be little point in keeping substitutions. Indeed
the lower cost of substitutions compared to a deletion followed by an
insertion can adversely affect the highlighting. If the length of the
line does not change delta will prefer to use substitutions over
deletions and insertions even if it results in unchanged tokens being
marked as changed. For example in
-[a] a a a a a [b b b]
+[c] a a a a a [a c c]
unchanged tokens are marked as deleted and inserted. Without
substitutions this is highlighted as
-a a a a a a [b b b]
+[c ]a a a a a a [c c]
which highlights the insertion at the beginning of the line and the
change at the end of the line more clearly.
There is a change to the distance calculation as substitutions only
contributed the length of the deletion whereas now the same change will
add the length of both the deletion and the insertion. This is addressed
by doubling the contribution of unchanged sections so that the
denominator equals the sum of the distance contributions of the plus
line and minus line.
|
|
Otherwise the file extension would return 'rs"' which does not
match any language.
|
|
|
|
|
|
Also new workarounds.rs file, and DELTA_NO_WORKAROUNDS env var
to disable these.
|
|
|
|
|
|
Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
|
|
* Add sourcehut link parsing
* refactor: GitRemoteRepo::GitHubRepo -> ..::GitHub, repo_slug -> slug
https://rust-lang.github.io/rust-clippy/master/index.html#enum_variant_names
* readme.md: change bitbucket to sourcehut
|
|
Following fixes are included:
* derive_partial_eq_without_eq:
Eq trait was added by running `cargo clippy --fix --no-deps`.
* get_first:
Function was replaced by running `cargo clippy --fix --no-deps`.
* unnecessary_to_owned:
This check was disabled for ANSIString as to_string call is required
to enforce formatting. Otherwise the underlying string was returned
directly (probably due to Deref implementation).
* type_complexity:
Closure type was simplified and Box<> usage was removed.
|
|
New CLI/config option is introduced: blame-timestamp-output-format.
Fixes #1157.
|
|
Found via following command:
codespell -L crate,nin,numer,struc,ded,fo
|
|
* Fix git-grep match-highlighting at line-start
This commit fixes highlighting the part of the line of code that matches
the git grep query in cases where the match starts at the beginning of
the lines.
Fixes #1056.
* Fix handling of non-match highlight
In some cases, `git grep` will customize the foreground-color for more
than just the subset of the line that matches the grep pattern. This
breaks the current match-detection behavior, which considers any
characters with a non-default "foreground color" within the "code" part
of a git-grep-ouput-line to be part of the match. This commit makes
match-detection check for boldness and a red foreground instead of just
checking for a non-default foreground-color.
git grep matches are bold and red by default. But git grep isn't the
only reason input to delta may contain color codes; there may still be
cases where the highlighting looks wrong here.
|
|
Prior to this commit, syntax highlighting of scala code was not
correct in `git show $commit:$path` output. It was working for other
languages as far as I know. I'm not sure why.
|
|
Fixes #677
|
|
|
|
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
|
|
The test_process_calling_cmdline test only allows "cargo test" and
"cargo tarpaulin" for running the testsuite, for "cargo t" is a
built-in alias for "cargo test" and should be allowed, too.
|
|
(#1112)
Up until commit 55287a8 "Run in diff mode iff two positional arguments
are supplied" diff mode was only supported when stdin is connected to a
tty, which meant that, for example, running `delta a b` in a git hook
would do the wrong thing.
As a fix, the tty check was removed, so now `delta a b` always works,
but the only error condition is now to pass only a single file. When
passing no files at all, we try parse to stdin even when connected to a
tty. Usually that wouldn't be that bad, because the user could press
Ctrl-C or Ctrl-D (EOF) to quit, unfortunately something in the pager
setup breaks this, and the only way to exit `delta` is to kill it.
Running `delta` with stdin connected to a tty would mean that the user
has to manually enter a diff (or paste it), which is not really an
expected scenario, as demonstrated by the error message that's currently
only emitted when running `delta` with only a single file argument. So
we can avoid the lockup by also emitting the error message when running
on a tty and there are no files to be diffed.
Fixes #1039, fixes #1090
|
|
|
|
Fixes #1105
|