build: better guard against another process changing the working tree during a build