From b5c3548cf1fa504f67594a8071355f78b62cbd33 Mon Sep 17 00:00:00 2001 From: Jacob Casper Date: Thu, 19 Mar 2020 13:55:57 -0500 Subject: [PATCH] Handle globbing --- README.md | 2 +- blame.sh | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) 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 -- 2.20.1