Skip to content

Instantly share code, notes, and snippets.

@nibble-4bits
Last active July 15, 2022 00:12
Show Gist options
  • Select an option

  • Save nibble-4bits/1d34cf81d94a6dbe7c9305a1b38a7743 to your computer and use it in GitHub Desktop.

Select an option

Save nibble-4bits/1d34cf81d94a6dbe7c9305a1b38a7743 to your computer and use it in GitHub Desktop.

Revisions

  1. nibble-4bits revised this gist Jul 15, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git-vcherry.sh
    Original file line number Diff line number Diff line change
    @@ -17,4 +17,4 @@ AWK_PROG_TEMPLATE="$HASH_REGEX {
    { print }
    "

    git log --all --decorate --oneline --graph --color=always | awk "$AWK_PROG_TEMPLATE" | less
    git log --all --decorate --oneline --graph --color=always | awk "$AWK_PROG_TEMPLATE" | less -R
  2. nibble-4bits revised this gist Jul 14, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git-vcherry.sh
    Original file line number Diff line number Diff line change
    @@ -17,4 +17,4 @@ AWK_PROG_TEMPLATE="$HASH_REGEX {
    { print }
    "

    git log --all --decorate --oneline --graph --color=always | awk "$AWK_PROG_TEMPLATE" | less
    git log --all --decorate --oneline --graph --color=always | awk "$AWK_PROG_TEMPLATE" | less
  3. nibble-4bits revised this gist Jul 14, 2022. No changes.
  4. nibble-4bits created this gist Jul 14, 2022.
    20 changes: 20 additions & 0 deletions git-vcherry.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    #!/bin/bash

    set -eo pipefail

    UPSTREAM=$1
    HEAD=$2

    HASHES=$(git cherry "$UPSTREAM" "$HEAD" | grep -F '+' | tr -d '+ ' | cut -c 1-7)
    HASH_REGEX="/$(echo "$HASHES" | paste -sd '|' -)/"

    AWK_PROG_TEMPLATE="$HASH_REGEX {
    where = match(\$0, /[a-f0-9]{7,}/)
    substring = substr(\$0, where, 7)
    sub(substring, \"\033[1;7m&\")
    }
    { print }
    "

    git log --all --decorate --oneline --graph --color=always | awk "$AWK_PROG_TEMPLATE" | less