If lock is true you just truncated a file that wasn't supposed to be modified until the new version was fully written to disk *and* the lock was released.

Git relies on doing atomic updates on the filesystem by writing the new content to a new temporary file, and renaming that over the real file name once the new content is completely written.  This method *COMPLETELY* ignores that scheme, making it incompatible and useless for JGit.