-
Notifications
You must be signed in to change notification settings - Fork 739
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
Any failure in command deletes everything from both commit and disk #631
Comments
Um,
Very much disagree. The directory is the latest version and if history rewrites modify the latest version, the working directory should be made to match.
No, it throws an error:
Hard to determine what's going wrong when each of the incomplete example commands you provide has one or more errors in it. I suspect you're making similar usage errors in the parts you've elided but I can't correct them unless I know what the commands you are using are. Could you provide some?
You've lost me now; do you mean File-exists check? I'm not sure if you're just continuing to make errors or if you've completely jumped in your train of thought without explaining the connection.
I mean, there's a |
Edit: Skim/Skip this. Accurate issue describe bellow. Yeah sorry, I didn't give exact command. I just wrote it like I say it. But what I mean is that sometimes delete from current working directory and sometime doesn't (Just deletes from history as I wanted). I don't know if it's due to git rm, git rm --cached needing to be done before or after, or if the file is gitignored, And when you make a typo inside the command, like the one time I gave it a path to a non existant file, It deleted every file in the project repo that wasn't git ignored. ( I was in src/ and gave a file thinking I was in project root. So I gave ./src/filename). That's just a bug that should never happen. Another time, I forgot the spaces (before or after, don't remember) "--invert-path" and it did the same. Deleted nearly everything. Maybe not git ignored files and files that start with . so Of course a path to a non existant file and the wrong path to a file are the same thing. I don't remember the specifics of what didn't get deleted, I just dealt with it before. It deleted pretty much every important thing that I wanted to git track. At the end of the day, I use this when a file that's too big get accidentally added 10 or so commit back, and I can't push to github because of it. Or if a semi private file get pushed. If it nukes, I lose all progress since last push. I tend to make a backup locally by just copying the directory when I use it, but when 10 times in a row, it all goes well, you stop being cautious, and then some weird behaviors destroy everything. At least if the files aren't touched, then even if history is fucked, you can just clone again and then merge the files diffs. Maybe a --keep-in-dir option or something would be nice. Because actually deleting the file, and not having it in the history are two different things imo, and rm exist for that already. No need to change default behavior to keep backward compatibility. (Except the two bugs). And if it already exist, please tell. |
Figured it out. And after going back through history logs from a month ago, the --invert-path was missing in the first example, which is my bad. But the other time, for the spacing case (non existant files), that's on ya'll. --invert-paths made it so it only kept a non existant file. git filter-repo --path <path/to/file/not/exist> nukes the projects `git filter-repo --path file1 --path file2 ... |
I'm on arch linux. Here's the versions and commits. ❯ git version Minimal example: Go into a non git dir to be safe.
Outputs from zsh inside tmux.
And yeah, I need to use force cause not a fresh clone. And, anyway since 99% of the time I use it due to not being able to push (because I accidentally not ignored some large file), kinda doesn't apply. Maybe a force-safe flag should be used. Or again, just throw an error if a file doesn't exist, and if someone want to use filter repo to do a total nuke, then they should use `rm -rf |
Only
gitignore is irrelevant, unless you mean the file wasn't tracked at all in git. You shouldn't need to do git rm or git rm --cached before or after. Can you provide an example of the repo you had, the command you ran, what you saw, and what you expected?
I doubt you did; when I try it:
it provides a nice error. git-filter-repo is aware of that common mistake that users make and checks for it. (...unless you're using a really old version of git-filter-repo?) If you ran something like
The fact that the command does as it is told (e.g. "Do not keep anything other than this (non-existent) path"), is hardly a bug; the program is doing what it is told. The problem is the user told it something they didn't actually want.
Let's check this out...
No it doesn't:
No it doesn't:
No it doesn't:
However, your examples are definitely bad in that every single one of them was using a path that started with
at least on any sane OS. I have learned that sadly on some inferior OSes, they have something that automatically translates a path like
Yes, the commands are very problematic for the user to specify, as shown above. But git-filter-repo handled them all admirably with nice errors.
|
Yes, as documented.
I'm not following, perhaps because I haven't seen a good example command line from you yet demonstrating the bug. Or maybe I missed it. Can you provide one?
Nope, walking all of history to check whether each and every path listed has ever existed in any commit is a very expensive check in repositories of any meaningful size. There's a good reason the documentation:
|
Yeah, I adjusted the comments as I wrote it. I kinda always edits until i have a final version. Didn't think you had responded earlier. Anyway, the last case is perfect. yes, i didn't test path that start with /, i just wrote it that way as an abstract path, guess i should have put </path/to/non_existant_file>. Anyway, my last comment shows an example. |
So yes, use analize and dry-run? |
Oh, it still totally applies:
And note that you no longer have to pass |
Still has the leading
You mean
which is the one I was asking about. |
Well, in this example
I'll modify into this, so force isn't needed. Though, it was never about force.
My problems is that it shows nothing (aka, the project got nuked), you said doing verifications for if the file called Does that mean, that filter repo can delete all occurance of a file inside a special path, for every commit, even if it's currently deleted. And if you move the file, it will remove the occurance in the paths you get, but won't affect the path where it moved. So, due to that, you can't just do a check for if it exists in current stage/commit/directory, because it needs to be able to delete moved, renamed and rm'ed files. |
Yes, exactly as you asked.
Yes, which again is exactly what you told the command to do. But, in this latter case, you can just delete the test_copy directory once you realize the result is not what you wanted, and then re-run the
Right, it deleted all the files, just as you asked. (More specifically, you told it you only wanted to keep
It doesn't check for renames, no. But the path absolutely could exist in older versions and not in current versions, and since filter-repo is about rewriting history, making assumptions about recent versions only makes little sense. What you're asking basically amounts to a multiple pass and walk of all history, where the first path walks all of history to find which files exist, and then before starting the second pass, error out if some of the paths specified by the user don't exist, and then start the second pass that does the actual rewrite. If you wanted to write something like that, you could have some script call
No; filter-repo is about rewriting all of history of the whole repo; this is too niche IMO; especially since...
...this seems like a perfectly reasonable way to handle the special case where you only care if it currently exists in the working directory. |
Thanks, really helped me learn. |
Cool! Glad it was helpful. |
This must be fixed. I've lost my progress 3 times now due to using it. I usually keep copies of the entire project before using it...
But, since its needed multiple time sometimes...
If you git filter repo --path --invert-paths
and it's given a file that doesn't exist, it will deletes every file in the project.
At worst, it should delete every file from commit history. But it should not touch the actual file in the directory.
git filter-repo --invert path (miss a space).
Same thing, it whipes every thing.
File does not exist check is basic. I do not know why it is not present.
If so, please educate me. If there are saveguard flags, what are they.
The text was updated successfully, but these errors were encountered: