Created
March 22, 2016 23:13
-
-
Save eugeneia/7d34c270f8d1603c48f0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -euo pipefail | |
commit=$1 | |
parent=$1^1 | |
function commit_path_sha512 { | |
git cat-file blob $(git rev-parse $1:$2) | sha512sum | cut -d " " -f 1 | |
} | |
function diff_path { echo ${1:6}; } | |
function diff_a { expr match "$1" '^--- a/' >/dev/null; } | |
function diff_b { expr match "$1" '^+++ b/' >/dev/null; } | |
function v_improve { | |
while read line; do | |
if diff_a "$line"; then | |
local path=$(diff_path "$line") | |
local sha512=$(commit_path_sha512 "$parent" "$path") | |
echo "$line $sha512" | |
elif diff_b "$line"; then | |
local path=$(diff_path "$line") | |
local sha512=$(commit_path_sha512 "$commit" "$path") | |
echo "$line $sha512" | |
else | |
echo "$line" | |
fi | |
done | |
} | |
git diff $parent..$commit | v_improve |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment