-
Notifications
You must be signed in to change notification settings - Fork 717
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
Renaming path and then renaming it back to the original name deletes path rather than renaming it (renaming to another path that exists has weird side effects) #569
Comments
This problem looks to be an example of "unexpected" behavior that can occur when the new name in In the above scenario, the path rename of On the other hand, the path rename of @newren I'm not exactly sure what you intend to happen when the new name in |
Yeah, working as expected. Unfortunately, attempting to determine if the new pathnames are in the commit history, within a relevant range of commits, is computationally quite expensive and can become challenging in terms of tracking the topology correctly. This can be even worse since the renaming can happen with --path-rename or --paths-from-file or --filename-callback and might be a prefix, or a glob, or a regex, or some more general function making it hard to even enumerate all the new names. I added a very simplistic check (basically only triggering if there was a commit which modified both the old and new filenames when users tried to rename one to the other -- in that case filter-repo will print a "File renaming caused colliding pathnames" error and abort). That can sometimes help users, but it leaves a lot of cases out because I don't think a more general one is really feasible. I'd be very happy to take a patch to add a warning to the manual. |
Using the
--replace-refs delete-no-add
workaround from Bug #401, I've found a scenario wheregit filter-repo --path-rename <source-path>:<target-path>
deletes the source path rather than renaming it to the target path as shown below.Create a new Git repository
Perform initial Git commit
Create and commit file f1
Rename file f1 to f2
Create and commit new f1 file
Delete and commit new f1 file
Rename file f2 to f1
Note that
git filter-repo --replace-refs delete-no-add --path-rename f2:f1 --force
incorrectly deleted filef2
rather than renaming it tof1
The text was updated successfully, but these errors were encountered: