- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 934
index.move failed when file being moved contains the string " to " #1283
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
Comments
Thanks a lot for the report! It's quite amazing to see 11 year old code do…that. Indeed, it would be great if you could attempt a fix. I would be curious if a test breaks without this kind of parsing, and if not it's probably safe to discard. |
Confirmed. The code is running
This is going to be hard to distinguish the |
😬 |
That's a tough one indeed. One could hope there is some sort of flag that allows to change the messaging around renames. Otherwise GitPython would have to re-implement the renaming logic to be able to anticipate outputs from inputs. |
The question is if the |
It does look like some more sophisticated parsing is required. Since git --dry-run puts single quotes around the source and destination file in the output, the parser for this would have to recognise the difference between the "to" in between the single quote in 'filename to move.txt' to 'destination to move to.txt' and the "to" that is in between the two single quoted strings. |
Oh indeed, there are single quotes which makes parsing this non-ambiguous. Once one verified that single-quotes within single-quotes are escaped with a backslash the parser should be able to do the right thing at all times. |
Note that currently the code is parsing the second half of the output, the one without the quotes. I have no idea if they are always the same. |
I've added a single quote to one of the files:
🙄 |
I just run in this very issue, and was stumped by it... the real fix is to use a programmatic interface instead of using Popen and parsing the raw text output. This triggered me to migrate from GitPython to pygit2 on top of libgit2. That said, I do want to give some kudos to the maintainers of this project for maintaining it for so long (Nov 2014, almost 14 years. Funily the same age as pygit2, which had its first commit in the same month). Thanks. |
When the filename being moved contains the string " to " this command fails with the assertion error "Too many tokens"
Steps to reproduce.
Result:
Assertion error "Too Many Tokens"
Then found this line
GitPython/git/index/base.py
Line 952 in 18c777b
Happy to look at working on a fix, but don't exactly understand why the parsing of the string returned from git is required.
The text was updated successfully, but these errors were encountered: