{"thread":{"id":"7054","subject":"[PATCH 2/7] Add basic support for customization (vc-git.el)","startedAt":"2007-03-03T10:18:32Z","lastAt":"2007-03-03T10:18:32Z","messageCount":1,"participants":["Xavier Maillard"],"isPatch":true,"patchVersion":1,"patchTotal":7},"messages":[{"id":"36160","messageId":"15277.1172917112@localhost","threadId":"7054","inReplyTo":null,"subject":"[PATCH 2/7] Add basic support for customization (vc-git.el)","fromName":"Xavier Maillard","fromEmail":"zedek@gnu.org","sentAt":"2007-03-03T10:18:32Z","receivedAt":"2007-03-03T10:18:32Z","isPatch":true,"sender":{"key":"zedek@gnu.org","avatar":null},"body":"\n* vc-git, vc-git-program-name, vc-git-author-name\n  vc-git-author-email : defcustom\n\n* replace all occurences of call to git to vc-git-program-name\n\n* add --author switch to vc-git-checkin\n\n* add docstring to vc-git-checkin\n\nSigned-off-by: Xavier Maillard <zedek@gnu.org>\n---\n contrib/emacs/vc-git.el |   56 +++++++++++++++++++++++++++++++++++++---------\n 1 files changed, 45 insertions(+), 11 deletions(-)\n\ndiff --git a/contrib/emacs/vc-git.el b/contrib/emacs/vc-git.el\nindex 3d43ca0..8ec470c 100644\n--- a/contrib/emacs/vc-git.el\n+++ b/contrib/emacs/vc-git.el\n@@ -36,6 +36,28 @@\n ;; Add it automatically\n (add-to-list 'vc-handled-backends 'GIT)\n \n+(defgroup vc-git nil\n+  \"*This is GIT backend for vc.\"\n+  :prefix \"vc-git-\"\n+  :group 'vc)\n+\n+(defcustom vc-git-program-name \"git\"\n+  \"*The name of the git command.\"\n+  :type 'string\n+  :group 'vc-git)\n+\n+(defcustom vc-git-author-name nil\n+\"*Author name to use in git. If nil, we check for environment variables\n+GIT_AUTHOR_NAME or `user_full_name'.\"\n+  :type '(choice string (const nil))\n+  :group 'vc-git)\n+\n+(defcustom vc-git-author-email nil\n+\"*Author email to use in git. If nil, we check for environment variables\n+GIT_AUTHOR_ADDRESS and if still nil, `user_mail_address'.\"\n+  :type '(choice string (const nil))\n+  :group 'vc-git)\n+\n (defvar git-commits-coding-system 'utf-8\n   \"Default coding system for git commits.\")\n \n@@ -44,7 +66,7 @@\n   (let* ((ok t)\n          (str (with-output-to-string\n                 (with-current-buffer standard-output\n-                  (unless (eq 0 (apply #'call-process \"git\" nil '(t nil) nil\n+                  (unless (eq 0 (apply #'call-process vc-git-program-name nil '(t nil) nil\n                                        (append args (list (file-relative-name file)))))\n                     (setq ok nil))))))\n     (and ok str)))\n@@ -52,7 +74,7 @@\n (defun vc-git--run-command (file &rest args)\n   \"Run a git command on FILE, discarding any output.\"\n   (let ((name (file-relative-name file)))\n-    (eq 0 (apply #'call-process \"git\" nil (get-buffer \"*Messages\") nil (append args (list name))))))\n+    (eq 0 (apply #'call-process vc-git-program-name nil (get-buffer \"*Messages\") nil (append args (list name))))))\n \n (defun vc-git-registered (file)\n   \"Check whether FILE is registered with git.\"\n@@ -61,7 +83,7 @@\n            (name (file-relative-name file dir)))\n       (and (ignore-errors\n              (when dir (cd dir))\n-             (eq 0 (call-process \"git\" nil '(t nil) nil \"ls-files\" \"-c\" \"-z\" \"--\" name)))\n+             (eq 0 (call-process vc-git-program-name nil '(t nil) nil \"ls-files\" \"-c\" \"-z\" \"--\" name)))\n            (let ((str (buffer-string)))\n              (and (> (length str) (length name))\n                   (string= (substring str 0 (1+ (length name))) (concat name \"\\0\"))))))))\n@@ -77,7 +99,7 @@\n   \"git-specific version of `vc-workfile-version'.\"\n   (let ((str (with-output-to-string\n                (with-current-buffer standard-output\n-                 (call-process \"git\" nil '(t nil) nil \"symbolic-ref\" \"HEAD\")))))\n+                 (call-process vc-git-program-name nil '(t nil) nil \"symbolic-ref\" \"HEAD\")))))\n     (if (string-match \"^\\\\(refs/heads/\\\\)?\\\\(.+\\\\)$\" str)\n         (match-string 2 str)\n       str)))\n@@ -105,20 +127,32 @@\n (defun vc-git-print-log (file &optional buffer)\n   (let ((name (file-relative-name file))\n         (coding-system-for-read git-commits-coding-system))\n-    (vc-do-command buffer 'async \"git\" name \"rev-list\" \"--pretty\" \"HEAD\" \"--\")))\n+    (vc-do-command buffer 'async vc-git-program-name name \"rev-list\" \"--pretty\" \"HEAD\" \"--\")))\n \n (defun vc-git-diff (file &optional rev1 rev2 buffer)\n   (let ((name (file-relative-name file))\n         (buf (or buffer \"*vc-diff*\")))\n     (if (and rev1 rev2)\n-        (vc-do-command buf 0 \"git\" name \"diff-tree\" \"-p\" rev1 rev2 \"--\")\n-      (vc-do-command buf 0 \"git\" name \"diff-index\" \"-p\" (or rev1 \"HEAD\") \"--\"))\n+        (vc-do-command buf 0 vc-git-program-name name \"diff-tree\" \"-p\" rev1 rev2 \"--\")\n+      (vc-do-command buf 0 vc-git-program-name name \"diff-index\" \"-p\" (or rev1 \"HEAD\") \"--\"))\n     ; git-diff-index doesn't set exit status like diff does\n     (if (vc-git-workfile-unchanged-p file) 0 1)))\n \n (defun vc-git-checkin (file rev comment)\n-  (let ((coding-system-for-write git-commits-coding-system))\n-    (vc-git--run-command file \"commit\" \"-m\" comment \"--only\" \"--\")))\n+  \"Record FILE to git. REV should always be nil and is ignored,\n+COMMENT is the new comment.\"\n+  (let ((coding-system-for-write git-commits-coding-system)\n+\t(author-name (or vc-git-author-name\n+\t\t\t (getenv \"GIT_AUTHOR_NAME\")\n+\t\t\t user-full-name))\n+\t(author-email (or vc-git-author-email\n+\t\t\t (getenv \"GIT_AUTHOR_ADDRESS\")\n+\t\t\t user-mail-address)))\n+    \n+    (vc-git--run-command (file-name-nondirectory file) \"commit\" \"-m\" \n+\t\t\t comment \n+\t\t\t \"--author\" (concat author-name \" <\" author-email \">\")\n+\t\t\t \"--only\" \"--\")))\n \n (defun vc-git-checkout (file &optional editable rev destfile)\n   (if destfile\n@@ -128,14 +162,14 @@\n             (coding-system-for-read 'no-conversion)\n             (coding-system-for-write 'no-conversion))\n         (with-temp-file destfile\n-          (eq 0 (call-process \"git\" nil t nil \"cat-file\" \"blob\"\n+          (eq 0 (call-process vc-git-program-name nil t nil \"cat-file\" \"blob\"\n                               (concat (or rev \"HEAD\") \":\" fullname)))))\n     (vc-git--run-command file \"checkout\" (or rev \"HEAD\"))))\n \n (defun vc-git-annotate-command (file buf &optional rev)\n   ; FIXME: rev is ignored\n   (let ((name (file-relative-name file)))\n-    (call-process \"git\" nil buf nil \"blame\" name)))\n+    (call-process vc-git-program-name nil buf nil \"blame\" name)))\n \n (defun vc-git-annotate-time ()\n   (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)\n-- \n1.5.0\n"}]}