dandavison / delta

A syntax-highlighting pager for git, diff, grep, and blame output
https://dandavison.github.io/delta/
MIT License
22.76k stars 381 forks source link

git log --graph not supported ? #141

Open bric3 opened 4 years ago

bric3 commented 4 years ago

Hi I believe I came across an issue, but I'm not sure. I've configured delta this way in my .gitconfig

[core]
  pager = delta --width=variable

I have this alias as well

[alias]
    slog = log --graph --pretty=format:'%C(red)%h%Creset %C(green)%ad%Creset %C(magenta)%G?%Creset %s %C(auto)%d%Creset %C(bold blue)%ae%Creset' --abbrev-commit --date=format:'%Y-%m-%d %H:%M' --color=always

I narrowed the issue to the --graph option, when it's used, delta somehow back out

git log --graph --patch
bric3 commented 4 years ago
git log -1 --graph --patch ``` * commit 8baa3f796113965b5225944413a74359e5409e5d (HEAD -> master, origin/master, origin/HEAD) | Author: Scott McLeod | Date: 2020-04-21 00:32:06 -0400 | | Fold retrieve-sapmachine into retrieval code, use globbing for cache | | diff --git a/bin/functions b/bin/functions | index 9e01fe7..c5d5bf8 100755 | --- a/bin/functions | +++ b/bin/functions | @@ -1,9 +1,12 @@ | #!/usr/bin/env bash | -set -e | -set -Euo pipefail | | PLUGIN_HOME="$(dirname "$(dirname "${0}")")" | CACHE_DIR="${TMPDIR:-/tmp}/asdf-java.cache" | +CURL_OPTS=('-f' '-s') | + | +shopt -s nullglob | +CACHE_FILES=("${CACHE_DIR}"/*) | +shopt -u nullglob | | if [ ! -d "${CACHE_DIR}" ] | then | @@ -12,16 +15,16 @@ fi | | KERNEL_NAME="$(uname -s)" | case "${KERNEL_NAME}" in | - Darwin) BASE64_OPTS="-D" | + Darwin) BASE64_OPTS=('-D') | OS="mac" | SHA256SUM="gsha256sum" | - STAT_OPTS="-f %c" | + STAT_OPTS=('-f' '%c') | TEMP_DIR=$(/usr/bin/mktemp -dt asdf-java) | ;; | - Linux) BASE64_OPTS="-d" | + Linux) BASE64_OPTS=('-d') | OS="linux" | SHA256SUM="sha256sum" | - STAT_OPTS="-c %Z" | + STAT_OPTS=('-c' '%Z') | TEMP_DIR=$(mktemp -dp /tmp asdf-java.XXXXXXXX) | ;; | *) echo "Unknown operating system: ${KERNEL_NAME}" : ```
git log -1 --patch 🔴 ``` commit 8baa3f796113965b5225944413a74359e5409e5d (HEAD -> master, origin/master, origin/HEAD) Author: Scott McLeod Date: 2020-04-21 00:32:06 -0400 Fold retrieve-sapmachine into retrieval code, use globbing for cache bin/functions ──────────────────────────────────────────── 1 #!/usr/bin/env bash set -e set -Euo pipefail PLUGIN_HOME="$(dirname "$(dirname "${0}")")" CACHE_DIR="${TMPDIR:-/tmp}/asdf-java.cache" CURL_OPTS=('-f' '-s') shopt -s nullglob CACHE_FILES=("${CACHE_DIR}"/*) shopt -u nullglob if [ ! -d "${CACHE_DIR}" ] then ────┐ fi │ ────┘ 15 KERNEL_NAME="$(uname -s)" case "${KERNEL_NAME}" in Darwin) BASE64_OPTS="-D" Darwin) BASE64_OPTS=('-D') OS="mac" SHA256SUM="gsha256sum" STAT_OPTS="-f %c" STAT_OPTS=('-f' '%c') TEMP_DIR=$(/usr/bin/mktemp -dt asdf-java) ;; Linux) BASE64_OPTS="-d" Linux) BASE64_OPTS=('-d') OS="linux" SHA256SUM="sha256sum" STAT_OPTS="-c %Z" STAT_OPTS=('-c' '%Z') TEMP_DIR=$(mktemp -dp /tmp asdf-java.XXXXXXXX) ;; *) echo "Unknown operating system: ${KERNEL_NAME}" ```
dandavison commented 4 years ago

Hi @bric3, thanks for this! I agree it's not working and I agree it would make sense for it to work in principle.

Regarding implementation, the parser currently does not have any concept of "being in log --graph mode" and does not handle the possibility that each line starts with an arbitrary number of | | | ... markers corresponding to an arbitrary number of branch lineages.

Incidentally, do you find it helpful to use log --patch in conjunction with log --graph or would you say that they people would normally use them separately?

bric3 commented 4 years ago

Incidentally, do you find it helpful to use log --patch in conjunction with log --graph or would you say that they people would normally use them separately?

Actually I usually don't do that as I'm using the git alias which happens to use the --graph, and sometimes I want to see the patch of a commit by adding the -p option. I guess it's a limitation of the pager way of doing things. I wonder of git could have a some way to render the diff.

But if this has to be implemnted I think using the star * before a commit to distinguish between graph mode or normal mode may be a clue to achieve that. I know the diff-highlight script does something like that https://github.com/git/git/commit/4551fbba141e0b2e4d16830f76f784e9c960bdf8. Although I recognize it's ultimately a tad complex.

bew commented 2 years ago

Incidentally, do you find it helpful to use log --patch in conjunction with log --graph or would you say that they people would normally use them separately?

I'm using both at the same time, mainly because I have a git alias that reformats the commits info, body, and also enables graph. And when I want to see the patch diff of each commits I just add -p to that alias.

I tested with delta 0.13.0, it's not yet working.

How difficult is the rest of the work needed to have this feature?