]> git.wh0rd.org - home.git/blame - .bin/git-rewrite-authors
git-log: include tag/branch names
[home.git] / .bin / git-rewrite-authors
CommitLineData
e36215f2 1#!/bin/sh
6c162084 2
e36215f2
MF
3tmp=$(mktemp -t "${0##*/}.XXXXXX")
4trap "rm -rf '${tmp}'" EXIT
6c162084
MF
5cat << \EOF > ${tmp}
6decode() {
7 awk -vid="$1" -vtype="$2" '$1 == id {
a51e0311
MF
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 "'\'';"
e36215f2 13 }' "${author_file}"
6c162084
MF
14}
15EOF
16
17for x in cvs-authors authors ; do
e36215f2
MF
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
6c162084 24done
5b0dff8a
MF
25if [ ! -e "${author_file}" ] ; then
26 echo "error: could not find ${author_file}"
27 exit 1
28fi
6c162084
MF
29git filter-branch \
30 --env-filter ". ${tmp};"' \
31 eval `decode "${GIT_AUTHOR_NAME}" AUTHOR`; \
32 eval `decode "${GIT_COMMITTER_NAME}" COMMITTER`; \
33' "$@"