Skip to content

Instantly share code, notes, and snippets.

@gmeszaros
Forked from mloberg/gist:3750653
Last active August 28, 2017 13:01
Show Gist options
  • Save gmeszaros/d46030b76a3d6cbb84645023e130b9db to your computer and use it in GitHub Desktop.
Save gmeszaros/d46030b76a3d6cbb84645023e130b9db to your computer and use it in GitHub Desktop.

Revisions

  1. gmeszaros renamed this gist Aug 28, 2017. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. gmeszaros revised this gist Aug 28, 2017. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -12,12 +12,12 @@ elif [[ -z "$FILE" ]]; then
    fi

    # Check if valid git repo
    git status &> /dev/null

    ROOT=$(git rev-parse --show-toplevel)
    if [[ $? -ne 0 ]]; then
    echo "Not a valid git repo."
    exit 1
    fi
    cd "$ROOT"

    # git revision for file
    REVS=`git log --pretty=%H -- $FILE`
    @@ -26,7 +26,7 @@ REVS=`git log --pretty=%H -- $FILE`
    for rev in $REVS; do
    git show $rev:$FILE > _file_to_check
    # if you are on a Linux system, change md5 to md5sum
    if [[ -n `md5 _file_to_check | grep $CHECKSUM` ]]; then
    if [[ -n `md5sum _file_to_check | grep $CHECKSUM` ]]; then
    echo $rev
    fi
    rm _file_to_check
  3. @mloberg mloberg created this gist Sep 19, 2012.
    33 changes: 33 additions & 0 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    #!/bin/sh

    CHECKSUM=$1
    FILE=$2

    if [[ -z "$CHECKSUM" ]]; then
    echo "Usage: $0 md5 file"
    exit 1
    elif [[ -z "$FILE" ]]; then
    echo "Usage: $0 md5 file"
    exit 1
    fi

    # Check if valid git repo
    git status &> /dev/null

    if [[ $? -ne 0 ]]; then
    echo "Not a valid git repo."
    exit 1
    fi

    # git revision for file
    REVS=`git log --pretty=%H -- $FILE`

    # check each revision for checksum
    for rev in $REVS; do
    git show $rev:$FILE > _file_to_check
    # if you are on a Linux system, change md5 to md5sum
    if [[ -n `md5 _file_to_check | grep $CHECKSUM` ]]; then
    echo $rev
    fi
    rm _file_to_check
    done