diff options
| -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 @@ | |||
| 1 | 2008-03-22 Alexandre Julliard <julliard@winehq.org> | ||
| 2 | |||
| 3 | * vc-git.el (vc-git--empty-db-p) | ||
| 4 | (vc-git-after-dir-status-stage1-empty-db): New functions. | ||
| 5 | (vc-git-dir-status, vc-git-after-dir-status-stage1, vc-git-state): | ||
| 6 | Add support for empty repositories. | ||
| 7 | |||
| 1 | 2008-03-22 Dan Nicolaescu <dann@ics.uci.edu> | 8 | 2008-03-22 Dan Nicolaescu <dann@ics.uci.edu> |
| 2 | 9 | ||
| 3 | * vc-git.el (vc-git-annotate-extract-revision-at-line): | 10 | * 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 @@ | |||
| 149 | (if (and diff (string-match ":[0-7]\\{6\\} [0-7]\\{6\\} [0-9a-f]\\{40\\} [0-9a-f]\\{40\\} \\([ADMU]\\)\0[^\0]+\0" | 149 | (if (and diff (string-match ":[0-7]\\{6\\} [0-7]\\{6\\} [0-9a-f]\\{40\\} [0-9a-f]\\{40\\} \\([ADMU]\\)\0[^\0]+\0" |
| 150 | diff)) | 150 | diff)) |
| 151 | (if (string= (match-string 1 diff) "A") 'added 'edited) | 151 | (if (string= (match-string 1 diff) "A") 'added 'edited) |
| 152 | 'up-to-date))) | 152 | (if (vc-git--empty-db-p) 'added 'up-to-date)))) |
| 153 | 153 | ||
| 154 | (defun vc-git--ls-files-state (state &rest args) | 154 | (defun vc-git--ls-files-state (state &rest args) |
| 155 | "Set state to STATE on all files found with git-ls-files ARGS." | 155 | "Set state to STATE on all files found with git-ls-files ARGS." |
| @@ -229,10 +229,19 @@ | |||
| 229 | (vc-exec-after | 229 | (vc-exec-after |
| 230 | `(vc-git-after-dir-status-stage2 (quote ,update-function) ,status-buffer))) | 230 | `(vc-git-after-dir-status-stage2 (quote ,update-function) ,status-buffer))) |
| 231 | 231 | ||
| 232 | (defun vc-git-after-dir-status-stage1-empty-db (update-function status-buffer) | ||
| 233 | (goto-char (point-min)) | ||
| 234 | (while (re-search-forward "\\([^\0]*?\\)\0" nil t 1) | ||
| 235 | (push (cons (match-string 1) 'added) vc-git-status-result)) | ||
| 236 | (erase-buffer) | ||
| 237 | (vc-git-command (current-buffer) 'async nil "ls-files" "-z" "-o" | ||
| 238 | "--directory" "--no-empty-directory" "--exclude-standard") | ||
| 239 | (vc-exec-after | ||
| 240 | `(vc-git-after-dir-status-stage2 (quote ,update-function) ,status-buffer))) | ||
| 241 | |||
| 232 | (defun vc-git-dir-status (dir update-function status-buffer) | 242 | (defun vc-git-dir-status (dir update-function status-buffer) |
| 233 | "Return a list of conses (file . state) for DIR." | 243 | "Return a list of conses (file . state) for DIR." |
| 234 | ;; Further things that would have to be fixed later: | 244 | ;; Further things that would have to be fixed later: |
| 235 | ;; - support for an empty repository (with no initial commit) | ||
| 236 | ;; - how to handle unregistered directories | 245 | ;; - how to handle unregistered directories |
| 237 | ;; - how to support vc-status on a subdir of the project tree | 246 | ;; - how to support vc-status on a subdir of the project tree |
| 238 | (with-current-buffer | 247 | (with-current-buffer |
| @@ -241,9 +250,14 @@ | |||
| 241 | (set (make-local-variable 'vc-git-status-result) nil) | 250 | (set (make-local-variable 'vc-git-status-result) nil) |
| 242 | (cd dir) | 251 | (cd dir) |
| 243 | (erase-buffer) | 252 | (erase-buffer) |
| 244 | (vc-git-command (current-buffer) 'async nil "diff-index" "-z" "HEAD") | 253 | (if (vc-git--empty-db-p) |
| 245 | (vc-exec-after | 254 | (progn |
| 246 | `(vc-git-after-dir-status-stage1 (quote ,update-function) ,status-buffer)) | 255 | (vc-git-command (current-buffer) 'async nil "ls-files" "-z" "-c") |
| 256 | (vc-exec-after | ||
| 257 | `(vc-git-after-dir-status-stage1-empty-db (quote ,update-function) ,status-buffer))) | ||
| 258 | (vc-git-command (current-buffer) 'async nil "diff-index" "-z" "HEAD") | ||
| 259 | (vc-exec-after | ||
| 260 | `(vc-git-after-dir-status-stage1 (quote ,update-function) ,status-buffer))) | ||
| 247 | (current-buffer))) | 261 | (current-buffer))) |
| 248 | 262 | ||
| 249 | ;;; STATE-CHANGING FUNCTIONS | 263 | ;;; STATE-CHANGING FUNCTIONS |
| @@ -482,6 +496,10 @@ or BRANCH^ (where \"^\" can be repeated)." | |||
| 482 | The difference to vc-do-command is that this function always invokes `git'." | 496 | The difference to vc-do-command is that this function always invokes `git'." |
| 483 | (apply 'vc-do-command buffer okstatus "git" file-or-list flags)) | 497 | (apply 'vc-do-command buffer okstatus "git" file-or-list flags)) |
| 484 | 498 | ||
| 499 | (defun vc-git--empty-db-p () | ||
| 500 | "Check if the git db is empty (no commit done yet)." | ||
| 501 | (not (eq 0 (vc-git--call nil "rev-parse" "--verify" "HEAD")))) | ||
| 502 | |||
| 485 | (defun vc-git--call (buffer command &rest args) | 503 | (defun vc-git--call (buffer command &rest args) |
| 486 | ;; We don't need to care the arguments. If there is a file name, it | 504 | ;; We don't need to care the arguments. If there is a file name, it |
| 487 | ;; is always a relative one. This works also for remote | 505 | ;; is always a relative one. This works also for remote |