Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--email-callback doesn't work (CMD on Windows doesn't treat single quote, ['], as a quote mark) #435

Closed
user4302 opened this issue Mar 2, 2023 · 10 comments

Comments

@user4302
Copy link

user4302 commented Mar 2, 2023

using the following syntax
git-filter-repo --email-callback 'return email.replace(b".cm", b".com")'

i try out git-filter-repo --email-callback 'return email.replace(b"user@email.com", b"user.name@email.com")'
but i get the following error
git-filter-repo: error: unrecognized arguments: email.replace(buser@email.com, buser.name@email.com)'

so i try this
git-filter-repo --email-callback 'return email.replace(b"""user@email.com""", b"""user.name@email.com""")'

but i get this
git-filter-repo: error: unrecognized arguments: email.replace(b"user@email.com", b"user.name@email.com")'

what am i doing wrong?

@me-and
Copy link

me-and commented Mar 2, 2023

This looks like a quoting problem. Can you confirm what shell you're using (Bash, PowerShell, cmd, …) and provide a complete copy-paste of the command and output as you see it?

@user4302
Copy link
Author

user4302 commented Mar 3, 2023

i am using CMD.

i tried this just now and it did not work
image

i also forgot to add the who0le code for the issue,
i am using python (v3.10.2) in front of the git-filter-repo part
(i set it up to use "python" instead of "python3")

@andry81
Copy link

andry81 commented Mar 3, 2023

In CMD ' character is not quote character. You must use " instead:

python.exe git-filter-repo ... "return ..."

In Windows the nested quote character as the entire command line depends on the application contained in the command line being executed (child process), when in Linux - on the application has executed the command line (parent process).

Try something like:

  • \"
  • """
python.exe git-filter-repo ... "return ... \" ... \""

Basically in Windows all \" in " skips by CreateProcess API and it's relatives.

@user4302
Copy link
Author

user4302 commented Mar 3, 2023

In CMD ' character is not quote character. You must use " instead:

python.exe git-filter-repo ... "return ..."

In Windows the nested quote character as the entire command line depends on the application contained in the command line being executed (child process), when in Linux - on the application has executed the command line (parent process).

Try something like:

  • \"
  • """
python.exe git-filter-repo ... "return ... \" ... \""

Basically in Windows all \" in " skips by CreateProcess API and it's relatives.

i already tried the triple quotes and got this
git-filter-repo: error: unrecognized arguments: email.replace(b"user@email.com", b"user.name@email.com")'

for the backslash method i get the error still
git-filter-repo: error: unrecognized arguments: email.replace(b"user@email.com", b"user.name@email.com")'

@andry81
Copy link

andry81 commented Mar 3, 2023

Can you introduce the full command line you typed in console?

@user4302
Copy link
Author

user4302 commented Mar 3, 2023

git-filter-repo --email-callback 'return email.replace(b"user@email.com", b"user.name@email.com")'

yeah, here it is

python git-filter-repo --email-callback 'return email.replace(b\"user@email.com\", b\"user.name@email.com\")'

(previously i had user@email.com and made many commits and pushed to the repo
now i changed to user.name@email.com and have a few commits with this email address for the author.)

@andry81
Copy link

andry81 commented Mar 3, 2023

python git-filter-repo --email-callback 'return email.replace(b"user@email.com", b"user.name@email.com")'

You didn't fix the command line, you still trying to use ' as quote character.

@user4302
Copy link
Author

user4302 commented Mar 3, 2023

python git-filter-repo --email-callback 'return email.replace(b"user@email.com", b"user.name@email.com")'

You didn't fix the command line, you still trying to use ' as quote character.

ohhhh. around the whole command, i just noticed.
my bad.
its working now.
thanks loads.

also i tested this on a small dummy local repo and forced it and it works.

if i try this on a repo that is on gitlab.
when i run this command, will it ask me to make a new commit which will push all the files with updated authors?
i just dont want anything to break on the repo.

i noticed an incorrect email address on sonarQube, which is why im trying to change my email now

@andry81
Copy link

andry81 commented Mar 3, 2023

when i run this command, will it ask me to make a new commit which will push all the files with updated authors?
i just dont want anything to break on the repo.

I don't know how would git-filter-repo act, but the old filter-branch just creates refs/originals/refs/* to be able to restore original branches and copy the rest references and tags.

@newren newren changed the title --email-callback doesnt work, --email-callback doesn't work (CMD on Windows doesn't treat single quote, ['], as a quote mark) Jun 10, 2023
@newren
Copy link
Owner

newren commented Jun 10, 2023

if i try this on a repo that is on gitlab. when i run this command, will it ask me to make a new commit which will push all the files with updated authors? i just dont want anything to break on the repo.

i noticed an incorrect email address on sonarQube, which is why im trying to change my email now

When you run filter-repo, it modifies any commits matching the rules you specify, AND all commits which come after those in any branch. If you were just fixing up the latest commit on some branch, force-pushing back to the resource might be okay. But pushing a rewritten version of public history should not be something you undertake lightly; please read https://www.mankier.com/1/git-filter-repo#Discussion to get some background on the ramifications. You may also want to see https://docs.gitlab.com/ee/user/project/repository/reducing_the_repo_size_using_git.html#repository-cleanup for the steps to take if you need to purge the old commits.

ohhhh. around the whole command, i just noticed.
my bad.
its working now.

Glad it's working for you now. Thanks, both @me-and and @andry81.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants