I am syncing two repos A and B. Will the following operations cause data loss: 1. File 1 is locked in repo A, and its symlink target is edited without unlocking file 1. 2. File 1 is unlocked and editted in repo B, followed by a git-annex add operation. 3. Repo A and B are synced with git-annex sync --content Will the editing in step 1 be lost? If so, can you please do a git fsck on the file to be overwritten to at lease give a warning.
I am using emacs su-mode, until recently have I found that su-mode let me edit the symlink target without unlocking.
git-annex fsck
will detect this problem, but the real problem here is not that some edit got lost, but that you corrupted a version control object file. Similar to editing a file in.git/objects/
. Fsck will, when it notices the problem, move the corrupted object file to `.git/annex/bad/'. So your edits are not lost, but are in danger of being forgotten.Note that, once the modified version of the file from repo B replaces the worktree file,
git annex fsck
of that file won't check the old version, so will not detect the problem.git annex fsck --all
still will detect it.git-annex mostly prevents this kind of problem by making the file not have a write bit be set, and putting it in a directory that also has its write bit not set.
You have to either be running as root, or using a program that goes out of its way to change multiple permissions, to get into that situation.
(One example of a program that does is vim.
:w!
will temporarily overwrite both write bits.)