]> git.wh0rd.org Git - home.git/blob - .bin/git-rewrite-authors
r: force python2 since repo fails w/py3
[home.git] / .bin / git-rewrite-authors
1 #!/bin/sh
2
3 tmp=$(mktemp -t "${0##*/}.XXXXXX")
4 trap "rm -rf '${tmp}'" EXIT
5 cat << \EOF > ${tmp}
6 decode() {
7         awk -vid="$1" -vtype="$2" '$1 == id {
8                 match($0, /^[^=]*=\s*([^<]*)<([^>]*)>/, a);
9                 name = gensub(/\s+$/, "", "g", a[1]);
10                 email = a[2];
11                 print "export GIT_"type"_NAME='\''" name "'\'';"
12                 print "export GIT_"type"_EMAIL='\''" email "'\'';"
13         }' "${author_file}"
14 }
15 EOF
16
17 for x in cvs-authors authors ; do
18         export author_file="${PWD}/.git/${x}"
19         [ -e "${author_file}" ] && break
20         if [ -L "${author_file}" ] ; then
21                 echo "error: ${author_file} is a broken link"
22                 exit 1
23         fi
24 done
25 git filter-branch \
26         --env-filter ". ${tmp};"' \
27                 eval `decode "${GIT_AUTHOR_NAME}" AUTHOR`; \
28                 eval `decode "${GIT_COMMITTER_NAME}" COMMITTER`; \
29 ' "$@"