-
Notifications
You must be signed in to change notification settings - Fork 742
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
--path-rename with spaces #56
Comments
urghh, figured it out!
i must say this in slight contrary to the comment here: https://github.com/newren/git-filter-repo#solving-this-with-filter-repo "the single quotes are unnecessary, but make it clearer to a human" d'oh! 🍺 |
Indeed, this isn't a python issue at all but one of how the shell passes arguments to programs. For example, let's say you had a repository with the following three files, one of them oddly named:
Then the command
would clearly be passing two --path arguments and asking for those two paths to be kept, while the command
would be passing just one --path argument and asking for the funnily named path to be kept. Also, this isn't contrary to the documentation comment at all as the example didn't have any spaces or special characters that needed to be quoted to keep the shell from interpreting the characters in a funny way. Anyway, glad you figured it out. |
sorry, maybe contrary was not the right word... but i didn't want to go so far as 'confusing'.. perhaps, unclear? i.e. the example on that page cannot be extended to: this also does not work: nor this: essentially i couldn't take the example of adding so, i guess to close this out properly what is the right way to escape this please? 🙂 |
The most straightforward translation is
although this also works:
The first of your examples is actually fine, though dropping the two final quotes is perhaps clearer since it literally ends up with filter-repo getting the exact same arguments. The other two of your examples try to replace None of this is a filter-repo issue, but one of understanding how shells work. It may be instructive with a simple helper program named arguments.py with the following contents:
Now, if we try that program with the last two examples you provided, you can what filter-repo was actually told by the shell:
which shows why filter-repo believes it was told to replace 'some path/' with '""'. In contrast, with either of the versions I specified:
which shows that 'some path/' should be replaced by nothing. Also, we can run your original example both with three trailing quotes or just one to show that they result in the filter-repo getting the exact same input arguments:
|
Oh, also, as this is entirely a shell issue, I should point out that quotes aren't necessary at all, even with spaces; The following:
would have also worked. The whole problem is how do you prevent the shell from breaking arguments at the space character; so that you can pass a simple OLDPREFIX:NEWPREFIX string as a single argument to filter-repo. |
Oooookkkkay. So, the issue all along was that my Git client of choice, PowerShell for Git (https://github.com/dahlbyk/posh-git), seems to not be respecting any of this!! Your last comment, something which i had explicitly tried to do earlier today made me suddenly think it could be the client. And of course, in the vanilla Git Bash.. it works le sigh 😕. Honestly thought i was going mad with you saying it worked, and me literally copy+pasting the command it not working! Thanks for your patience 🙂. 🤦 |
Ah, PowerShell has even funnier quoting rules/requirements than posix shells, eh? Good to know, thanks for the heads up. |
Hi,
I can't get the
--path-rename
command to function if there is a space in the path..Works:
git filter-repo --path new.folder/ --path-rename new.folder/:'' --force --dry-run
Fails:
git filter-repo --path 'new folder/' --path-rename 'new folder/':'' --force --dry-run
This simply throws the exception..
Is this a python version issue? I have tried all kinds of combinations, double quotes, escape chars, etc.
The text was updated successfully, but these errors were encountered: