diff options
author | Franck Cuny <franck@lumberjaph.net> | 2015-07-06 11:46:36 -0700 |
---|---|---|
committer | Franck Cuny <franck@lumberjaph.net> | 2015-07-06 11:46:36 -0700 |
commit | 3d10fafdfc888b43d91aebf45cb6022f4f3c3203 (patch) | |
tree | 61bd8c8475beaa5f86f2e78d1e4d3b7ea625eb84 /bin/git-blame-from-line-number | |
parent | create repository (diff) | |
download | emacs.d-3d10fafdfc888b43d91aebf45cb6022f4f3c3203.tar.gz |
configuration files
Diffstat (limited to '')
-rwxr-xr-x | bin/git-blame-from-line-number | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/bin/git-blame-from-line-number b/bin/git-blame-from-line-number new file mode 100755 index 0000000..dbe1970 --- /dev/null +++ b/bin/git-blame-from-line-number @@ -0,0 +1,23 @@ +#!/bin/sh + +usage() { + echo "usage: $0 <filename> <lineno>" + exit 1 +} + +filename="$1" + +[ -z "${filename}" ] && usage + +lineno="$2" + +[ -z "${lineno}" ] && usage + +line=$(git blame -L "${lineno}","${lineno}" "${filename}") +sha=$(echo $line | awk '{print $1}') + +if [[ "${sha}" == "00000000" ]]; then + echo "${line}" +else + git show "${sha}" +fi |