Skip to content

Commit

Permalink
Merge pull request #11 from syohex/add-validation
Browse files Browse the repository at this point in the history
Add validation
  • Loading branch information
pidu committed Jul 29, 2014
2 parents 32d1164 + 51c2c73 commit 8b10363
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions git-timemachine.el
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,18 @@
("w" . git-timemachine-kill-revision))
:group 'git-timemachine)

(defun git-timemachine-validate (file)
(unless file
(error "This buffer is not related to file."))
(with-temp-buffer
(unless (zerop (call-process "git" nil nil nil "ls-files" "--error-unmatch" file))
(error "This file is not git tracked."))))

;;;###autoload
(defun git-timemachine ()
"Enable git timemachine for file of current buffer."
(interactive)
(git-timemachine-validate (buffer-file-name))
(let ((git-directory (file-name-as-directory (car (process-lines "git" "rev-parse" "--show-toplevel"))))
(file-name (buffer-file-name))
(timemachine-buffer (format "timemachine:%s" (buffer-name)))
Expand Down

0 comments on commit 8b10363

Please sign in to comment.