Hadn't known vc-refresh-state gets into my find-file-hook irregardless. This won't work with git branches in a detached HEAD state. emacs -Q --batch -l vc-git -l log-edit --eval "\ (let* ((dir (make-temp-file \"vc-git-tests\" t)) \ (default-directory dir)) \ (vc-git-create-repo) \ (with-temp-file \"foo\") \ (vc-git-register (split-string \"foo\")) \ (vc-git-checkin (split-string \"foo\") \"his fooness\") \ (vc-git-checkout nil (vc-git--rev-parse \"HEAD\" t)) \ (with-current-buffer (find-file-noselect \"foo\") \ (run-hooks (quote find-file-hook)))) \ "