comparison lisp/vc-git.el @ 107341:8bc19ba3da90

* vc-git.el: Re-flow to fit into 80 columns. (vc-git-after-dir-status-stage, vc-git-dir-status-goto-stage): Remove spurious `quote' element in each case alternative. (vc-git-show-log-entry): Use prog1. (vc-git-after-dir-status-stage): Remove unused var `remaining'.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Fri, 05 Mar 2010 23:05:47 -0500
parents 36d87e3f3cc3
children ff09b16a7200
comparison
equal deleted inserted replaced
107340:e0514072acb0 107341:8bc19ba3da90
67 ;; * find-revision (file rev buffer) OK 67 ;; * find-revision (file rev buffer) OK
68 ;; * checkout (file &optional editable rev) OK 68 ;; * checkout (file &optional editable rev) OK
69 ;; * revert (file &optional contents-done) OK 69 ;; * revert (file &optional contents-done) OK
70 ;; - rollback (files) COULD BE SUPPORTED 70 ;; - rollback (files) COULD BE SUPPORTED
71 ;; - merge (file rev1 rev2) It would be possible to merge 71 ;; - merge (file rev1 rev2) It would be possible to merge
72 ;; changes into a single file, but when 72 ;; changes into a single file, but
73 ;; committing they wouldn't 73 ;; when committing they wouldn't
74 ;; be identified as a merge 74 ;; be identified as a merge
75 ;; by git, so it's probably 75 ;; by git, so it's probably
76 ;; not a good idea. 76 ;; not a good idea.
77 ;; - merge-news (file) see `merge' 77 ;; - merge-news (file) see `merge'
78 ;; - steal-lock (file &optional revision) NOT NEEDED 78 ;; - steal-lock (file &optional revision) NOT NEEDED
128 128
129 ;;; STATE-QUERYING FUNCTIONS 129 ;;; STATE-QUERYING FUNCTIONS
130 130
131 ;;;###autoload (defun vc-git-registered (file) 131 ;;;###autoload (defun vc-git-registered (file)
132 ;;;###autoload "Return non-nil if FILE is registered with git." 132 ;;;###autoload "Return non-nil if FILE is registered with git."
133 ;;;###autoload (if (vc-find-root file ".git") ; short cut 133 ;;;###autoload (if (vc-find-root file ".git") ; Short cut.
134 ;;;###autoload (progn 134 ;;;###autoload (progn
135 ;;;###autoload (load "vc-git") 135 ;;;###autoload (load "vc-git")
136 ;;;###autoload (vc-git-registered file)))) 136 ;;;###autoload (vc-git-registered file))))
137 137
138 (defun vc-git-registered (file) 138 (defun vc-git-registered (file)
147 ;; See also: http://marc.info/?l=git&m=125787684318129&w=2 147 ;; See also: http://marc.info/?l=git&m=125787684318129&w=2
148 (name (file-relative-name file dir)) 148 (name (file-relative-name file dir))
149 (str (ignore-errors 149 (str (ignore-errors
150 (cd dir) 150 (cd dir)
151 (vc-git--out-ok "ls-files" "-c" "-z" "--" name) 151 (vc-git--out-ok "ls-files" "-c" "-z" "--" name)
152 ;; if result is empty, use ls-tree to check for deleted file 152 ;; If result is empty, use ls-tree to check for deleted
153 ;; file.
153 (when (eq (point-min) (point-max)) 154 (when (eq (point-min) (point-max))
154 (vc-git--out-ok "ls-tree" "--name-only" "-z" "HEAD" "--" name)) 155 (vc-git--out-ok "ls-tree" "--name-only" "-z" "HEAD"
156 "--" name))
155 (buffer-string)))) 157 (buffer-string))))
156 (and str 158 (and str
157 (> (length str) (length name)) 159 (> (length str) (length name))
158 (string= (substring str 0 (1+ (length name))) 160 (string= (substring str 0 (1+ (length name)))
159 (concat name "\0")))))))) 161 (concat name "\0"))))))))
171 "Git-specific version of `vc-state'." 173 "Git-specific version of `vc-state'."
172 ;; FIXME: This can't set 'ignored yet 174 ;; FIXME: This can't set 'ignored yet
173 (if (not (vc-git-registered file)) 175 (if (not (vc-git-registered file))
174 'unregistered 176 'unregistered
175 (vc-git--call nil "add" "--refresh" "--" (file-relative-name file)) 177 (vc-git--call nil "add" "--refresh" "--" (file-relative-name file))
176 (let ((diff (vc-git--run-command-string file "diff-index" "-z" "HEAD" "--"))) 178 (let ((diff (vc-git--run-command-string
179 file "diff-index" "-z" "HEAD" "--")))
177 (if (and diff (string-match ":[0-7]\\{6\\} [0-7]\\{6\\} [0-9a-f]\\{40\\} [0-9a-f]\\{40\\} \\([ADMUT]\\)\0[^\0]+\0" 180 (if (and diff (string-match ":[0-7]\\{6\\} [0-7]\\{6\\} [0-9a-f]\\{40\\} [0-9a-f]\\{40\\} \\([ADMUT]\\)\0[^\0]+\0"
178 diff)) 181 diff))
179 (vc-git--state-code (match-string 1 diff)) 182 (vc-git--state-code (match-string 1 diff))
180 (if (vc-git--empty-db-p) 'added 'up-to-date))))) 183 (if (vc-git--empty-db-p) 'added 'up-to-date)))))
181 184
204 (propertize def-ml 207 (propertize def-ml
205 'help-echo (concat help-echo "\nCurrent branch: " branch))))) 208 'help-echo (concat help-echo "\nCurrent branch: " branch)))))
206 209
207 (defstruct (vc-git-extra-fileinfo 210 (defstruct (vc-git-extra-fileinfo
208 (:copier nil) 211 (:copier nil)
209 (:constructor vc-git-create-extra-fileinfo (old-perm new-perm &optional rename-state orig-name)) 212 (:constructor vc-git-create-extra-fileinfo
213 (old-perm new-perm &optional rename-state orig-name))
210 (:conc-name vc-git-extra-fileinfo->)) 214 (:conc-name vc-git-extra-fileinfo->))
211 old-perm new-perm ;; permission flags 215 old-perm new-perm ;; Permission flags.
212 rename-state ;; rename or copy state 216 rename-state ;; Rename or copy state.
213 orig-name) ;; original name for renames or copies 217 orig-name) ;; Original name for renames or copies.
214 218
215 (defun vc-git-escape-file-name (name) 219 (defun vc-git-escape-file-name (name)
216 "Escape a file name if necessary." 220 "Escape a file name if necessary."
217 (if (string-match "[\n\t\"\\]" name) 221 (if (string-match "[\n\t\"\\]" name)
218 (concat "\"" 222 (concat "\""
230 (defun vc-git-file-type-as-string (old-perm new-perm) 234 (defun vc-git-file-type-as-string (old-perm new-perm)
231 "Return a string describing the file type based on its permissions." 235 "Return a string describing the file type based on its permissions."
232 (let* ((old-type (lsh (or old-perm 0) -9)) 236 (let* ((old-type (lsh (or old-perm 0) -9))
233 (new-type (lsh (or new-perm 0) -9)) 237 (new-type (lsh (or new-perm 0) -9))
234 (str (case new-type 238 (str (case new-type
235 (?\100 ;; file 239 (?\100 ;; File.
236 (case old-type 240 (case old-type
237 (?\100 nil) 241 (?\100 nil)
238 (?\120 " (type change symlink -> file)") 242 (?\120 " (type change symlink -> file)")
239 (?\160 " (type change subproject -> file)"))) 243 (?\160 " (type change subproject -> file)")))
240 (?\120 ;; symlink 244 (?\120 ;; Symlink.
241 (case old-type 245 (case old-type
242 (?\100 " (type change file -> symlink)") 246 (?\100 " (type change file -> symlink)")
243 (?\160 " (type change subproject -> symlink)") 247 (?\160 " (type change subproject -> symlink)")
244 (t " (symlink)"))) 248 (t " (symlink)")))
245 (?\160 ;; subproject 249 (?\160 ;; Subproject.
246 (case old-type 250 (case old-type
247 (?\100 " (type change file -> subproject)") 251 (?\100 " (type change file -> subproject)")
248 (?\120 " (type change symlink -> subproject)") 252 (?\120 " (type change symlink -> subproject)")
249 (t " (subproject)"))) 253 (t " (subproject)")))
250 (?\110 nil) ;; directory (internal, not a real git state) 254 (?\110 nil) ;; Directory (internal, not a real git state).
251 (?\000 ;; deleted or unknown 255 (?\000 ;; Deleted or unknown.
252 (case old-type 256 (case old-type
253 (?\120 " (symlink)") 257 (?\120 " (symlink)")
254 (?\160 " (subproject)"))) 258 (?\160 " (subproject)")))
255 (t (format " (unknown type %o)" new-type))))) 259 (t (format " (unknown type %o)" new-type)))))
256 (cond (str (propertize str 'face 'font-lock-comment-face)) 260 (cond (str (propertize str 'face 'font-lock-comment-face))
257 ((eq new-type ?\110) "/") 261 ((eq new-type ?\110) "/")
258 (t "")))) 262 (t ""))))
259 263
260 (defun vc-git-rename-as-string (state extra) 264 (defun vc-git-rename-as-string (state extra)
261 "Return a string describing the copy or rename associated with INFO, or an empty string if none." 265 "Return a string describing the copy or rename associated with INFO,
266 or an empty string if none."
262 (let ((rename-state (when extra 267 (let ((rename-state (when extra
263 (vc-git-extra-fileinfo->rename-state extra)))) 268 (vc-git-extra-fileinfo->rename-state extra))))
264 (if rename-state 269 (if rename-state
265 (propertize 270 (propertize
266 (concat " (" 271 (concat " ("
267 (if (eq rename-state 'copy) "copied from " 272 (if (eq rename-state 'copy) "copied from "
268 (if (eq state 'added) "renamed from " 273 (if (eq state 'added) "renamed from "
269 "renamed to ")) 274 "renamed to "))
270 (vc-git-escape-file-name (vc-git-extra-fileinfo->orig-name extra)) 275 (vc-git-escape-file-name
271 ")") 'face 'font-lock-comment-face) 276 (vc-git-extra-fileinfo->orig-name extra))
277 ")")
278 'face 'font-lock-comment-face)
272 ""))) 279 "")))
273 280
274 (defun vc-git-permissions-as-string (old-perm new-perm) 281 (defun vc-git-permissions-as-string (old-perm new-perm)
275 "Format a permission change as string." 282 "Format a permission change as string."
276 (propertize 283 (propertize
300 (t 'font-lock-variable-name-face)) 307 (t 'font-lock-variable-name-face))
301 'mouse-face 'highlight) 308 'mouse-face 'highlight)
302 " " (vc-git-permissions-as-string old-perm new-perm) 309 " " (vc-git-permissions-as-string old-perm new-perm)
303 " " 310 " "
304 (propertize (vc-git-escape-file-name (vc-dir-fileinfo->name info)) 311 (propertize (vc-git-escape-file-name (vc-dir-fileinfo->name info))
305 'face (if isdir 'font-lock-comment-delimiter-face 'font-lock-function-name-face) 312 'face (if isdir 'font-lock-comment-delimiter-face
313 'font-lock-function-name-face)
306 'help-echo 314 'help-echo
307 (if isdir 315 (if isdir
308 "Directory\nVC operations can be applied to it\nmouse-3: Pop-up menu" 316 "Directory\nVC operations can be applied to it\nmouse-3: Pop-up menu"
309 "File\nmouse-3: Pop-up menu") 317 "File\nmouse-3: Pop-up menu")
310 'keymap vc-dir-filename-mouse-map 318 'keymap vc-dir-filename-mouse-map
312 (vc-git-file-type-as-string old-perm new-perm) 320 (vc-git-file-type-as-string old-perm new-perm)
313 (vc-git-rename-as-string state extra)))) 321 (vc-git-rename-as-string state extra))))
314 322
315 (defun vc-git-after-dir-status-stage (stage files update-function) 323 (defun vc-git-after-dir-status-stage (stage files update-function)
316 "Process sentinel for the various dir-status stages." 324 "Process sentinel for the various dir-status stages."
317 (let (remaining next-stage result) 325 (let (next-stage result)
318 (goto-char (point-min)) 326 (goto-char (point-min))
319 (case stage 327 (case stage
320 ('update-index 328 (update-index
321 (setq next-stage (if (vc-git--empty-db-p) 'ls-files-added 329 (setq next-stage (if (vc-git--empty-db-p) 'ls-files-added
322 (if files 'ls-files-up-to-date 'diff-index)))) 330 (if files 'ls-files-up-to-date 'diff-index))))
323 ('ls-files-added 331 (ls-files-added
324 (setq next-stage 'ls-files-unknown) 332 (setq next-stage 'ls-files-unknown)
325 (while (re-search-forward "\\([0-7]\\{6\\}\\) [0-9a-f]\\{40\\} 0\t\\([^\0]+\\)\0" nil t) 333 (while (re-search-forward "\\([0-7]\\{6\\}\\) [0-9a-f]\\{40\\} 0\t\\([^\0]+\\)\0" nil t)
326 (let ((new-perm (string-to-number (match-string 1) 8)) 334 (let ((new-perm (string-to-number (match-string 1) 8))
327 (name (match-string 2))) 335 (name (match-string 2)))
328 (push (list name 'added (vc-git-create-extra-fileinfo 0 new-perm)) result)))) 336 (push (list name 'added (vc-git-create-extra-fileinfo 0 new-perm))
329 ('ls-files-up-to-date 337 result))))
338 (ls-files-up-to-date
330 (setq next-stage 'diff-index) 339 (setq next-stage 'diff-index)
331 (while (re-search-forward "\\([0-7]\\{6\\}\\) [0-9a-f]\\{40\\} 0\t\\([^\0]+\\)\0" nil t) 340 (while (re-search-forward "\\([0-7]\\{6\\}\\) [0-9a-f]\\{40\\} 0\t\\([^\0]+\\)\0" nil t)
332 (let ((perm (string-to-number (match-string 1) 8)) 341 (let ((perm (string-to-number (match-string 1) 8))
333 (name (match-string 2))) 342 (name (match-string 2)))
334 (push (list name 'up-to-date (vc-git-create-extra-fileinfo perm perm)) result)))) 343 (push (list name 'up-to-date
335 ('ls-files-unknown 344 (vc-git-create-extra-fileinfo perm perm))
345 result))))
346 (ls-files-unknown
336 (when files (setq next-stage 'ls-files-ignored)) 347 (when files (setq next-stage 'ls-files-ignored))
337 (while (re-search-forward "\\([^\0]*?\\)\0" nil t 1) 348 (while (re-search-forward "\\([^\0]*?\\)\0" nil t 1)
338 (push (list (match-string 1) 'unregistered (vc-git-create-extra-fileinfo 0 0)) result))) 349 (push (list (match-string 1) 'unregistered
339 ('ls-files-ignored 350 (vc-git-create-extra-fileinfo 0 0))
351 result)))
352 (ls-files-ignored
340 (while (re-search-forward "\\([^\0]*?\\)\0" nil t 1) 353 (while (re-search-forward "\\([^\0]*?\\)\0" nil t 1)
341 (push (list (match-string 1) 'ignored (vc-git-create-extra-fileinfo 0 0)) result))) 354 (push (list (match-string 1) 'ignored
342 ('diff-index 355 (vc-git-create-extra-fileinfo 0 0))
356 result)))
357 (diff-index
343 (setq next-stage 'ls-files-unknown) 358 (setq next-stage 'ls-files-unknown)
344 (while (re-search-forward 359 (while (re-search-forward
345 ":\\([0-7]\\{6\\}\\) \\([0-7]\\{6\\}\\) [0-9a-f]\\{40\\} [0-9a-f]\\{40\\} \\(\\([ADMUT]\\)\0\\([^\0]+\\)\\|\\([CR]\\)[0-9]*\0\\([^\0]+\\)\0\\([^\0]+\\)\\)\0" 360 ":\\([0-7]\\{6\\}\\) \\([0-7]\\{6\\}\\) [0-9a-f]\\{40\\} [0-9a-f]\\{40\\} \\(\\([ADMUT]\\)\0\\([^\0]+\\)\\|\\([CR]\\)[0-9]*\0\\([^\0]+\\)\0\\([^\0]+\\)\\)\0"
346 nil t 1) 361 nil t 1)
347 (let ((old-perm (string-to-number (match-string 1) 8)) 362 (let ((old-perm (string-to-number (match-string 1) 8))
348 (new-perm (string-to-number (match-string 2) 8)) 363 (new-perm (string-to-number (match-string 2) 8))
349 (state (or (match-string 4) (match-string 6))) 364 (state (or (match-string 4) (match-string 6)))
350 (name (or (match-string 5) (match-string 7))) 365 (name (or (match-string 5) (match-string 7)))
351 (new-name (match-string 8))) 366 (new-name (match-string 8)))
352 (if new-name ; copy or rename 367 (if new-name ; Copy or rename.
353 (if (eq ?C (string-to-char state)) 368 (if (eq ?C (string-to-char state))
354 (push (list new-name 'added (vc-git-create-extra-fileinfo old-perm new-perm 'copy name)) result) 369 (push (list new-name 'added
355 (push (list name 'removed (vc-git-create-extra-fileinfo 0 0 'rename new-name)) result) 370 (vc-git-create-extra-fileinfo old-perm new-perm
356 (push (list new-name 'added (vc-git-create-extra-fileinfo old-perm new-perm 'rename name)) result)) 371 'copy name))
357 (push (list name (vc-git--state-code state) (vc-git-create-extra-fileinfo old-perm new-perm)) result)))))) 372 result)
373 (push (list name 'removed
374 (vc-git-create-extra-fileinfo 0 0
375 'rename new-name))
376 result)
377 (push (list new-name 'added
378 (vc-git-create-extra-fileinfo old-perm new-perm
379 'rename name))
380 result))
381 (push (list name (vc-git--state-code state)
382 (vc-git-create-extra-fileinfo old-perm new-perm))
383 result))))))
358 (when result 384 (when result
359 (setq result (nreverse result)) 385 (setq result (nreverse result))
360 (when files 386 (when files
361 (dolist (entry result) (setq files (delete (car entry) files))) 387 (dolist (entry result) (setq files (delete (car entry) files)))
362 (unless files (setq next-stage nil)))) 388 (unless files (setq next-stage nil))))
363 (when (or result (not next-stage)) (funcall update-function result next-stage)) 389 (when (or result (not next-stage))
364 (when next-stage (vc-git-dir-status-goto-stage next-stage files update-function)))) 390 (funcall update-function result next-stage))
391 (when next-stage
392 (vc-git-dir-status-goto-stage next-stage files update-function))))
365 393
366 (defun vc-git-dir-status-goto-stage (stage files update-function) 394 (defun vc-git-dir-status-goto-stage (stage files update-function)
367 (erase-buffer) 395 (erase-buffer)
368 (case stage 396 (case stage
369 ('update-index 397 (update-index
370 (if files 398 (if files
371 (vc-git-command (current-buffer) 'async files "add" "--refresh" "--") 399 (vc-git-command (current-buffer) 'async files "add" "--refresh" "--")
372 (vc-git-command (current-buffer) 'async nil "update-index" "--refresh"))) 400 (vc-git-command (current-buffer) 'async nil
373 ('ls-files-added 401 "update-index" "--refresh")))
374 (vc-git-command (current-buffer) 'async files "ls-files" "-z" "-c" "-s" "--")) 402 (ls-files-added
375 ('ls-files-up-to-date 403 (vc-git-command (current-buffer) 'async files
376 (vc-git-command (current-buffer) 'async files "ls-files" "-z" "-c" "-s" "--")) 404 "ls-files" "-z" "-c" "-s" "--"))
377 ('ls-files-unknown 405 (ls-files-up-to-date
378 (vc-git-command (current-buffer) 'async files "ls-files" "-z" "-o" 406 (vc-git-command (current-buffer) 'async files
379 "--directory" "--no-empty-directory" "--exclude-standard" "--")) 407 "ls-files" "-z" "-c" "-s" "--"))
380 ('ls-files-ignored 408 (ls-files-unknown
381 (vc-git-command (current-buffer) 'async files "ls-files" "-z" "-o" "-i" 409 (vc-git-command (current-buffer) 'async files
382 "--directory" "--no-empty-directory" "--exclude-standard" "--")) 410 "ls-files" "-z" "-o" "--directory"
383 ('diff-index 411 "--no-empty-directory" "--exclude-standard" "--"))
384 (vc-git-command (current-buffer) 'async files "diff-index" "--relative" "-z" "-M" "HEAD" "--"))) 412 (ls-files-ignored
413 (vc-git-command (current-buffer) 'async files
414 "ls-files" "-z" "-o" "-i" "--directory"
415 "--no-empty-directory" "--exclude-standard" "--"))
416 (diff-index
417 (vc-git-command (current-buffer) 'async files
418 "diff-index" "--relative" "-z" "-M" "HEAD" "--")))
385 (vc-exec-after 419 (vc-exec-after
386 `(vc-git-after-dir-status-stage (quote ,stage) (quote ,files) (quote ,update-function)))) 420 `(vc-git-after-dir-status-stage ',stage ',files ',update-function)))
387 421
388 (defun vc-git-dir-status (dir update-function) 422 (defun vc-git-dir-status (dir update-function)
389 "Return a list of (FILE STATE EXTRA) entries for DIR." 423 "Return a list of (FILE STATE EXTRA) entries for DIR."
390 ;; Further things that would have to be fixed later: 424 ;; Further things that would have to be fixed later:
391 ;; - how to handle unregistered directories 425 ;; - how to handle unregistered directories
437 (progn 471 (progn
438 (setq branch (match-string 2 str)) 472 (setq branch (match-string 2 str))
439 (setq remote 473 (setq remote
440 (with-output-to-string 474 (with-output-to-string
441 (with-current-buffer standard-output 475 (with-current-buffer standard-output
442 (vc-git--out-ok "config" (concat "branch." branch ".remote"))))) 476 (vc-git--out-ok "config"
477 (concat "branch." branch ".remote")))))
443 (when (string-match "\\([^\n]+\\)" remote) 478 (when (string-match "\\([^\n]+\\)" remote)
444 (setq remote (match-string 1 remote))) 479 (setq remote (match-string 1 remote)))
445 (when remote 480 (when remote
446 (setq remote-url 481 (setq remote-url
447 (with-output-to-string 482 (with-output-to-string
448 (with-current-buffer standard-output 483 (with-current-buffer standard-output
449 (vc-git--out-ok "config" (concat "remote." remote ".url")))))) 484 (vc-git--out-ok "config"
485 (concat "remote." remote ".url"))))))
450 (when (string-match "\\([^\n]+\\)" remote-url) 486 (when (string-match "\\([^\n]+\\)" remote-url)
451 (setq remote-url (match-string 1 remote-url)))) 487 (setq remote-url (match-string 1 remote-url))))
452 (setq branch "not (detached HEAD)")) 488 (setq branch "not (detached HEAD)"))
453 ;; FIXME: maybe use a different face when nothing is stashed. 489 ;; FIXME: maybe use a different face when nothing is stashed.
454 (concat 490 (concat
548 (apply 'vc-git-command buffer 584 (apply 'vc-git-command buffer
549 'async files 585 'async files
550 (append 586 (append
551 '("log" "--no-color") 587 '("log" "--no-color")
552 (when shortlog 588 (when shortlog
553 '("--graph" "--decorate" 589 '("--graph" "--decorate" "--date=short"
554 "--date=short" "--pretty=format:%d%h %ad %s" "--abbrev-commit")) 590 "--pretty=format:%d%h %ad %s" "--abbrev-commit"))
555 (when limit (list "-n" (format "%s" limit))) 591 (when limit (list "-n" (format "%s" limit)))
556 (when start-revision (list start-revision)) 592 (when start-revision (list start-revision))
557 '("--"))))))) 593 '("--")))))))
558 594
559 (defvar log-view-message-re) 595 (defvar log-view-message-re)
563 599
564 ;; Dynamically bound. 600 ;; Dynamically bound.
565 (defvar vc-short-log) 601 (defvar vc-short-log)
566 602
567 (define-derived-mode vc-git-log-view-mode log-view-mode "Git-Log-View" 603 (define-derived-mode vc-git-log-view-mode log-view-mode "Git-Log-View"
568 (require 'add-log) ;; we need the faces add-log 604 (require 'add-log) ;; We need the faces add-log.
569 ;; Don't have file markers, so use impossible regexp. 605 ;; Don't have file markers, so use impossible regexp.
570 (set (make-local-variable 'log-view-file-re) "\\`a\\`") 606 (set (make-local-variable 'log-view-file-re) "\\`a\\`")
571 (set (make-local-variable 'log-view-per-file-logs) nil) 607 (set (make-local-variable 'log-view-per-file-logs) nil)
572 (set (make-local-variable 'log-view-message-re) 608 (set (make-local-variable 'log-view-message-re)
573 (if vc-short-log 609 (if vc-short-log
608 (defun vc-git-show-log-entry (revision) 644 (defun vc-git-show-log-entry (revision)
609 "Move to the log entry for REVISION. 645 "Move to the log entry for REVISION.
610 REVISION may have the form BRANCH, BRANCH~N, 646 REVISION may have the form BRANCH, BRANCH~N,
611 or BRANCH^ (where \"^\" can be repeated)." 647 or BRANCH^ (where \"^\" can be repeated)."
612 (goto-char (point-min)) 648 (goto-char (point-min))
613 (let (found) 649 (prog1
614 (when revision 650 (when revision
615 (setq found 651 (search-forward
616 (search-forward (format "\ncommit %s" revision) nil t 652 (format "\ncommit %s" revision) nil t
617 (cond ((string-match "~\\([0-9]\\)$" revision) 653 (cond ((string-match "~\\([0-9]\\)\\'" revision)
618 (1+ (string-to-number (match-string 1 revision)))) 654 (1+ (string-to-number (match-string 1 revision))))
619 ((string-match "\\^+$" revision) 655 ((string-match "\\^+\\'" revision)
620 (1+ (length (match-string 0 revision)))) 656 (1+ (length (match-string 0 revision))))
621 (t nil))))) 657 (t nil))))
622 (beginning-of-line) 658 (beginning-of-line)))
623 found))
624 659
625 (defun vc-git-diff (files &optional rev1 rev2 buffer) 660 (defun vc-git-diff (files &optional rev1 rev2 buffer)
626 "Get a difference report using Git between two revisions of FILES." 661 "Get a difference report using Git between two revisions of FILES."
627 (let (process-file-side-effects) 662 (let (process-file-side-effects)
628 (apply #'vc-git-command (or buffer "*vc-diff*") 1 files 663 (apply #'vc-git-command (or buffer "*vc-diff*") 1 files
946 (and 981 (and
947 (vc-git--out-ok "name-rev" "--name-only" commit) 982 (vc-git--out-ok "name-rev" "--name-only" commit)
948 (goto-char (point-min)) 983 (goto-char (point-min))
949 (= (forward-line 2) 1) 984 (= (forward-line 2) 1)
950 (bolp) 985 (bolp)
951 (buffer-substring-no-properties (point-min) (1- (point-max))))))) 986 (buffer-substring-no-properties (point-min)
987 (1- (point-max)))))))
952 (and name (not (string= name "undefined")) name)))) 988 (and name (not (string= name "undefined")) name))))
953 989
954 (provide 'vc-git) 990 (provide 'vc-git)
955 991
956 ;; arch-tag: bd10664a-0e5b-48f5-a877-6c17b135be12 992 ;; arch-tag: bd10664a-0e5b-48f5-a877-6c17b135be12