Do you check the files' modification dates?
For checking if the file was modified ? It is easier than that, my program is implementing the file system so I see every write operation on the file. I can easily now if the file was modified and only write then (edit: it is done). That won't change the fact that comments are discarded when the file is written back in the writable branch. Anyway, I think it is best to keep your settings in read only branch, and let the writable branch for in-game modification.
You could possibly support a three-way merge on raw files. My raw file merges almost always proceed without any hiccups. (Though that "almost" gives me pause. I'm not sure what would be appropriate to do in the event of a conflict, for a FUSE plugin.)
By three-way merge, I assume you are speaking of merging an old version, a new version and modified old version into a modified new version. That is not what I meant to do here. I apply mods on a base version (maybe already modified by other mods), it is always a two-way merge. Files in a mod need not to be complete but only a patch made for the current version. The mod can be generated from a three-way diff but that outside the scope of the filesystem.
It was maybe not very clear in my first post but merged files (init.txt, d_init.txt, ...) must be minimal patches if you want to see the modification that came from updating the other branches. For example, if you make a "mod" whose only purpose is displaying the FPS, init.txt should only contains:
[FPS:YES]
so that if another mod that change the tileset, is loaded before the FPS mod, it is not overwritten by the FPS mod.
I think I will make some tools based on the algorithms used in the filesystem to generate such diff files.
Edit: The filesystem no only write the file when it was modified, comments are still discarded when writing. I also added a dfdiff tool to make diff file for mods. Example
$ dfdiff init ~/games/df-test/{base,mayday}/data/init/init.txt
[FONT:mayday-no-highlight.png]
[FPS:YES]
[FULLFONT:mayday-no-highlight.png]
[GRAPHICS:YES]
[GRAPHICS_FONT:mayday.png]
[GRAPHICS_FULLFONT:mayday.png]
[G_FPS_CAP:25]
[INTRO:NO]
[MACRO_MS:0]
[PRINT_MODE:TWBT]
[SOUND:NO]
[TRUETYPE:NO]
[VSYNC:YES]
[ZOOM_SPEED:5]