2

I have migrated my svn repo to local git. For some reason all authors look like:

userid <userid@localhost> 

Is there way to change all authors rewriting "localhost" to "myorg.org"

userid <userid@myorg.org> 

UPDATE

userid is not fixed.

Dmitry Pavlenko
  • 8,530
  • 3
  • 30
  • 38
Macchiatow
  • 607
  • 10
  • 24
  • What tool did you use to convert the repo from Subversion to Git? – Wolf Aug 10 '15 at 15:04
  • 1
    SubGit one-time conversion takes a `--authors-file FILE` option to supply a file that maps subversion committers to full Git authors/email. You'll probably have to run your conversion again, but this time specifying an authors-file. See this helper for the mirror mode translation: http://www.subgit.com/remote-book.html#6 – Wolf Aug 10 '15 at 15:12
  • in fact it did load authors correctly (except mentione issue) without any extra manipulations @Wolf – Macchiatow Aug 10 '15 at 15:17
  • SubGit uses core.defaultDomain option as a domain to form an e-mail when it cannot find SVN author in authors.txt. Does the author have non-ASCII characters (it can be encoding issue, for example)? (Disclaimer: I'm one of SubGit developers) – Dmitry Pavlenko Aug 10 '15 at 15:29
  • nice that worked thanks @DmitryPavlenko – Macchiatow Aug 10 '15 at 16:10
  • @DmitryPavlenko I have an issue trying to push to my remote repo. It seems there is a push hook. I get "invalide commiter" exception even though authors looks fine. Is there ways to set both be equal? In fact I dont even see comiter info, only author. – Macchiatow Aug 11 '15 at 08:24
  • Could you please file and issue in our (https://issues.tmatesoft.com/issues/SGT) tracker and attach logs from subgit/logs directory (mainly daemon.0.log) with the exception? Thanks! – Dmitry Pavlenko Aug 11 '15 at 11:12

1 Answers1

5

The comments have several suggestions for fixing this during the import process. If you want to fix it after the import is complete, you can use the git filter-branch command to rewrite author emails.

git filter-branch --env-filter '
  GIT_AUTHOR_EMAIL=${GIT_AUTHOR_EMAIL/localhost/myorg.org}
  GIT_COMMITTER_EMAIL=${GIT_COMMITTER_EMAIL/localhost/myorg.org}
'

This will subsitute myorg.org for localhost in all author and committer emails (on the current branch).

larsks
  • 277,717
  • 41
  • 399
  • 399
  • (Note that the search/replace syntax used here is `bash`-ism) – larsks Aug 10 '15 at 16:11
  • I'm getting `eval: Bad substitution` error on line 2 when trying to use it. This one works https://help.github.com/articles/changing-author-info/ but I can't make the bash substitutions work :( – Jakub Bochenski Jan 17 '18 at 14:13
  • .. or not: it worked once but now I'm stuck with `2: eval: Bad substitution` – Jakub Bochenski Jan 17 '18 at 14:27
  • It sounds like you're not using bash? You could try something similar using a construct appropriate for your shell (e.g., using `echo` and `sed`, or something similar). – larsks Jan 17 '18 at 14:35
  • Since there were 4 authors in the repo I went with the linked GH script. Still I'd love to know what happened. I do use bash. I tried passing the argument directly to eval -- it works. – Jakub Bochenski Jan 17 '18 at 14:56
  • Running `$ git filter-branch -f --env-filter 'echo $SHELL'` results in output like `Rewrite d256d077ef4eeaa54cbfb0814060c786b4bae25a (1/52) (0 seconds passed, remaining 0 predicted) /bin/bash` – Jakub Bochenski Jan 17 '18 at 15:00
  • On Windows, you have to use Git Bash to run the script. A more complete version can be found there: https://help.github.com/articles/changing-author-info/ – slaadvak May 23 '18 at 13:04