templates / branches--on commit write_ref_to_lockfile(): new function, extracted from write_ref_sha1() (1d45523)
   1: this is just to ensure the directory exists.