Create a gist now

Instantly share code, notes, and snippets.

Embed
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

This comment has been minimized.

Show comment
Hide comment
@stigkj

stigkj Dec 9, 2011

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
Owner

stigkj commented Dec 9, 2011

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
@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Apr 17, 2012

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.

ghost commented Apr 17, 2012

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

This comment has been minimized.

Show comment
Hide comment
@stigkj

stigkj Apr 17, 2012

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

Owner

stigkj commented Apr 17, 2012

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

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Apr 17, 2012

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

ghost commented Apr 17, 2012

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

@stigkj

This comment has been minimized.

Show comment
Hide comment
@stigkj

stigkj Apr 18, 2012

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

Owner

stigkj commented Apr 18, 2012

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