]> git.wh0rd.org Git - home.git/commitdiff
git-rewrite-authors: handle more edge cases
authorMike Frysinger <vapier@gentoo.org>
Sat, 19 Aug 2017 18:55:02 +0000 (14:55 -0400)
committerMike Frysinger <vapier@gentoo.org>
Sat, 19 Aug 2017 18:55:02 +0000 (14:55 -0400)
.bin/git-rewrite-authors

index 4e4c2bf8b112d9659434834894ecb366d74fdb5e..601700805230e52478c77c9d3dbdac79ec034e80 100755 (executable)
@@ -7,6 +7,9 @@ decode() {
        awk -vid="$1" -vtype="$2" '$1 == id {
                match($0, /^[^=]*=\s*([^<]*)<([^>]*)>/, a);
                name = gensub(/\s+$/, "", "g", a[1]);
+               name = gensub(/^"/, "", "g", name);
+               name = gensub(/"$/, "", "g", name);
+               name = gensub(/'\''/, "'\''\\\\'\'''\''", "g", name);
                email = a[2];
                print "export GIT_"type"_NAME='\''" name "'\'';"
                print "export GIT_"type"_EMAIL='\''" email "'\'';"
@@ -27,7 +30,7 @@ if [ ! -e "${author_file}" ] ; then
        exit 1
 fi
 git filter-branch \
-       --env-filter ". ${tmp};"' \
-               eval `decode "${GIT_AUTHOR_NAME}" AUTHOR`; \
-               eval `decode "${GIT_COMMITTER_NAME}" COMMITTER`; \
+       --env-filter ". '${tmp}';"' \
+               eval "$(decode "${GIT_AUTHOR_NAME}" AUTHOR)"; \
+               eval "$(decode "${GIT_COMMITTER_NAME}" COMMITTER)"; \
 ' "$@"