From: Jacob Casper Date: Thu, 19 Mar 2020 18:55:57 +0000 (-0500) Subject: Handle globbing X-Git-Url: https://git.jacobcasper.com/?a=commitdiff_plain;p=blame.git Handle globbing --- diff --git a/README.md b/README.md index 9b190a9..52a011c 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ A shell script to see who should _really_ own a file in your `git` project. ## Usage -`blame [file]` +`blame [file ...]` ## Installation diff --git a/blame.sh b/blame.sh index 6c32e2e..93d7375 100755 --- a/blame.sh +++ b/blame.sh @@ -1,2 +1,5 @@ #!/bin/sh -git blame --line-porcelain -- $1 | awk '/^author /' | awk '{$1 = ""; author=substr($0, 2); counts[author] += 1} END { for (author in counts) {print counts[author],author,counts[author],counts[author]/NR*100"%"} }' | sort -nr -k 1 | awk '{$1 = ""; print $0}' +for FILE in "$@"; do + echo $FILE + git blame --line-porcelain -- $FILE | awk '/^author /' | awk '{$1 = ""; author=substr($0, 2); counts[author] += 1} END { for (author in counts) {print counts[author],author,counts[author],counts[author]/NR*100"%"} }' | sort -nr -k 1 | awk '{$1 = ""; print $0}' +done