From 016d3b178ad7339b326d7ccce9fe44036858b858 Mon Sep 17 00:00:00 2001 From: Loic Nageleisen Date: Mon, 3 Aug 2015 15:23:03 +0200 Subject: [PATCH] tool to rewrite email of commiter and author --- fix_commit_email.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 fix_commit_email.sh diff --git a/fix_commit_email.sh b/fix_commit_email.sh new file mode 100755 index 0000000..c5f5f3c --- /dev/null +++ b/fix_commit_email.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +set -e +set -u + +old_mail="$1" +new_mail="$2" +new_name="$3" +shift +shift +shift + +git filter-branch --env-filter ' + +OLD_EMAIL="'"$old_mail"'" +CORRECT_NAME="'"$new_name"'" +CORRECT_EMAIL="'"$new_mail"'" + +if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ] +then + export GIT_COMMITTER_NAME="$CORRECT_NAME" + export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL" +fi +if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ] +then + export GIT_AUTHOR_NAME="$CORRECT_NAME" + export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL" +fi +' "$@"