diff options
author | Teddy Wing | 2020-08-22 20:42:55 +0200 |
---|---|---|
committer | Teddy Wing | 2020-08-22 21:18:34 +0200 |
commit | 5cbc3972644a321442b9640cfcc50f7ef014a6c9 (patch) | |
tree | 42870a32fcf84345793956e62b118f0eaeca773a /src/config.rs | |
parent | 95790ebf124823538a1cbeaf6a3b02a8b6ebbe4d (diff) | |
download | git-suggestion-5cbc3972644a321442b9640cfcc50f7ef014a6c9.tar.bz2 |
Execute `git diff` to output diffs
I want to enable colour diff output. At first, I thought about doing
this by getting the diff colours from the Git config, then outputting
the ANSI escape codes manually with the text.
However, I then thought it would be nice to enable other diff features
like `--word-diff`, and it would be too much trouble to re-implement
that manually, and then I'd have to take word diff colouring into
account.
Decided that the optimal way to get both colours and extra diff
features like word diffing would be to use `git diff` directly under the
hood.
We shell out to `git diff`, and give it the original file as a base, and
a new blob object that we create in the repository on the right side.
This allows us to compare the file using a command in the following
format:
$ git diff <BASE>:src/server.rs <TEMPORARY_HASH>
Ostensibly, the temporary blob object I create for the right side
version should be freed automatically by `git2`.
Add a new `sugdiff` command to output diffs. This will replace
`sugpatch`. Since we're working with diffs, I think a name with "diff"
sounds more logical. The previous version, "patch" sounds too much like
what "apply" does, because of the Unix `patch` command.
Diffstat (limited to 'src/config.rs')
0 files changed, 0 insertions, 0 deletions