Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git log --graph not supported ? #141

Open
bric3 opened this issue Apr 28, 2020 · 6 comments
Open

git log --graph not supported ? #141

bric3 opened this issue Apr 28, 2020 · 6 comments

Comments

@bric3
Copy link

bric3 commented Apr 28, 2020

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
Copy link
Author

bric3 commented Apr 28, 2020

git log -1 --graph --patch
* commit 8baa3f796113965b5225944413a74359e5409e5d (HEAD -> master, origin/master, origin/HEAD)
| Author: Scott McLeod <halcyonblue@gmail.com>
| 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 <halcyonblue@gmail.com>
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
Copy link
Owner

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
Copy link
Author

bric3 commented Apr 29, 2020

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 git/git@4551fbb. Although I recognize it's ultimately a tad complex.

@bew
Copy link

bew commented Jun 4, 2022

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?

@sebastiancarlos
Copy link

I also wanted this to be able to add --patch to my git log aliases. So instead I ended up making new aliases for the --patch use cases:

[alias]
        # log (short and long)
        l = log --graph --pretty=format:'%C(auto)%h %C(bold)%cs%C(auto) %C(blue)%an:%C(auto)%d %s' --color=always
        la = l --all
        ll = log --graph --pretty=fuller --abbrev-commit --color=always
        lla = ll --all

        # versions of log aliases with "--patch"
        # - they duplicate the "l" and "ll" aliases wtihout "--graph" since
        #   it's not compatible with git-delta
        lp = log --pretty=format:'%C(auto)%h %C(bold)%cs%C(auto) %C(blue)%an:%C(auto)%d %s' --color=always --patch
        lap = lp --all
        llp = log --pretty=fuller --abbrev-commit --color=always --patch
        llap = llp --all

@huyz
Copy link

huyz commented Nov 11, 2024

Until delta supports --graph, I just fall back to difftastic:

	lg-dt = "!DFT_IGNORE_COMMENTS= git -c diff.external=difft log --graph --date=local --decorate --patch --ext-diff"
	show-dt = "!DFT_IGNORE_COMMENTS= git -c diff.external=difft show --patch --ext-diff"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants