diff options
| author | Dan Nicolaescu <dann@ics.uci.edu> | 2008-03-22 17:33:52 +0000 |
|---|---|---|
| committer | Dan Nicolaescu <dann@ics.uci.edu> | 2008-03-22 17:33:52 +0000 |
| commit | 8e4e4aefb66b5333c97bfb0dfba0750716a77415 (patch) | |
| tree | 9a8c3877b2f2e98081accbed39206018dc1eb22f /lisp | |
| parent | dd3ffb9a381f5fb3ef61988d0c0733b33c059c8f (diff) | |
| download | emacs-8e4e4aefb66b5333c97bfb0dfba0750716a77415.tar.gz | |
(vc-git--empty-db-p)
(vc-git-after-dir-status-stage1-empty-db): New functions.
(vc-git-dir-status, vc-git-after-dir-status-stage1, vc-git-state):
Add support for empty repositories.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/vc-git.el | 28 |
2 files changed, 30 insertions, 5 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index f7bacf9b31b..353bf47b5e8 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2008-03-22 Alexandre Julliard <julliard@winehq.org> + + * vc-git.el (vc-git--empty-db-p) + (vc-git-after-dir-status-stage1-empty-db): New functions. + (vc-git-dir-status, vc-git-after-dir-status-stage1, vc-git-state): + Add support for empty repositories. + 2008-03-22 Dan Nicolaescu <dann@ics.uci.edu> * vc-git.el (vc-git-annotate-extract-revision-at-line): diff --git a/lisp/vc-git.el b/lisp/vc-git.el index 36d17ad4a75..82c00677169 100644 --- a/lisp/vc-git.el +++ b/lisp/vc-git.el @@ -149,7 +149,7 @@ (if (and diff (string-match ":[0-7]\\{6\\} [0-7]\\{6\\} [0-9a-f]\\{40\\} [0-9a-f]\\{40\\} \\([ADMU]\\)\0[^\0]+\0" diff)) (if (string= (match-string 1 diff) "A") 'added 'edited) - 'up-to-date))) + (if (vc-git--empty-db-p) 'added 'up-to-date)))) (defun vc-git--ls-files-state (state &rest args) "Set state to STATE on all files found with git-ls-files ARGS." @@ -229,10 +229,19 @@ (vc-exec-after `(vc-git-after-dir-status-stage2 (quote ,update-function) ,status-buffer))) +(defun vc-git-after-dir-status-stage1-empty-db (update-function status-buffer) + (goto-char (point-min)) + (while (re-search-forward "\\([^\0]*?\\)\0" nil t 1) + (push (cons (match-string 1) 'added) vc-git-status-result)) + (erase-buffer) + (vc-git-command (current-buffer) 'async nil "ls-files" "-z" "-o" + "--directory" "--no-empty-directory" "--exclude-standard") + (vc-exec-after + `(vc-git-after-dir-status-stage2 (quote ,update-function) ,status-buffer))) + (defun vc-git-dir-status (dir update-function status-buffer) "Return a list of conses (file . state) for DIR." ;; Further things that would have to be fixed later: - ;; - support for an empty repository (with no initial commit) ;; - how to handle unregistered directories ;; - how to support vc-status on a subdir of the project tree (with-current-buffer @@ -241,9 +250,14 @@ (set (make-local-variable 'vc-git-status-result) nil) (cd dir) (erase-buffer) - (vc-git-command (current-buffer) 'async nil "diff-index" "-z" "HEAD") - (vc-exec-after - `(vc-git-after-dir-status-stage1 (quote ,update-function) ,status-buffer)) + (if (vc-git--empty-db-p) + (progn + (vc-git-command (current-buffer) 'async nil "ls-files" "-z" "-c") + (vc-exec-after + `(vc-git-after-dir-status-stage1-empty-db (quote ,update-function) ,status-buffer))) + (vc-git-command (current-buffer) 'async nil "diff-index" "-z" "HEAD") + (vc-exec-after + `(vc-git-after-dir-status-stage1 (quote ,update-function) ,status-buffer))) (current-buffer))) ;;; STATE-CHANGING FUNCTIONS @@ -482,6 +496,10 @@ or BRANCH^ (where \"^\" can be repeated)." The difference to vc-do-command is that this function always invokes `git'." (apply 'vc-do-command buffer okstatus "git" file-or-list flags)) +(defun vc-git--empty-db-p () + "Check if the git db is empty (no commit done yet)." + (not (eq 0 (vc-git--call nil "rev-parse" "--verify" "HEAD")))) + (defun vc-git--call (buffer command &rest args) ;; We don't need to care the arguments. If there is a file name, it ;; is always a relative one. This works also for remote |
