Rewrite the real file if history file is a symlink#7754
Conversation
Mind posting your error? It's not failing on CI or for me, and it's not skipped either (that test only runs if git is installed). Not that I think it's related, but it might show differences in our setup. |
|
Yes, here you go: It fails on the master branch as well for me. I haven't looked at it in detail, I assumed it's the same problem as https://github.com/fish-shell/fish-shell/runs/1997846755?check_suite_focus=true, but that's probably not the case. In fact, it's probably because the test is affected by my global |
Yeah, that's it. We either need to disable .gitconfig here or at least anchor the match some more ( Either way, not related.
Nah, that's lsan being lsan - we do some funky business in the tests that regularly confuses it. But given these are tests, the funky business is the point. |
|
Yes, exactly. If you like, here's the same fix you mentioned in pull request form: #7755. It works for me. |
|
Alright, at a glance this looks okay but I don't want to add it to 3.2.0 this late (hopefully) in the cycle and risk breaking history. If we do a 3.2.1 it can go in there. |
|
Thanks for looking at it! I didn't realize you were going to release 3.2 today. Congratulations! I'm happy for this to get in later. There's one minor issue I fixed in a new commit. It was a bit confusing. Let me know if you think it's potentially problematic. I wanted to see what happens when the symlink points to an invalid location or another file-system. In the latter case, the history writing fails, which I think is a good outcome. However, no error is shown to the user, which is less good. It is also a bit surprising, since in the case of The error for fish-shell/src/env_universal_common.cpp Lines 486 to 491 in 589eb34 In Lines 852 to 854 in 589eb34 I'm not exactly sure why the former code produces output and the latter does not, but it seems to be intended. At least, the So, I added a commit that adds the first kind of |
The former produces output because it's FLOG category "error", which is enabled by default. (this is the first argument to "FLOGF") The latter has the category "history_file", which isn't. You'd have to start fish with Making it consistent with the former seems correct. There's a point to be made that they should be "warning" because fish is still mostly functional (but less so without universal variables), but that's a question for another time. I would just change "history_file" to "error" for now - keep the message because it's more informative, but change the category. Definitely no two FLOGs with different categories. |
|
Thanks, that sounds good, I'll probably do it tomorrow. I also plan to rebase this branch (thus finding out how pull requests deal with rewriting history) and move the the changelog entry to the other section. Should I use the more informative message even though it is not localized? Also, there is an option to move the entire |
Localize it - i.e. put it through |
When the history file is a symbolic link, `fish` used to overwrite the link with a real file whenever it saved history. This makes it follow the symlink and overwrite the real file instead. The same issue was fixed for the `fish_variables` file in 622f286 from #7728. This makes `fish_history` behave in the same way. The implementation is nearly identical. Since the tests for the two issues are so similar, I combined them together and slightly expanded the older test. This also addresses #7553.
Currently, when history file renaming fails, no message is shown to the user. This happens, for instance, if the history file is a symlink pointing to another filesystem. This copies code (with a bit of variation, after reviewer comments) from https://github.com/fish-shell/fish-shell/blob/589eb34571e00da530395776166dd873489d4027/src/env_universal_common.cpp#L486-L491 into `history.cpp`, so that a message is shown to the user.
|
In case the rebase is annoying, here are the changes since the previous version: b1a203d...ilyagr:tmp. Maybe I'll try a merge and lots of fix-ups next time. |
|
Merged, thanks! |
|
Thank you! |
This is a followup to #7728 that makes
fish_historybehave consistently with the new behavior offish_variables. It should also help with issues like #7553.I combined the tests for the two features, renamed the test file, and fixed the issue where the old test could pass if fish didn't write anything to the expected location of
fish_variables. I couldn't find a good way to have a nice diff for the rename. Let me know if you prefer separate tests.The checks/git.fish test is currently failing, but I believe that is because of <...>. Edit: that wasn't the reason.
TODOs: