From 7546c767759585cc4117448b60b6bb2ff85fda59 Mon Sep 17 00:00:00 2001 From: Dan Nicolaescu Date: Tue, 24 Jul 2007 13:15:04 +0000 Subject: vc-git.el (vc-git-checkout, vc-directory-exclusion-list): Fix typos. --- lisp/vc-git.el | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'lisp/vc-git.el') diff --git a/lisp/vc-git.el b/lisp/vc-git.el index de6be9af733..39c86f672fb 100644 --- a/lisp/vc-git.el +++ b/lisp/vc-git.el @@ -44,6 +44,7 @@ ;; Implement the rest of the vc interface. See the comment at the ;; beginning of vc.el. The current status is: +;; ("??" means: "figure out what to do about it") ;; ;; FUNCTION NAME STATUS ;; BACKEND PROPERTIES @@ -56,7 +57,7 @@ ;; * workfile-version (file) OK ;; - latest-on-branch-p (file) ?? ;; * checkout-model (file) OK -;; - workfile-unchanged-p (file) MAYBE CAN BE SIMPLIFIED +;; - workfile-unchanged-p (file) OK ;; - mode-line-string (file) NOT NEEDED ;; - dired-state-info (file) OK ;; STATE-CHANGING FUNCTIONS @@ -97,8 +98,8 @@ ;; MISCELLANEOUS ;; - make-version-backups-p (file) ?? ;; - repository-hostname (dirname) ?? -;; - previous-version (file rev) ?? -;; - next-version (file rev) ?? +;; - previous-version (file rev) OK +;; - next-version (file rev) OK ;; - check-headers () ?? ;; - clear-headers () ?? ;; - delete-file (file) OK @@ -115,7 +116,7 @@ ;; should be moved to vc-hooks.el (add-to-list 'vc-handled-backends 'GIT) (eval-after-load "vc" - '(add-to-list 'vc-directory-exclusion-list ".bzr" t)) + '(add-to-list 'vc-directory-exclusion-list ".git" t)) ;;; BACKEND PROPERTIES @@ -251,7 +252,7 @@ (concat (if rev rev "HEAD") ":" fullname) "cat-file" "blob"))) (defun vc-git-checkout (file &optional editable rev) - (vc-git-command nil0 file "checkout" (or rev "HEAD"))) + (vc-git-command nil 0 file "checkout" (or rev "HEAD"))) (defun vc-git-revert (file &optional contents-done) "Revert FILE to the version stored in the git repository." -- cgit v1.2.3 From 64e3efd9bced55ceede61a6536f8b33b7be69bd5 Mon Sep 17 00:00:00 2001 From: Dan Nicolaescu Date: Tue, 24 Jul 2007 22:21:46 +0000 Subject: vc-git.el (vc-git-print-log): Fix previous change. --- lisp/ChangeLog | 4 ++++ lisp/vc-git.el | 28 +++++++++++++--------------- 2 files changed, 17 insertions(+), 15 deletions(-) (limited to 'lisp/vc-git.el') diff --git a/lisp/ChangeLog b/lisp/ChangeLog index c4c089d476a..405b5a50dbf 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,7 @@ +2007-07-24 Dan Nicolaescu + + * vc-git.el (vc-git-print-log): Fix previous change. + 2007-07-24 Stefan Monnier * window.el (save-selected-window): Minor optimization. diff --git a/lisp/vc-git.el b/lisp/vc-git.el index 39c86f672fb..43cddbc3cf2 100644 --- a/lisp/vc-git.el +++ b/lisp/vc-git.el @@ -264,27 +264,25 @@ (defun vc-git-print-log (files &optional buffer) "Get change log associated with FILES." - (let ((name (file-relative-name file)) - (coding-system-for-read git-commits-coding-system)) - ;; `log-view-mode' needs to have the file name in order to function - ;; correctly. "git log" does not print it, so we insert it here by - ;; hand. - + (let ((coding-system-for-read git-commits-coding-system)) ;; `vc-do-command' creates the buffer, but we need it before running ;; the command. (vc-setup-buffer buffer) ;; If the buffer exists from a previous invocation it might be ;; read-only. (let ((inhibit-read-only t)) - ;; XXX Here loop and call "git rev-list" on each file separately - ;; to make sure that each file gets a "File:" header before the - ;; corresponding log. Maybe there is a way to do this with one - ;; command... - (dolist (file files) - (with-current-buffer - buffer - (insert "File: " (file-name-nondirectory file) "\n"))) - (vc-git-command buffer 'async name "rev-list" "--pretty" "HEAD" "--")))) + ;; XXX `log-view-mode' needs to have something to identify where + ;; the log for each individual file starts. It seems that by + ;; default git does not output this info. So loop here and call + ;; "git rev-list" on each file separately to make sure that each + ;; file gets a "File:" header before the corresponding + ;; log. Maybe there is a way to do this with one command... + (dolist (file files) + (with-current-buffer + buffer + (insert "File: " (file-name-nondirectory file) "\n")) + (vc-git-command buffer 'async (file-relative-name file) + "rev-list" "--pretty" "HEAD" "--"))))) (defvar log-view-message-re) (defvar log-view-file-re) -- cgit v1.2.3 From b747d346a22726e41ade73a477973732ccb7be30 Mon Sep 17 00:00:00 2001 From: Dan Nicolaescu Date: Wed, 25 Jul 2007 15:03:05 +0000 Subject: * vc-git.el (vc-git-log-view-mode): Port to the multi-file vc interface. (vc-git-create-snapshot, vc-git-retrieve-snapshot): New functions. --- lisp/ChangeLog | 5 +++++ lisp/vc-git.el | 43 +++++++++++++++++++++++++++++-------------- 2 files changed, 34 insertions(+), 14 deletions(-) (limited to 'lisp/vc-git.el') diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 9b4f3d4b8af..eaabf87af3e 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2007-07-25 Alexandre Julliard + + * vc-git.el (vc-git-log-view-mode): Port to the multi-file vc interface. + (vc-git-create-snapshot, vc-git-retrieve-snapshot): New functions. + 2007-07-25 Vinicius Jose Latorre * ps-print.el (ps-multibyte-buffer): Docstring fix. diff --git a/lisp/vc-git.el b/lisp/vc-git.el index 43cddbc3cf2..f48fb201bbe 100644 --- a/lisp/vc-git.el +++ b/lisp/vc-git.el @@ -40,7 +40,6 @@ ;; - check if more functions could use vc-git-command instead ;; of start-process. ;; - changelog generation -;; - working with revisions other than HEAD ;; Implement the rest of the vc interface. See the comment at the ;; beginning of vc.el. The current status is: @@ -73,8 +72,11 @@ ;; * checkout (file &optional editable rev) OK ;; * revert (file &optional contents-done) OK ;; - rollback (files) ?? PROBABLY NOT NEEDED -;; - merge (file rev1 rev2) NEEDED -;; - merge-news (file) NEEDED +;; - merge (file rev1 rev2) It would be possible to merge changes into +;; a single file, but when committing they +;; wouldn't be identified as a merge by git, +;; so it's probably not a good idea. +;; - merge-news (file) see `merge' ;; - steal-lock (file &optional version) NOT NEEDED ;; HISTORY FUNCTIONS ;; * print-log (files &optional buffer) OK @@ -84,7 +86,7 @@ ;; - logentry-check () ?? ;; - comment-history (file) ?? ;; - update-changelog (files) ?? -;; * diff (file &optional rev1 rev2 buffer) PORT TO NEW VC INTERFACE +;; * diff (file &optional rev1 rev2 buffer) OK ;; - revision-completion-table (file) NEEDED? ;; - diff-tree (dir &optional rev1 rev2) OK ;; - annotate-command (file buf &optional rev) OK @@ -92,9 +94,9 @@ ;; - annotate-current-time () ?? NOT NEEDED ;; - annotate-extract-revision-at-line () OK ;; SNAPSHOT SYSTEM -;; - create-snapshot (dir name branchp) NEEDED +;; - create-snapshot (dir name branchp) OK ;; - assign-name (file name) NOT NEEDED -;; - retrieve-snapshot (dir name update) NEEDED +;; - retrieve-snapshot (dir name update) OK, needs to handle the `name' arg ;; MISCELLANEOUS ;; - make-version-backups-p (file) ?? ;; - repository-hostname (dirname) ?? @@ -310,14 +312,11 @@ ("^Date: \\(.+\\)" (1 'change-log-date)) ("^summary:[ \t]+\\(.+\\)" (1 'log-view-message)))))) -(defun vc-git-diff (file &optional rev1 rev2 buffer) - (let ((name (file-relative-name file)) - (buf (or buffer "*vc-diff*"))) +(defun vc-git-diff (files &optional rev1 rev2 buffer) + (let ((buf (or buffer "*vc-diff*"))) (if (and rev1 rev2) - (vc-git-command buf 0 name "diff-tree" "-p" rev1 rev2 "--") - (vc-git-command buf 0 name "diff-index" "-p" (or rev1 "HEAD") "--")) - ;; git-diff-index doesn't set exit status like diff does - (if (vc-git-workfile-unchanged-p file) 0 1))) + (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") "--")))) (defun vc-git-diff-tree (dir &optional rev1 rev2) (vc-git-diff dir rev1 rev2)) @@ -338,6 +337,22 @@ (and (looking-at "[0-9a-f]+") (buffer-substring-no-properties (match-beginning 0) (match-end 0))))) +;;; SNAPSHOT SYSTEM + +(defun vc-git-create-snapshot (dir name branchp) + (let ((default-directory dir)) + (and (vc-git-command nil 0 nil "update-index" "--refresh") + (if branchp + (vc-git-command nil 0 nil "checkout" "-b" name) + (vc-git-command nil 0 nil "tag" name))))) + +(defun vc-git-retrieve-snapshot (dir name update) + (let ((default-directory dir)) + (vc-git-command nil 0 nil "checkout" name) + ;; FIXME: update buffers if `update' is true + )) + + ;;; MISCELLANEOUS (defun vc-git-previous-version (file rev) @@ -397,7 +412,7 @@ (vc-git-command nil 0 (list old new) "mv" "-f" "--")) -;; Internal commands +;;; Internal commands (defun vc-git-root (file) (vc-find-root file ".git")) -- cgit v1.2.3 From 40ed3f4f565af3b4aa375dc3a654fe7506690d40 Mon Sep 17 00:00:00 2001 From: Dan Nicolaescu Date: Wed, 25 Jul 2007 15:08:09 +0000 Subject: Fix comment. --- lisp/vc-git.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lisp/vc-git.el') diff --git a/lisp/vc-git.el b/lisp/vc-git.el index f48fb201bbe..5dcdab94f47 100644 --- a/lisp/vc-git.el +++ b/lisp/vc-git.el @@ -96,7 +96,7 @@ ;; SNAPSHOT SYSTEM ;; - create-snapshot (dir name branchp) OK ;; - assign-name (file name) NOT NEEDED -;; - retrieve-snapshot (dir name update) OK, needs to handle the `name' arg +;; - retrieve-snapshot (dir name update) OK, needs to update buffers ;; MISCELLANEOUS ;; - make-version-backups-p (file) ?? ;; - repository-hostname (dirname) ?? -- cgit v1.2.3 From 108607bc25dcb8d4aac102661e18ca4c19d418c4 Mon Sep 17 00:00:00 2001 From: Dan Nicolaescu Date: Thu, 26 Jul 2007 17:26:08 +0000 Subject: vc-git.el (vc-git-revision-table) (vc-git-revision-completion-table): New functions. --- lisp/ChangeLog | 5 +++++ lisp/vc-git.el | 68 ++++++++++++++++++++++++++++++++++++---------------------- 2 files changed, 47 insertions(+), 26 deletions(-) (limited to 'lisp/vc-git.el') diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 65239278624..ad836f8ef03 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2007-07-26 Alexandre Julliard + + * vc-git.el (vc-git-revision-table) + (vc-git-revision-completion-table): New functions. + 2007-07-26 Vinicius Jose Latorre * progmodes/ebnf-abn.el (ebnf-abn-skip-comment): diff --git a/lisp/vc-git.el b/lisp/vc-git.el index 5dcdab94f47..619199fc287 100644 --- a/lisp/vc-git.el +++ b/lisp/vc-git.el @@ -51,10 +51,10 @@ ;; STATE-QUERYING FUNCTIONS ;; * registered (file) OK ;; * state (file) OK -;; - state-heuristic (file) ?? PROBABLY NOT NEEDED +;; - state-heuristic (file) NOT NEEDED ;; - dir-state (dir) OK ;; * workfile-version (file) OK -;; - latest-on-branch-p (file) ?? +;; - latest-on-branch-p (file) NOT NEEDED ;; * checkout-model (file) OK ;; - workfile-unchanged-p (file) OK ;; - mode-line-string (file) NOT NEEDED @@ -62,19 +62,19 @@ ;; STATE-CHANGING FUNCTIONS ;; * create-repo () OK ;; * register (files &optional rev comment) OK -;; - init-version (file) ?? +;; - init-version (file) NOT NEEDED ;; - responsible-p (file) OK -;; - could-register (file) NEEDED -;; - receive-file (file rev) ?? +;; - could-register (file) NOT NEEDED, DEFAULT IS GOOD +;; - receive-file (file rev) NOT NEEDED ;; - unregister (file) OK ;; * checkin (files rev comment) OK ;; * find-version (file rev buffer) OK ;; * checkout (file &optional editable rev) OK ;; * revert (file &optional contents-done) OK -;; - rollback (files) ?? PROBABLY NOT NEEDED -;; - merge (file rev1 rev2) It would be possible to merge changes into -;; a single file, but when committing they -;; wouldn't be identified as a merge by git, +;; - rollback (files) COULD BE SUPPORTED +;; - merge (file rev1 rev2) It would be possible to merge changes into +;; a single file, but when committing they +;; wouldn't be identified as a merge by git, ;; so it's probably not a good idea. ;; - merge-news (file) see `merge' ;; - steal-lock (file &optional version) NOT NEEDED @@ -82,32 +82,32 @@ ;; * print-log (files &optional buffer) OK ;; - log-view-mode () OK ;; - show-log-entry (version) NOT NEEDED, DEFAULT IS GOOD -;; - wash-log (file) ?? -;; - logentry-check () ?? +;; - wash-log (file) COULD BE SUPPORTED +;; - logentry-check () NOT NEEDED ;; - comment-history (file) ?? -;; - update-changelog (files) ?? +;; - update-changelog (files) COULD BE SUPPORTED ;; * diff (file &optional rev1 rev2 buffer) OK ;; - revision-completion-table (file) NEEDED? ;; - diff-tree (dir &optional rev1 rev2) OK ;; - annotate-command (file buf &optional rev) OK ;; - annotate-time () OK -;; - annotate-current-time () ?? NOT NEEDED +;; - annotate-current-time () NOT NEEDED ;; - annotate-extract-revision-at-line () OK ;; SNAPSHOT SYSTEM ;; - create-snapshot (dir name branchp) OK ;; - assign-name (file name) NOT NEEDED ;; - retrieve-snapshot (dir name update) OK, needs to update buffers ;; MISCELLANEOUS -;; - make-version-backups-p (file) ?? -;; - repository-hostname (dirname) ?? +;; - make-version-backups-p (file) NOT NEEDED +;; - repository-hostname (dirname) NOT NEEDED ;; - previous-version (file rev) OK ;; - next-version (file rev) OK -;; - check-headers () ?? -;; - clear-headers () ?? +;; - check-headers () COULD BE SUPPORTED +;; - clear-headers () NOT NEEDED ;; - delete-file (file) OK ;; - rename-file (old new) OK -;; - find-file-hook () PROBABLY NOT NEEDED -;; - find-file-not-found-hook () PROBABLY NOT NEEDED +;; - find-file-hook () NOT NEEDED +;; - find-file-not-found-hook () NOT NEEDED (eval-when-compile (require 'cl) (require 'vc)) @@ -146,7 +146,7 @@ (let ((str (buffer-string))) (and (> (length str) (length name)) (string= (substring str 0 (1+ (length name))) (concat name "\0"))))))))) - + (defun vc-git-state (file) "Git-specific version of `vc-state'." (let ((diff (vc-git--run-command-string file "diff-index" "-z" "HEAD" "--"))) @@ -200,7 +200,7 @@ ;; stat info, so if the file has been modified it will always show ;; up as modified in vc-git-state, even if the change has been ;; undone, until git-update-index --refresh is run. - + ;; OTOH the vc-git-workfile-unchanged-p implementation checks the ;; actual content, so it will detect the case of a file reverted ;; back to its original state. @@ -236,7 +236,7 @@ (defun vc-git-unregister (file) (vc-git-command nil 0 file "rm" "-f" "--cached" "--")) - + (defun vc-git-checkin (files rev comment) (let ((coding-system-for-write git-commits-coding-system)) @@ -246,11 +246,11 @@ (let ((coding-system-for-read 'binary) (coding-system-for-write 'binary) (fullname (substring - (vc-git--run-command-string + (vc-git--run-command-string file "ls-files" "-z" "--full-name" "--") 0 -1))) - (vc-git-command - buffer 0 + (vc-git-command + buffer 0 (concat (if rev rev "HEAD") ":" fullname) "cat-file" "blob"))) (defun vc-git-checkout (file &optional editable rev) @@ -283,7 +283,7 @@ (with-current-buffer buffer (insert "File: " (file-name-nondirectory file) "\n")) - (vc-git-command buffer 'async (file-relative-name file) + (vc-git-command buffer 'async (file-relative-name file) "rev-list" "--pretty" "HEAD" "--"))))) (defvar log-view-message-re) @@ -318,6 +318,22 @@ (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") "--")))) +(defun vc-git-revision-table (file) + (let ((table (list "HEAD"))) + (with-temp-buffer + (vc-git-command t nil nil "for-each-ref" "--format=%(refname)") + (goto-char (point-min)) + (while (re-search-forward "^refs/\\(heads\\|tags\\)/\\(.*\\)$" nil t) + (push (match-string 2) table))) + table)) + +(defun vc-git-revision-completion-table (file) + (lexical-let ((file file) + table) + (setq table (lazy-completion-table + table (lambda () (vc-git-revision-table file)))) + table)) + (defun vc-git-diff-tree (dir &optional rev1 rev2) (vc-git-diff dir rev1 rev2)) -- cgit v1.2.3 From 625f71cff9f69fb0ca47aedbb69111f22186e628 Mon Sep 17 00:00:00 2001 From: Dan Nicolaescu Date: Thu, 26 Jul 2007 18:44:39 +0000 Subject: * vc-git.el: Relicense to GPLv3 or later. (vc-directory-exclusion-list, vc-handled-backends): Remove. * vc-hooks.el (vc-handled-backends): Add GIT. * vc.el (vc-directory-exclusion-list): Add .git. * vc2-xtra.texi (Customizing VC): Add GIT. --- etc/NEWS | 2 ++ lisp/ChangeLog | 9 +++++++++ lisp/vc-git.el | 8 +------- lisp/vc-hooks.el | 6 +++--- lisp/vc.el | 2 +- man/ChangeLog | 2 ++ man/vc2-xtra.texi | 2 +- 7 files changed, 19 insertions(+), 12 deletions(-) (limited to 'lisp/vc-git.el') diff --git a/etc/NEWS b/etc/NEWS index 4ec011c07c3..21194e24a2f 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -100,6 +100,8 @@ considered for update. *** VC has some support for Mercurial (hg). +*** VC has some support for Git. + ** sgml-electric-tag-pair-mode lets you simultaneously edit matched tag pairs. ** BibTeX mode: diff --git a/lisp/ChangeLog b/lisp/ChangeLog index ad836f8ef03..616dfd16859 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,12 @@ +2007-07-26 Dan Nicolaescu + + * vc-git.el: Relicense to GPLv3 or later. + (vc-directory-exclusion-list, vc-handled-backends): Remove. + + * vc-hooks.el (vc-handled-backends): Add GIT. + + * vc.el (vc-directory-exclusion-list): Add .git. + 2007-07-26 Alexandre Julliard * vc-git.el (vc-git-revision-table) diff --git a/lisp/vc-git.el b/lisp/vc-git.el index 619199fc287..7e358ed0238 100644 --- a/lisp/vc-git.el +++ b/lisp/vc-git.el @@ -9,7 +9,7 @@ ;; GNU Emacs is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 2, or (at your option) +;; the Free Software Foundation; either version 3, or (at your option) ;; any later version. ;; GNU Emacs is distributed in the hope that it will be useful, @@ -114,12 +114,6 @@ (defvar git-commits-coding-system 'utf-8 "Default coding system for git commits.") -;; XXX when this backend is considered sufficiently reliable this -;; should be moved to vc-hooks.el -(add-to-list 'vc-handled-backends 'GIT) -(eval-after-load "vc" - '(add-to-list 'vc-directory-exclusion-list ".git" t)) - ;;; BACKEND PROPERTIES (defun vc-git-revision-granularity () diff --git a/lisp/vc-hooks.el b/lisp/vc-hooks.el index 15238751679..a8b6297caa2 100644 --- a/lisp/vc-hooks.el +++ b/lisp/vc-hooks.el @@ -62,9 +62,9 @@ interpreted as hostnames." :type 'regexp :group 'vc) -(defcustom vc-handled-backends '(RCS CVS SVN SCCS BZR HG Arch MCVS) - ;; BZR, HG, Arch and MCVS come last because they are per-tree rather - ;; than per-dir. +(defcustom vc-handled-backends '(RCS CVS SVN SCCS BZR GIT HG Arch MCVS) + ;; BZR, GIT, HG, Arch and MCVS come last because they are per-tree + ;; rather than per-dir. "List of version control backends for which VC will be used. Entries in this list will be tried in order to determine whether a file is under that sort of version control. diff --git a/lisp/vc.el b/lisp/vc.el index 47d231eb2c7..08baa16e6b4 100644 --- a/lisp/vc.el +++ b/lisp/vc.el @@ -587,7 +587,7 @@ These are passed to the checkin program by \\[vc-register]." :version "20.3") (defcustom vc-directory-exclusion-list '("SCCS" "RCS" "CVS" "MCVS" ".svn" - ".hg" ".bzr" "{arch}") + ".git" ".hg" ".bzr" "{arch}") "List of directory names to be ignored when walking directory trees." :type '(repeat string) :group 'vc) diff --git a/man/ChangeLog b/man/ChangeLog index c393eb02589..08ba464789a 100644 --- a/man/ChangeLog +++ b/man/ChangeLog @@ -1,5 +1,7 @@ 2007-07-26 Dan Nicolaescu + * vc2-xtra.texi (Customizing VC): Add GIT. + * dired.texi (Wdired): Mention C-x C-q key binding. 2007-07-25 Glenn Morris diff --git a/man/vc2-xtra.texi b/man/vc2-xtra.texi index 7627787d1d2..83f28088726 100644 --- a/man/vc2-xtra.texi +++ b/man/vc2-xtra.texi @@ -590,7 +590,7 @@ headers. @vindex vc-handled-backends The variable @code{vc-handled-backends} determines which version control systems VC should handle. The default value is @code{(RCS CVS -SVN SCCS BZR HG Arch MCVS)}, so it contains all the version systems +SVN SCCS BZR GIT HG Arch MCVS)}, so it contains all the version systems that are currently supported. If you want VC to ignore one or more of these systems, exclude its name from the list. To disable VC entirely, set this variable to @code{nil}. -- cgit v1.2.3