samp coding-system-for-read t)))
(setq coding-system-for-read 'undecided)))
+(defconst vc-git--empty-tree "4b825dc642cb6eb9a060e54bf8d69288fbee4904"
+ "Git object ID of the empty tree object.")
+
(defun vc-git-diff (files &optional rev1 rev2 buffer async)
"Get a difference report using Git between two revisions of FILES."
(let (process-file-side-effects
(command "diff-tree"))
(vc-git--asciify-coding-system)
(if rev2
- ;; Diffing against the empty tree.
- (unless rev1 (setq rev1 "4b825dc642cb6eb9a060e54bf8d69288fbee4904"))
+ (unless rev1 (setq rev1 vc-git--empty-tree))
(setq command "diff-index")
- (unless rev1 (setq rev1 "HEAD")))
+ (unless rev1
+ ;; If there aren't any commits yet then there is no HEAD.
+ ;; So diff against the empty tree object.
+ (setq rev1 (if (vc-git--empty-db-p) vc-git--empty-tree "HEAD"))))
(if vc-git-diff-switches
(apply #'vc-git-command (or buffer "*vc-diff*")
(if async 'async 1)