diff options
| author | Thien-Thi Nguyen | 2007-11-24 14:35:54 +0000 |
|---|---|---|
| committer | Thien-Thi Nguyen | 2007-11-24 14:35:54 +0000 |
| commit | 2aa0736ab509f264e28d3fdfd831bc6512daf6a7 (patch) | |
| tree | 91e559a5bd114f9c4d86688c10330e2e9d944a59 | |
| parent | d6447bae097fa58f5c26b73203f222f48556655b (diff) | |
| download | emacs-2aa0736ab509f264e28d3fdfd831bc6512daf6a7.tar.gz emacs-2aa0736ab509f264e28d3fdfd831bc6512daf6a7.zip | |
Refill; nfc.
| -rw-r--r-- | lisp/vc-git.el | 111 |
1 files changed, 60 insertions, 51 deletions
diff --git a/lisp/vc-git.el b/lisp/vc-git.el index f891bac8bd1..0810361e7fb 100644 --- a/lisp/vc-git.el +++ b/lisp/vc-git.el | |||
| @@ -116,7 +116,7 @@ | |||
| 116 | ;;; BACKEND PROPERTIES | 116 | ;;; BACKEND PROPERTIES |
| 117 | 117 | ||
| 118 | (defun vc-git-revision-granularity () | 118 | (defun vc-git-revision-granularity () |
| 119 | 'repository) | 119 | 'repository) |
| 120 | 120 | ||
| 121 | ;;; STATE-QUERYING FUNCTIONS | 121 | ;;; STATE-QUERYING FUNCTIONS |
| 122 | 122 | ||
| @@ -134,17 +134,20 @@ | |||
| 134 | (let* ((dir (file-name-directory file)) | 134 | (let* ((dir (file-name-directory file)) |
| 135 | (name (file-relative-name file dir))) | 135 | (name (file-relative-name file dir))) |
| 136 | (and (ignore-errors | 136 | (and (ignore-errors |
| 137 | (when dir (cd dir)) | 137 | (when dir (cd dir)) |
| 138 | (eq 0 (call-process "git" nil '(t nil) nil "ls-files" "-c" "-z" "--" name))) | 138 | (eq 0 (call-process "git" nil '(t nil) nil "ls-files" |
| 139 | "-c" "-z" "--" name))) | ||
| 139 | (let ((str (buffer-string))) | 140 | (let ((str (buffer-string))) |
| 140 | (and (> (length str) (length name)) | 141 | (and (> (length str) (length name)) |
| 141 | (string= (substring str 0 (1+ (length name))) (concat name "\0"))))))))) | 142 | (string= (substring str 0 (1+ (length name))) |
| 143 | (concat name "\0"))))))))) | ||
| 142 | 144 | ||
| 143 | (defun vc-git-state (file) | 145 | (defun vc-git-state (file) |
| 144 | "Git-specific version of `vc-state'." | 146 | "Git-specific version of `vc-state'." |
| 145 | (call-process "git" nil nil nil "add" "--refresh" "--" (file-relative-name file)) | 147 | (call-process "git" nil nil nil "add" "--refresh" "--" (file-relative-name file)) |
| 146 | (let ((diff (vc-git--run-command-string file "diff-index" "-z" "HEAD" "--"))) | 148 | (let ((diff (vc-git--run-command-string file "diff-index" "-z" "HEAD" "--"))) |
| 147 | (if (and diff (string-match ":[0-7]\\{6\\} [0-7]\\{6\\} [0-9a-f]\\{40\\} [0-9a-f]\\{40\\} [ADMU]\0[^\0]+\0" diff)) | 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)) | ||
| 148 | 'edited | 151 | 'edited |
| 149 | 'up-to-date))) | 152 | 'up-to-date))) |
| 150 | 153 | ||
| @@ -158,7 +161,8 @@ | |||
| 158 | (setq status-char (char-after)) | 161 | (setq status-char (char-after)) |
| 159 | (setq file | 162 | (setq file |
| 160 | (expand-file-name | 163 | (expand-file-name |
| 161 | (buffer-substring-no-properties (+ (point) 2) (line-end-position)))) | 164 | (buffer-substring-no-properties (+ (point) 2) |
| 165 | (line-end-position)))) | ||
| 162 | (cond | 166 | (cond |
| 163 | ;; The rest of the possible states in "git ls-files -t" output: | 167 | ;; The rest of the possible states in "git ls-files -t" output: |
| 164 | ;; R removed/deleted | 168 | ;; R removed/deleted |
| @@ -290,27 +294,27 @@ | |||
| 290 | "^commit *\\([0-9a-z]+\\)") | 294 | "^commit *\\([0-9a-z]+\\)") |
| 291 | (set (make-local-variable 'log-view-font-lock-keywords) | 295 | (set (make-local-variable 'log-view-font-lock-keywords) |
| 292 | (append | 296 | (append |
| 293 | `((,log-view-message-re (1 'change-log-acknowledgement)) | 297 | `((,log-view-message-re (1 'change-log-acknowledgement)) |
| 294 | (,log-view-file-re (1 'change-log-file-face))) | 298 | (,log-view-file-re (1 'change-log-file-face))) |
| 295 | ;; Handle the case: | 299 | ;; Handle the case: |
| 296 | ;; user: foo@bar | 300 | ;; user: foo@bar |
| 297 | '(("^Author:[ \t]+\\([A-Za-z0-9_.+-]+@[A-Za-z0-9_.-]+\\)" | 301 | '(("^Author:[ \t]+\\([A-Za-z0-9_.+-]+@[A-Za-z0-9_.-]+\\)" |
| 298 | (1 'change-log-email)) | 302 | (1 'change-log-email)) |
| 299 | ;; Handle the case: | 303 | ;; Handle the case: |
| 300 | ;; user: FirstName LastName <foo@bar> | 304 | ;; user: FirstName LastName <foo@bar> |
| 301 | ("^Author:[ \t]+\\([^<(]+?\\)[ \t]*[(<]\\([A-Za-z0-9_.+-]+@[A-Za-z0-9_.-]+\\)[>)]" | 305 | ("^Author:[ \t]+\\([^<(]+?\\)[ \t]*[(<]\\([A-Za-z0-9_.+-]+@[A-Za-z0-9_.-]+\\)[>)]" |
| 302 | (1 'change-log-name) | 306 | (1 'change-log-name) |
| 303 | (2 'change-log-email)) | 307 | (2 'change-log-email)) |
| 304 | ("^ +\\(?:\\(?:[Aa]cked\\|[Ss]igned-[Oo]ff\\)-[Bb]y:\\)[ \t]+\\([A-Za-z0-9_.+-]+@[A-Za-z0-9_.-]+\\)" | 308 | ("^ +\\(?:\\(?:[Aa]cked\\|[Ss]igned-[Oo]ff\\)-[Bb]y:\\)[ \t]+\\([A-Za-z0-9_.+-]+@[A-Za-z0-9_.-]+\\)" |
| 305 | (1 'change-log-name)) | 309 | (1 'change-log-name)) |
| 306 | ("^ +\\(?:\\(?:[Aa]cked\\|[Ss]igned-[Oo]ff\\)-[Bb]y:\\)[ \t]+\\([^<(]+?\\)[ \t]*[(<]\\([A-Za-z0-9_.+-]+@[A-Za-z0-9_.-]+\\)[>)]" | 310 | ("^ +\\(?:\\(?:[Aa]cked\\|[Ss]igned-[Oo]ff\\)-[Bb]y:\\)[ \t]+\\([^<(]+?\\)[ \t]*[(<]\\([A-Za-z0-9_.+-]+@[A-Za-z0-9_.-]+\\)[>)]" |
| 307 | (1 'change-log-name) | 311 | (1 'change-log-name) |
| 308 | (2 'change-log-email)) | 312 | (2 'change-log-email)) |
| 309 | ("^Merge: \\([0-9a-z]+\\) \\([0-9a-z]+\\)" | 313 | ("^Merge: \\([0-9a-z]+\\) \\([0-9a-z]+\\)" |
| 310 | (1 'change-log-acknowledgement) | 314 | (1 'change-log-acknowledgement) |
| 311 | (2 'change-log-acknowledgement)) | 315 | (2 'change-log-acknowledgement)) |
| 312 | ("^Date: \\(.+\\)" (1 'change-log-date)) | 316 | ("^Date: \\(.+\\)" (1 'change-log-date)) |
| 313 | ("^summary:[ \t]+\\(.+\\)" (1 'log-view-message)))))) | 317 | ("^summary:[ \t]+\\(.+\\)" (1 'log-view-message)))))) |
| 314 | 318 | ||
| 315 | (defun vc-git-show-log-entry (revision) | 319 | (defun vc-git-show-log-entry (revision) |
| 316 | "Move to the log entry for REVISION. | 320 | "Move to the log entry for REVISION. |
| @@ -328,8 +332,10 @@ or BRANCH^ (where \"^\" can be repeated)." | |||
| 328 | (defun vc-git-diff (files &optional rev1 rev2 buffer) | 332 | (defun vc-git-diff (files &optional rev1 rev2 buffer) |
| 329 | (let ((buf (or buffer "*vc-diff*"))) | 333 | (let ((buf (or buffer "*vc-diff*"))) |
| 330 | (if (and rev1 rev2) | 334 | (if (and rev1 rev2) |
| 331 | (vc-git-command buf 1 files "diff-tree" "--exit-code" "-p" rev1 rev2 "--") | 335 | (vc-git-command buf 1 files "diff-tree" "--exit-code" "-p" |
| 332 | (vc-git-command buf 1 files "diff-index" "--exit-code" "-p" (or rev1 "HEAD") "--")))) | 336 | rev1 rev2 "--") |
| 337 | (vc-git-command buf 1 files "diff-index" "--exit-code" "-p" | ||
| 338 | (or rev1 "HEAD") "--")))) | ||
| 333 | 339 | ||
| 334 | (defun vc-git-revision-table (files) | 340 | (defun vc-git-revision-table (files) |
| 335 | ;; What about `files'?!? --Stef | 341 | ;; What about `files'?!? --Stef |
| @@ -356,13 +362,15 @@ or BRANCH^ (where \"^\" can be repeated)." | |||
| 356 | (defun vc-git-annotate-time () | 362 | (defun vc-git-annotate-time () |
| 357 | (and (re-search-forward "[0-9a-f]+ (.* \\([0-9]+\\)-\\([0-9]+\\)-\\([0-9]+\\) \\([0-9]+\\):\\([0-9]+\\):\\([0-9]+\\) \\([-+0-9]+\\) +[0-9]+)" nil t) | 363 | (and (re-search-forward "[0-9a-f]+ (.* \\([0-9]+\\)-\\([0-9]+\\)-\\([0-9]+\\) \\([0-9]+\\):\\([0-9]+\\):\\([0-9]+\\) \\([-+0-9]+\\) +[0-9]+)" nil t) |
| 358 | (vc-annotate-convert-time | 364 | (vc-annotate-convert-time |
| 359 | (apply #'encode-time (mapcar (lambda (match) (string-to-number (match-string match))) '(6 5 4 3 2 1 7)))))) | 365 | (apply #'encode-time (mapcar (lambda (match) |
| 366 | (string-to-number (match-string match))) | ||
| 367 | '(6 5 4 3 2 1 7)))))) | ||
| 360 | 368 | ||
| 361 | (defun vc-git-annotate-extract-revision-at-line () | 369 | (defun vc-git-annotate-extract-revision-at-line () |
| 362 | (save-excursion | 370 | (save-excursion |
| 363 | (move-beginning-of-line 1) | 371 | (move-beginning-of-line 1) |
| 364 | (and (looking-at "[0-9a-f]+") | 372 | (and (looking-at "[0-9a-f]+") |
| 365 | (buffer-substring-no-properties (match-beginning 0) (match-end 0))))) | 373 | (buffer-substring-no-properties (match-beginning 0) (match-end 0))))) |
| 366 | 374 | ||
| 367 | ;;; SNAPSHOT SYSTEM | 375 | ;;; SNAPSHOT SYSTEM |
| 368 | 376 | ||
| @@ -397,27 +405,27 @@ or BRANCH^ (where \"^\" can be repeated)." | |||
| 397 | (zerop (forward-line -1)) | 405 | (zerop (forward-line -1)) |
| 398 | (not (bobp)) | 406 | (not (bobp)) |
| 399 | (buffer-substring-no-properties | 407 | (buffer-substring-no-properties |
| 400 | (point) | 408 | (point) |
| 401 | (1- (point-max)))))))) | 409 | (1- (point-max)))))))) |
| 402 | 410 | ||
| 403 | (defun vc-git-next-revision (file rev) | 411 | (defun vc-git-next-revision (file rev) |
| 404 | "Git-specific version of `vc-next-revision'." | 412 | "Git-specific version of `vc-next-revision'." |
| 405 | (let* ((default-directory (file-name-directory | 413 | (let* ((default-directory (file-name-directory |
| 406 | (expand-file-name file))) | 414 | (expand-file-name file))) |
| 407 | (file (file-name-nondirectory file)) | 415 | (file (file-name-nondirectory file)) |
| 408 | (current-rev | 416 | (current-rev |
| 409 | (with-temp-buffer | 417 | (with-temp-buffer |
| 410 | (and | 418 | (and |
| 411 | (zerop | 419 | (zerop |
| 412 | (call-process "git" nil '(t nil) nil "rev-list" | 420 | (call-process "git" nil '(t nil) nil "rev-list" |
| 413 | "-1" rev "--" file)) | 421 | "-1" rev "--" file)) |
| 414 | (goto-char (point-max)) | 422 | (goto-char (point-max)) |
| 415 | (bolp) | 423 | (bolp) |
| 416 | (zerop (forward-line -1)) | 424 | (zerop (forward-line -1)) |
| 417 | (bobp) | 425 | (bobp) |
| 418 | (buffer-substring-no-properties | 426 | (buffer-substring-no-properties |
| 419 | (point) | 427 | (point) |
| 420 | (1- (point-max))))))) | 428 | (1- (point-max))))))) |
| 421 | (and current-rev | 429 | (and current-rev |
| 422 | (vc-git-symbolic-commit | 430 | (vc-git-symbolic-commit |
| 423 | (with-temp-buffer | 431 | (with-temp-buffer |
| @@ -455,7 +463,8 @@ The difference to vc-do-command is that this function always invokes `git'." | |||
| 455 | (str (with-output-to-string | 463 | (str (with-output-to-string |
| 456 | (with-current-buffer standard-output | 464 | (with-current-buffer standard-output |
| 457 | (unless (eq 0 (apply #'call-process "git" nil '(t nil) nil | 465 | (unless (eq 0 (apply #'call-process "git" nil '(t nil) nil |
| 458 | (append args (list (file-relative-name file))))) | 466 | (append args (list (file-relative-name |
| 467 | file))))) | ||
| 459 | (setq ok nil)))))) | 468 | (setq ok nil)))))) |
| 460 | (and ok str))) | 469 | (and ok str))) |
| 461 | 470 | ||