I recommend to look into git log --help and git rev-list --help .

I just created 2 scripts to list commits from Git repositories. It’s more in the score of an alias actually, so nothing comprehensive here. If you have some one-liners, alias or scripts for commits listing, please share here. The link of this post goes to the git log documentation. I’ll share mine in the comments too rather than in the post.

  • Morphit @feddit.uk
    link
    fedilink
    arrow-up
    1
    ·
    8 days ago

    You’re absolutely right. Here’s a slopcoded rewrite that does run a ton faster and doesn’t use git last-modified (which is labelled experimental but was kind of the original inspiration). I even got it to do relative filenames instead of the full path to the root of the repo which I had been wanting.

    cat .local/bin/git-slopblame

    #!/usr/bin/env bash
    # Show when <paths> were last committed, with date, author and commit title
    
    paths=("$@")
    if ((${#paths[@]} == 0)); then
        paths=(".")
    fi
    
    git log --format='@@@%h%x09%as%x09%an%x09%s' --relative --name-only -- "${paths[@]}" |
    awk '/^@@@/ {
            commit = substr($0, 4)
            next
        } length($0) && !seen[$0]++ {
            print commit "\t" $0
        }' |
    while IFS=$'\t' read -r hash date author subject file; do
        printf '%s:\033[34m%s\033[0m \033[32m%s\033[0m \033[34m%s:\033[0m%s\n' \
            "$hash" "$date" "$author" "$file" "$subject"
    done