Skip to content

@stigkj /git-fix-author forked from leif81/git_fix_author
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Written to change the unix name used for a cvs commit to a pretty git name for the user.Implementation borrowed from http://lists.freedesktop.org/archives/portland/2010-October.txtauthor-conv-file format (same format as git-cvsimport requires):
#!/bin/bash
#
# Changes author and committer name and email throughout the whole repository.
# Uses a file with the following format:
#
# john.doe@hotmail.com=John Doe <john.doe@hotmail.com>
# jill.doe@hotmail.com=Jill Doe <jill.doe@hotmail.com>
#
if [ ! -e "$1" ]
then
echo "File '$1' does not exist"
exit 1
fi
export authors_file=$1
git filter-branch -f --env-filter '
grep "^$GIT_COMMITTER_EMAIL=" "$authors_file" >> /dev/null
RETVAL=$?
if [ $RETVAL -eq 0 ]
then
get_name () {
grep "^$1=" "$authors_file" |
sed "s/^.*=\(.*\) <.*>$/\1/"
}
get_email () {
grep "^$1=" "$authors_file" |
sed "s/^.*=.* <\(.*\)>$/\1/"
}
name=$(get_name "$GIT_COMMITTER_EMAIL")
email=$(get_email "$GIT_COMMITTER_EMAIL")
GIT_AUTHOR_NAME="$name" &&
GIT_AUTHOR_EMAIL="$email" &&
GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME" &&
GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"
fi
' -- --all
@stigkj
Owner

Improved implementation by

  • taking the auth-conv-file to use as an argument
  • use email as key instead of name to get around the problem with foreign letters
  • more quoting
@MindTooth

Can this be adopted to include a list of Git contributors emails -- not a cvs import -- and then go through the list? Change the user and email based only on the old email.

@stigkj
Owner

You mean you do not have a file, just a list inline in the script?

@MindTooth

Having a file, but only base the cycle on emails, and end up with one author(name+email).

@stigkj
Owner

Not sure I understand...it is based on emails, that is, commits with emails matching the first column in the file will get their name and email replaced from the second column of the file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.