aboutsummaryrefslogtreecommitdiff
path: root/git-rewrite-identity
blob: fca905151b810610b23e63ab8194aa9c487a55fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
#
# Rewrite identities in commits.
#

# Parameters
BASENAME="`basename $0`"
OLD_EMAIL="$1"
NEW_EMAIL="$2"

# Syntax check
if [ -z "$3" ]; then
  echo "usage: $BASENAME <old-email> <new-email> <new-name>"
  exit 1
fi

# Get new name
shift 2
NEW_NAME="$*"

# Apply filter
echo "Please run this command:"
echo ""
cat <<-EOF
git filter-branch --commit-filter "
      if [ "\$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ];
      then
              GIT_AUTHOR_NAME="$NEW_NAME";
              GIT_AUTHOR_EMAIL="$NEW_EMAIL";
              git commit-tree "\$@";
      else
              git commit-tree "\$@";
      fi" HEAD
EOF