Kate rewrites a hard link of a file with a copy of it, so it will not point to original file. Reproducible: Always Steps to Reproduce: 1. Create a hard link for a text file 2. Edit the newly created link via Kate/kwrite 3. Save the changes (i used ctrl+s) Actual Results: We have 2 different files with it's own different contents. Expected Results: The original file and the link with the same content.
I can confirm this bug on FreeBSD 10.0-CURRENT and Qt: 4.8.4 KDE Development Platform: 4.10.1 Kate: 3.10.1
Again, most certainly a KSaveFile issue: KSaveFile writes to a temporary file and then renames the file, probably turning the hardlink into a normal file.
Generic KSaveFile issue.
Thiago wrote this in https://codereview.qt-project.org/52059 : "Who says the effects are undesireable? The hardlink may have been placed there so a backup copy could exist if the file got modified. Think of how Git shares object files between repositories: a hardlink is created and, if the file is modified for any reason (not one of the WORM files), it breaks the hardlink -- COW behaviour." Dominik, Christoph: OK to close as WONTFIX (or INVALID)?
I would be ok with that, hard links to user editable files are anyway a real corner case.
The problem with this is that the link is SILENTLY reomved. A user will have gone to some trouble to create the hard link in the first place and its arrogant to assume that it needs to be broken by any editing. There needs to be an option within KSaveFile giving choice of saving method: 1. A mv into place, which can be atomic (good) and can be the default. 2. A cp into place, which is not atomic, but preserves any hard link. Further Observations: Most people would think it bizarre if editing a symlink generated a second copy of the file. Editing a file with nano (for example) preserves hard links, see the quotation above.
*** This bug has been confirmed by popular vote. ***
I completely agree with comment #6. I have recently had the need to use hard links for a specific purpose, only to find out that Kate and all the programs that use it destroy my links (without a choice or warning), which is totally unacceptable.