]> gitweb.fluxo.info Git - utils-git.git/commitdiff
Adding git-rewrite-identity
authorSilvio Rhatto <rhatto@riseup.net>
Thu, 18 Sep 2014 21:39:55 +0000 (18:39 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Thu, 18 Sep 2014 21:39:55 +0000 (18:39 -0300)
git-rewrite-identity [new file with mode: 0755]

diff --git a/git-rewrite-identity b/git-rewrite-identity
new file mode 100755 (executable)
index 0000000..fca9051
--- /dev/null
@@ -0,0 +1,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