;;; vc-git.el --- VC backend for the git version control system
-;; Copyright (C) 2006, 2007, 2008 Free Software Foundation, Inc.
+;; Copyright (C) 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
;; Author: Alexandre Julliard <julliard@winehq.org>
;; Keywords: tools
(require 'vc-dir)
(require 'grep))
+(defcustom vc-git-diff-switches t
+ "String or list of strings specifying switches for Git diff under VC.
+If nil, use the value of `vc-diff-switches'. If t, use no switches."
+ :type '(choice (const :tag "Unspecified" nil)
+ (const :tag "None" t)
+ (string :tag "Argument String")
+ (repeat :tag "Argument List" :value ("") string))
+ :version "23.1"
+ :group 'vc)
+
(defvar git-commits-coding-system 'utf-8
"Default coding system for git commits.")
(if (eq 0 (logand ?\111 old-perm)) "+x" "-x"))
'face 'font-lock-type-face))
-(defun vc-git-status-printer (info)
+(defun vc-git-dir-printer (info)
"Pretty-printer for the vc-dir-fileinfo structure."
- (let* ((state (if (vc-dir-fileinfo->directory info)
- 'DIRECTORY
- (vc-dir-fileinfo->state info)))
+ (let* ((isdir (vc-dir-fileinfo->directory info))
+ (state (if isdir "" (vc-dir-fileinfo->state info)))
(extra (vc-dir-fileinfo->extra info))
(old-perm (when extra (vc-git-extra-fileinfo->old-perm extra)))
(new-perm (when extra (vc-git-extra-fileinfo->new-perm extra))))
(t 'font-lock-variable-name-face))
'mouse-face 'highlight)
" " (vc-git-permissions-as-string old-perm new-perm)
- " "
+ " "
(propertize (vc-git-escape-file-name (vc-dir-fileinfo->name info))
- 'face 'font-lock-function-name-face
- 'mouse-face 'highlight)
+ 'face (if isdir 'font-lock-comment-delimiter-face 'font-lock-function-name-face)
+ 'help-echo
+ (if isdir
+ "Directory\nVC operations can be applied to it\nmouse-3: Pop-up menu"
+ "File\nmouse-3: Pop-up menu")
+ 'mouse-face 'highlight)
(vc-git-file-type-as-string old-perm new-perm)
(vc-git-rename-as-string state extra))))
"Return a list of (FILE STATE EXTRA) entries for FILES in DIR."
(vc-git-dir-status-goto-stage 'update-index files update-function))
-(defun vc-git-status-extra-headers (dir)
+(defun vc-git-dir-extra-headers (dir)
(let ((str (with-output-to-string
(with-current-buffer standard-output
(vc-git--out-ok "symbolic-ref" "HEAD")))))
REVISION may have the form BRANCH, BRANCH~N,
or BRANCH^ (where \"^\" can be repeated)."
(goto-char (point-min))
- (search-forward "\ncommit" nil t
- (cond ((string-match "~\\([0-9]\\)$" revision)
- (1+ (string-to-number (match-string 1 revision))))
- ((string-match "\\^+$" revision)
- (1+ (length (match-string 0 revision))))
- (t nil)))
+ (when revision
+ (search-forward (format "\ncommit %s" revision) nil t
+ (cond ((string-match "~\\([0-9]\\)$" revision)
+ (1+ (string-to-number (match-string 1 revision))))
+ ((string-match "\\^+$" revision)
+ (1+ (length (match-string 0 revision))))
+ (t nil))))
(beginning-of-line))
(defun vc-git-diff (files &optional rev1 rev2 buffer)
- (let ((buf (or buffer "*vc-diff*")))
- (if (and rev1 rev2)
- (vc-git-command buf 1 files "diff-tree" "--exit-code" "-p"
- rev1 rev2 "--")
- (vc-git-command buf 1 files "diff-index" "--exit-code" "-p"
- (or rev1 "HEAD") "--"))))
+ "Get a difference report using Git between two revisions of FILES."
+ (apply #'vc-git-command (or buffer "*vc-diff*") 1 files
+ (if (and rev1 rev2) "diff-tree" "diff-index")
+ "--exit-code"
+ (append (vc-switches 'git 'diff)
+ (list "-p" (or rev1 "HEAD") rev2 "--"))))
(defun vc-git-revision-table (files)
;; What about `files'?!? --Stef