delta icon indicating copy to clipboard operation
delta copied to clipboard

git log --graph not supported ?

Open bric3 opened this issue 5 years ago • 6 comments

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 avatar Apr 28 '20 12:04 bric3

git log -1 --graph --patch
* commit 8baa3f796113965b5225944413a74359e5409e5d (HEAD -> master, origin/master, origin/HEAD)
| Author: Scott McLeod <[email protected]>
| 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 <[email protected]>
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}"

bric3 avatar Apr 28 '20 13:04 bric3

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?

dandavison avatar Apr 28 '20 13:04 dandavison

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.

bric3 avatar Apr 29 '20 09:04 bric3

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?

bew avatar Jun 04 '22 04:06 bew