code: def get_HEAD_SHA1(git_dir):
      
      head_file = os.path.join(git_dir, 'HEAD')
      with open(head_file, 'r') as hf:
          head_contents = hf.read().strip()
      assert head_contents.startswith('ref: ')
      ref_filename = head_contents[5:]  # strip off "ref: "
      real_ref = os.path.join(git_dir, ref_filename)
      with open(real_ref, 'r') as rf:
          return rf.read().strip()
docs: Not locked!