annotate lisp/vc-git.el @ 82228:3ee0156fc6da

*** empty log message ***
author Glenn Morris <rgm@gnu.org>
date Wed, 01 Aug 2007 06:25:04 +0000
parents a324837355ec
children 36893fdf92ab
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1 ;;; vc-git.el --- VC backend for the git version control system
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3 ;; Copyright (C) 2006, 2007 Free Software Foundation, Inc.
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4
82066
f599171df164 (vc-git-delete-file, vc-git-rename-file): New functions.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82054
diff changeset
5 ;; Author: Alexandre Julliard <julliard@winehq.org>
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6 ;; Keywords: tools
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
82145
f04985ac29f2 * vc-git.el: Relicense to GPLv3 or later.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82144
diff changeset
12 ;; the Free Software Foundation; either version 3, or (at your option)
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
13 ;; any later version.
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
14
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
18 ;; GNU General Public License for more details.
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
19
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
22 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
23 ;; Boston, MA 02110-1301, USA.
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
24
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
25 ;;; Commentary:
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
26
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
27 ;; This file contains a VC backend for the git version control
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
28 ;; system.
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
29 ;;
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
30
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
31 ;;; Installation:
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
32
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
33 ;; To install: put this file on the load-path and add GIT to the list
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
34 ;; of supported backends in `vc-handled-backends'; the following line,
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
35 ;; placed in your ~/.emacs, will accomplish this:
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
36 ;;
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
37 ;; (add-to-list 'vc-handled-backends 'GIT)
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
38
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
39 ;;; Todo:
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
40 ;; - check if more functions could use vc-git-command instead
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
41 ;; of start-process.
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
42 ;; - changelog generation
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
43
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
44 ;; Implement the rest of the vc interface. See the comment at the
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
45 ;; beginning of vc.el. The current status is:
82091
535e5fa4eca9 vc-git.el (vc-git-checkout, vc-directory-exclusion-list): Fix
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82068
diff changeset
46 ;; ("??" means: "figure out what to do about it")
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
47 ;;
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
48 ;; FUNCTION NAME STATUS
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
49 ;; BACKEND PROPERTIES
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
50 ;; * revision-granularity OK
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
51 ;; STATE-QUERYING FUNCTIONS
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
52 ;; * registered (file) OK
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
53 ;; * state (file) OK
82144
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
54 ;; - state-heuristic (file) NOT NEEDED
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
55 ;; - dir-state (dir) OK
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
56 ;; * workfile-version (file) OK
82144
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
57 ;; - latest-on-branch-p (file) NOT NEEDED
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
58 ;; * checkout-model (file) OK
82091
535e5fa4eca9 vc-git.el (vc-git-checkout, vc-directory-exclusion-list): Fix
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82068
diff changeset
59 ;; - workfile-unchanged-p (file) OK
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
60 ;; - mode-line-string (file) NOT NEEDED
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
61 ;; - dired-state-info (file) OK
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
62 ;; STATE-CHANGING FUNCTIONS
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
63 ;; * create-repo () OK
82047
7df018ac279e Update status.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82038
diff changeset
64 ;; * register (files &optional rev comment) OK
82144
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
65 ;; - init-version (file) NOT NEEDED
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
66 ;; - responsible-p (file) OK
82144
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
67 ;; - could-register (file) NOT NEEDED, DEFAULT IS GOOD
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
68 ;; - receive-file (file rev) NOT NEEDED
82068
cbb38ceb3177 (vc-git-unregister): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82066
diff changeset
69 ;; - unregister (file) OK
82047
7df018ac279e Update status.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82038
diff changeset
70 ;; * checkin (files rev comment) OK
82053
3cc1f1f9df04 (vc-git-checkin): Delete unused parameter and the code
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82052
diff changeset
71 ;; * find-version (file rev buffer) OK
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
72 ;; * checkout (file &optional editable rev) OK
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
73 ;; * revert (file &optional contents-done) OK
82144
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
74 ;; - rollback (files) COULD BE SUPPORTED
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
75 ;; - merge (file rev1 rev2) It would be possible to merge changes into
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
76 ;; a single file, but when committing they
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
77 ;; wouldn't be identified as a merge by git,
82109
12d79fae7504 * vc-git.el (vc-git-log-view-mode): Port to the multi-file vc interface.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82098
diff changeset
78 ;; so it's probably not a good idea.
12d79fae7504 * vc-git.el (vc-git-log-view-mode): Port to the multi-file vc interface.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82098
diff changeset
79 ;; - merge-news (file) see `merge'
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
80 ;; - steal-lock (file &optional version) NOT NEEDED
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
81 ;; HISTORY FUNCTIONS
82047
7df018ac279e Update status.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82038
diff changeset
82 ;; * print-log (files &optional buffer) OK
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
83 ;; - log-view-mode () OK
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
84 ;; - show-log-entry (version) NOT NEEDED, DEFAULT IS GOOD
82144
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
85 ;; - wash-log (file) COULD BE SUPPORTED
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
86 ;; - logentry-check () NOT NEEDED
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
87 ;; - comment-history (file) ??
82144
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
88 ;; - update-changelog (files) COULD BE SUPPORTED
82109
12d79fae7504 * vc-git.el (vc-git-log-view-mode): Port to the multi-file vc interface.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82098
diff changeset
89 ;; * diff (file &optional rev1 rev2 buffer) OK
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
90 ;; - revision-completion-table (file) NEEDED?
82053
3cc1f1f9df04 (vc-git-checkin): Delete unused parameter and the code
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82052
diff changeset
91 ;; - diff-tree (dir &optional rev1 rev2) OK
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
92 ;; - annotate-command (file buf &optional rev) OK
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
93 ;; - annotate-time () OK
82144
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
94 ;; - annotate-current-time () NOT NEEDED
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
95 ;; - annotate-extract-revision-at-line () OK
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
96 ;; SNAPSHOT SYSTEM
82109
12d79fae7504 * vc-git.el (vc-git-log-view-mode): Port to the multi-file vc interface.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82098
diff changeset
97 ;; - create-snapshot (dir name branchp) OK
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
98 ;; - assign-name (file name) NOT NEEDED
82110
b9d2156e3f5d Fix comment.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82109
diff changeset
99 ;; - retrieve-snapshot (dir name update) OK, needs to update buffers
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
100 ;; MISCELLANEOUS
82144
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
101 ;; - make-version-backups-p (file) NOT NEEDED
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
102 ;; - repository-hostname (dirname) NOT NEEDED
82091
535e5fa4eca9 vc-git.el (vc-git-checkout, vc-directory-exclusion-list): Fix
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82068
diff changeset
103 ;; - previous-version (file rev) OK
535e5fa4eca9 vc-git.el (vc-git-checkout, vc-directory-exclusion-list): Fix
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82068
diff changeset
104 ;; - next-version (file rev) OK
82144
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
105 ;; - check-headers () COULD BE SUPPORTED
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
106 ;; - clear-headers () NOT NEEDED
82066
f599171df164 (vc-git-delete-file, vc-git-rename-file): New functions.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82054
diff changeset
107 ;; - delete-file (file) OK
f599171df164 (vc-git-delete-file, vc-git-rename-file): New functions.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82054
diff changeset
108 ;; - rename-file (old new) OK
82144
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
109 ;; - find-file-hook () NOT NEEDED
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
110 ;; - find-file-not-found-hook () NOT NEEDED
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
111
82053
3cc1f1f9df04 (vc-git-checkin): Delete unused parameter and the code
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82052
diff changeset
112 (eval-when-compile (require 'cl) (require 'vc))
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
113
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
114 (defvar git-commits-coding-system 'utf-8
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
115 "Default coding system for git commits.")
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
116
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
117 ;;; BACKEND PROPERTIES
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
118
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
119 (defun vc-git-revision-granularity ()
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
120 'repository)
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
121
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
122 ;;; STATE-QUERYING FUNCTIONS
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
123
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
124 ;;;###autoload (defun vc-git-registered (file)
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
125 ;;;###autoload "Return non-nil if FILE is registered with git."
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
126 ;;;###autoload (if (vc-find-root file ".git") ; short cut
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
127 ;;;###autoload (progn
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
128 ;;;###autoload (load "vc-git")
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
129 ;;;###autoload (vc-git-registered file))))
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
130
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
131 (defun vc-git-registered (file)
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
132 "Check whether FILE is registered with git."
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
133 (when (vc-git-root file)
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
134 (with-temp-buffer
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
135 (let* ((dir (file-name-directory file))
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
136 (name (file-relative-name file dir)))
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
137 (and (ignore-errors
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
138 (when dir (cd dir))
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
139 (eq 0 (call-process "git" nil '(t nil) nil "ls-files" "-c" "-z" "--" name)))
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
140 (let ((str (buffer-string)))
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
141 (and (> (length str) (length name))
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
142 (string= (substring str 0 (1+ (length name))) (concat name "\0")))))))))
82144
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
143
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
144 (defun vc-git-state (file)
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
145 "Git-specific version of `vc-state'."
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
146 (let ((diff (vc-git--run-command-string file "diff-index" "-z" "HEAD" "--")))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
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))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
148 'edited
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
149 'up-to-date)))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
150
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
151 (defun vc-git-dir-state (dir)
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
152 (with-temp-buffer
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
153 (vc-git-command (current-buffer) nil nil "ls-files" "-t")
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
154 (goto-char (point-min))
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
155 (let ((status-char nil)
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
156 (file nil))
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
157 (while (not (eobp))
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
158 (setq status-char (char-after))
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
159 (setq file
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
160 (expand-file-name
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
161 (buffer-substring-no-properties (+ (point) 2) (line-end-position))))
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
162 (cond
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
163 ;; The rest of the possible states in "git ls-files -t" output:
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
164 ;; R removed/deleted
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
165 ;; K to be killed
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
166 ;; should not show up in vc-dired, so don't deal with them
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
167 ;; here.
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
168 ((eq status-char ?H)
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
169 (vc-file-setprop file 'vc-state 'up-to-date))
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
170 ((eq status-char ?M)
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
171 (vc-file-setprop file 'vc-state 'edited))
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
172 ((eq status-char ?C)
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
173 (vc-file-setprop file 'vc-state 'edited))
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
174 ((eq status-char ??)
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
175 (vc-file-setprop file 'vc-backend 'none)
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
176 (vc-file-setprop file 'vc-state 'nil)))
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
177 (forward-line)))))
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
178
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
179 (defun vc-git-workfile-version (file)
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
180 "Git-specific version of `vc-workfile-version'."
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
181 (let ((str (with-output-to-string
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
182 (with-current-buffer standard-output
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
183 (call-process "git" nil '(t nil) nil "symbolic-ref" "HEAD")))))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
184 (if (string-match "^\\(refs/heads/\\)?\\(.+\\)$" str)
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
185 (match-string 2 str)
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
186 str)))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
187
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
188 (defun vc-git-checkout-model (file)
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
189 'implicit)
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
190
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
191 (defun vc-git-workfile-unchanged-p (file)
82052
1776413f26d4 (vc-git-workfile-unchanged-p): Update comment.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82050
diff changeset
192 ;; The reason this does not use the result of vc-git-state is that
1776413f26d4 (vc-git-workfile-unchanged-p): Update comment.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82050
diff changeset
193 ;; git-diff-index (used by vc-git-state) doesn't refresh the cached
1776413f26d4 (vc-git-workfile-unchanged-p): Update comment.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82050
diff changeset
194 ;; stat info, so if the file has been modified it will always show
1776413f26d4 (vc-git-workfile-unchanged-p): Update comment.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82050
diff changeset
195 ;; up as modified in vc-git-state, even if the change has been
1776413f26d4 (vc-git-workfile-unchanged-p): Update comment.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82050
diff changeset
196 ;; undone, until git-update-index --refresh is run.
82144
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
197
82052
1776413f26d4 (vc-git-workfile-unchanged-p): Update comment.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82050
diff changeset
198 ;; OTOH the vc-git-workfile-unchanged-p implementation checks the
1776413f26d4 (vc-git-workfile-unchanged-p): Update comment.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82050
diff changeset
199 ;; actual content, so it will detect the case of a file reverted
1776413f26d4 (vc-git-workfile-unchanged-p): Update comment.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82050
diff changeset
200 ;; back to its original state.
1776413f26d4 (vc-git-workfile-unchanged-p): Update comment.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82050
diff changeset
201
1776413f26d4 (vc-git-workfile-unchanged-p): Update comment.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82050
diff changeset
202 ;; The ideal implementation would be to refresh the stat cache and
1776413f26d4 (vc-git-workfile-unchanged-p): Update comment.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82050
diff changeset
203 ;; then call vc-git-state, but at the moment there's no git command
1776413f26d4 (vc-git-workfile-unchanged-p): Update comment.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82050
diff changeset
204 ;; to refresh a single file, so this will have to be added first.
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
205 (let ((sha1 (vc-git--run-command-string file "hash-object" "--"))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
206 (head (vc-git--run-command-string file "ls-tree" "-z" "HEAD" "--")))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
207 (and head
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
208 (string-match "[0-7]\\{6\\} blob \\([0-9a-f]\\{40\\}\\)\t[^\0]+\0" head)
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
209 (string= (car (split-string sha1 "\n")) (match-string 1 head)))))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
210
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
211 (defun vc-git-dired-state-info (file)
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
212 "Git-specific version of `vc-dired-state-info'."
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
213 (let ((git-state (vc-state file)))
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
214 (if (eq git-state 'edited)
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
215 "(modified)"
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
216 ;; fall back to the default VC representation
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
217 (vc-default-dired-state-info 'GIT file))))
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
218
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
219 ;;; STATE-CHANGING FUNCTIONS
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
220
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
221 (defun vc-git-create-repo ()
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
222 "Create a new GIT repository."
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
223 (vc-git-command "init" nil 0 nil))
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
224
82038
7ee8cfeeb2b8 (vc-git-register, vc-git-checkin): Use vc-git-command,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82032
diff changeset
225 (defun vc-git-register (files &optional rev comment)
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
226 "Register FILE into the git version-control system."
82038
7ee8cfeeb2b8 (vc-git-register, vc-git-checkin): Use vc-git-command,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82032
diff changeset
227 (vc-git-command nil 0 files "update-index" "--add" "--"))
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
228
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
229 (defalias 'vc-git-responsible-p 'vc-git-root)
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
230
82068
cbb38ceb3177 (vc-git-unregister): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82066
diff changeset
231 (defun vc-git-unregister (file)
cbb38ceb3177 (vc-git-unregister): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82066
diff changeset
232 (vc-git-command nil 0 file "rm" "-f" "--cached" "--"))
82144
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
233
82068
cbb38ceb3177 (vc-git-unregister): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82066
diff changeset
234
82038
7ee8cfeeb2b8 (vc-git-register, vc-git-checkin): Use vc-git-command,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82032
diff changeset
235 (defun vc-git-checkin (files rev comment)
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
236 (let ((coding-system-for-write git-commits-coding-system))
82038
7ee8cfeeb2b8 (vc-git-register, vc-git-checkin): Use vc-git-command,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82032
diff changeset
237 (vc-git-command nil 0 files "commit" "-m" comment "--only" "--")))
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
238
82053
3cc1f1f9df04 (vc-git-checkin): Delete unused parameter and the code
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82052
diff changeset
239 (defun vc-git-find-version (file rev buffer)
3cc1f1f9df04 (vc-git-checkin): Delete unused parameter and the code
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82052
diff changeset
240 (let ((coding-system-for-read 'binary)
82066
f599171df164 (vc-git-delete-file, vc-git-rename-file): New functions.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82054
diff changeset
241 (coding-system-for-write 'binary)
f599171df164 (vc-git-delete-file, vc-git-rename-file): New functions.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82054
diff changeset
242 (fullname (substring
82144
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
243 (vc-git--run-command-string
82066
f599171df164 (vc-git-delete-file, vc-git-rename-file): New functions.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82054
diff changeset
244 file "ls-files" "-z" "--full-name" "--")
f599171df164 (vc-git-delete-file, vc-git-rename-file): New functions.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82054
diff changeset
245 0 -1)))
82144
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
246 (vc-git-command
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
247 buffer 0
82066
f599171df164 (vc-git-delete-file, vc-git-rename-file): New functions.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82054
diff changeset
248 (concat (if rev rev "HEAD") ":" fullname) "cat-file" "blob")))
82053
3cc1f1f9df04 (vc-git-checkin): Delete unused parameter and the code
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82052
diff changeset
249
3cc1f1f9df04 (vc-git-checkin): Delete unused parameter and the code
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82052
diff changeset
250 (defun vc-git-checkout (file &optional editable rev)
82091
535e5fa4eca9 vc-git.el (vc-git-checkout, vc-directory-exclusion-list): Fix
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82068
diff changeset
251 (vc-git-command nil 0 file "checkout" (or rev "HEAD")))
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
252
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
253 (defun vc-git-revert (file &optional contents-done)
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
254 "Revert FILE to the version stored in the git repository."
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
255 (if contents-done
82053
3cc1f1f9df04 (vc-git-checkin): Delete unused parameter and the code
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82052
diff changeset
256 (vc-git-command nil 0 file "update-index" "--")
3cc1f1f9df04 (vc-git-checkin): Delete unused parameter and the code
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82052
diff changeset
257 (vc-git-command nil 0 file "checkout" "HEAD")))
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
258
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
259 ;;; HISTORY FUNCTIONS
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
260
82038
7ee8cfeeb2b8 (vc-git-register, vc-git-checkin): Use vc-git-command,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82032
diff changeset
261 (defun vc-git-print-log (files &optional buffer)
7ee8cfeeb2b8 (vc-git-register, vc-git-checkin): Use vc-git-command,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82032
diff changeset
262 "Get change log associated with FILES."
82183
a324837355ec (vc-git-print-log): Support both the old single file
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82145
diff changeset
263 (let ((coding-system-for-read git-commits-coding-system)
a324837355ec (vc-git-print-log): Support both the old single file
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82145
diff changeset
264 ;; Support both the old print-log interface that passes a
a324837355ec (vc-git-print-log): Support both the old single file
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82145
diff changeset
265 ;; single file, and the new one that passes a file list.
a324837355ec (vc-git-print-log): Support both the old single file
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82145
diff changeset
266 (flist (if (listp files) files (list files))))
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
267 ;; `vc-do-command' creates the buffer, but we need it before running
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
268 ;; the command.
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
269 (vc-setup-buffer buffer)
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
270 ;; If the buffer exists from a previous invocation it might be
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
271 ;; read-only.
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
272 (let ((inhibit-read-only t))
82098
eabeaae7370e vc-git.el (vc-git-print-log): Fix previous change.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82091
diff changeset
273 ;; XXX `log-view-mode' needs to have something to identify where
eabeaae7370e vc-git.el (vc-git-print-log): Fix previous change.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82091
diff changeset
274 ;; the log for each individual file starts. It seems that by
eabeaae7370e vc-git.el (vc-git-print-log): Fix previous change.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82091
diff changeset
275 ;; default git does not output this info. So loop here and call
eabeaae7370e vc-git.el (vc-git-print-log): Fix previous change.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82091
diff changeset
276 ;; "git rev-list" on each file separately to make sure that each
eabeaae7370e vc-git.el (vc-git-print-log): Fix previous change.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82091
diff changeset
277 ;; file gets a "File:" header before the corresponding
eabeaae7370e vc-git.el (vc-git-print-log): Fix previous change.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82091
diff changeset
278 ;; log. Maybe there is a way to do this with one command...
82183
a324837355ec (vc-git-print-log): Support both the old single file
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82145
diff changeset
279 (dolist (file flist)
82098
eabeaae7370e vc-git.el (vc-git-print-log): Fix previous change.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82091
diff changeset
280 (with-current-buffer
eabeaae7370e vc-git.el (vc-git-print-log): Fix previous change.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82091
diff changeset
281 buffer
eabeaae7370e vc-git.el (vc-git-print-log): Fix previous change.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82091
diff changeset
282 (insert "File: " (file-name-nondirectory file) "\n"))
82144
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
283 (vc-git-command buffer 'async (file-relative-name file)
82098
eabeaae7370e vc-git.el (vc-git-print-log): Fix previous change.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82091
diff changeset
284 "rev-list" "--pretty" "HEAD" "--")))))
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
285
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
286 (defvar log-view-message-re)
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
287 (defvar log-view-file-re)
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
288 (defvar log-view-font-lock-keywords)
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
289
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
290 (define-derived-mode vc-git-log-view-mode log-view-mode "GIT-Log-View"
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
291 (require 'add-log) ;; we need the faces add-log
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
292 ;; Don't have file markers, so use impossible regexp.
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
293 (set (make-local-variable 'log-view-file-re) "^File:[ \t]+\\(.+\\)")
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
294 (set (make-local-variable 'log-view-message-re)
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
295 "^commit *\\([0-9a-z]+\\)")
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
296 (set (make-local-variable 'log-view-font-lock-keywords)
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
297 (append
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
298 `((,log-view-message-re (1 'change-log-acknowledgement))
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
299 (,log-view-file-re (1 'change-log-file-face)))
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
300 ;; Handle the case:
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
301 ;; user: foo@bar
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
302 '(("^Author:[ \t]+\\([A-Za-z0-9_.+-]+@[A-Za-z0-9_.-]+\\)"
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
303 (1 'change-log-email))
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
304 ;; Handle the case:
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
305 ;; user: FirstName LastName <foo@bar>
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
306 ("^Author:[ \t]+\\([^<(]+?\\)[ \t]*[(<]\\([A-Za-z0-9_.+-]+@[A-Za-z0-9_.-]+\\)[>)]"
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
307 (1 'change-log-name)
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
308 (2 'change-log-email))
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
309 ("^Date: \\(.+\\)" (1 'change-log-date))
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
310 ("^summary:[ \t]+\\(.+\\)" (1 'log-view-message))))))
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
311
82109
12d79fae7504 * vc-git.el (vc-git-log-view-mode): Port to the multi-file vc interface.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82098
diff changeset
312 (defun vc-git-diff (files &optional rev1 rev2 buffer)
12d79fae7504 * vc-git.el (vc-git-log-view-mode): Port to the multi-file vc interface.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82098
diff changeset
313 (let ((buf (or buffer "*vc-diff*")))
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
314 (if (and rev1 rev2)
82109
12d79fae7504 * vc-git.el (vc-git-log-view-mode): Port to the multi-file vc interface.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82098
diff changeset
315 (vc-git-command buf 1 files "diff-tree" "--exit-code" "-p" rev1 rev2 "--")
12d79fae7504 * vc-git.el (vc-git-log-view-mode): Port to the multi-file vc interface.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82098
diff changeset
316 (vc-git-command buf 1 files "diff-index" "--exit-code" "-p" (or rev1 "HEAD") "--"))))
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
317
82144
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
318 (defun vc-git-revision-table (file)
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
319 (let ((table (list "HEAD")))
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
320 (with-temp-buffer
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
321 (vc-git-command t nil nil "for-each-ref" "--format=%(refname)")
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
322 (goto-char (point-min))
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
323 (while (re-search-forward "^refs/\\(heads\\|tags\\)/\\(.*\\)$" nil t)
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
324 (push (match-string 2) table)))
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
325 table))
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
326
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
327 (defun vc-git-revision-completion-table (file)
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
328 (lexical-let ((file file)
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
329 table)
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
330 (setq table (lazy-completion-table
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
331 table (lambda () (vc-git-revision-table file))))
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
332 table))
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
333
82053
3cc1f1f9df04 (vc-git-checkin): Delete unused parameter and the code
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82052
diff changeset
334 (defun vc-git-diff-tree (dir &optional rev1 rev2)
3cc1f1f9df04 (vc-git-checkin): Delete unused parameter and the code
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82052
diff changeset
335 (vc-git-diff dir rev1 rev2))
3cc1f1f9df04 (vc-git-checkin): Delete unused parameter and the code
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82052
diff changeset
336
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
337 (defun vc-git-annotate-command (file buf &optional rev)
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
338 ;; FIXME: rev is ignored
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
339 (let ((name (file-relative-name file)))
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
340 (vc-git-command buf 0 name "blame" (if rev (concat "-r" rev)))))
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
341
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
342 (defun vc-git-annotate-time ()
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
343 (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)
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
344 (vc-annotate-convert-time
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
345 (apply #'encode-time (mapcar (lambda (match) (string-to-number (match-string match))) '(6 5 4 3 2 1 7))))))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
346
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
347 (defun vc-git-annotate-extract-revision-at-line ()
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
348 (save-excursion
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
349 (move-beginning-of-line 1)
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
350 (and (looking-at "[0-9a-f]+")
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
351 (buffer-substring-no-properties (match-beginning 0) (match-end 0)))))
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
352
82109
12d79fae7504 * vc-git.el (vc-git-log-view-mode): Port to the multi-file vc interface.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82098
diff changeset
353 ;;; SNAPSHOT SYSTEM
12d79fae7504 * vc-git.el (vc-git-log-view-mode): Port to the multi-file vc interface.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82098
diff changeset
354
12d79fae7504 * vc-git.el (vc-git-log-view-mode): Port to the multi-file vc interface.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82098
diff changeset
355 (defun vc-git-create-snapshot (dir name branchp)
12d79fae7504 * vc-git.el (vc-git-log-view-mode): Port to the multi-file vc interface.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82098
diff changeset
356 (let ((default-directory dir))
12d79fae7504 * vc-git.el (vc-git-log-view-mode): Port to the multi-file vc interface.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82098
diff changeset
357 (and (vc-git-command nil 0 nil "update-index" "--refresh")
12d79fae7504 * vc-git.el (vc-git-log-view-mode): Port to the multi-file vc interface.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82098
diff changeset
358 (if branchp
12d79fae7504 * vc-git.el (vc-git-log-view-mode): Port to the multi-file vc interface.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82098
diff changeset
359 (vc-git-command nil 0 nil "checkout" "-b" name)
12d79fae7504 * vc-git.el (vc-git-log-view-mode): Port to the multi-file vc interface.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82098
diff changeset
360 (vc-git-command nil 0 nil "tag" name)))))
12d79fae7504 * vc-git.el (vc-git-log-view-mode): Port to the multi-file vc interface.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82098
diff changeset
361
12d79fae7504 * vc-git.el (vc-git-log-view-mode): Port to the multi-file vc interface.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82098
diff changeset
362 (defun vc-git-retrieve-snapshot (dir name update)
12d79fae7504 * vc-git.el (vc-git-log-view-mode): Port to the multi-file vc interface.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82098
diff changeset
363 (let ((default-directory dir))
12d79fae7504 * vc-git.el (vc-git-log-view-mode): Port to the multi-file vc interface.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82098
diff changeset
364 (vc-git-command nil 0 nil "checkout" name)
12d79fae7504 * vc-git.el (vc-git-log-view-mode): Port to the multi-file vc interface.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82098
diff changeset
365 ;; FIXME: update buffers if `update' is true
12d79fae7504 * vc-git.el (vc-git-log-view-mode): Port to the multi-file vc interface.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82098
diff changeset
366 ))
12d79fae7504 * vc-git.el (vc-git-log-view-mode): Port to the multi-file vc interface.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82098
diff changeset
367
12d79fae7504 * vc-git.el (vc-git-log-view-mode): Port to the multi-file vc interface.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82098
diff changeset
368
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
369 ;;; MISCELLANEOUS
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
370
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
371 (defun vc-git-previous-version (file rev)
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
372 "Git-specific version of `vc-previous-version'."
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
373 (let ((default-directory (file-name-directory (expand-file-name file)))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
374 (file (file-name-nondirectory file)))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
375 (vc-git-symbolic-commit
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
376 (with-temp-buffer
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
377 (and
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
378 (zerop
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
379 (call-process "git" nil '(t nil) nil "rev-list"
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
380 "-2" rev "--" file))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
381 (goto-char (point-max))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
382 (bolp)
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
383 (zerop (forward-line -1))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
384 (not (bobp))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
385 (buffer-substring-no-properties
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
386 (point)
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
387 (1- (point-max))))))))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
388
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
389 (defun vc-git-next-version (file rev)
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
390 "Git-specific version of `vc-next-version'."
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
391 (let* ((default-directory (file-name-directory
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
392 (expand-file-name file)))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
393 (file (file-name-nondirectory file))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
394 (current-rev
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
395 (with-temp-buffer
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
396 (and
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
397 (zerop
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
398 (call-process "git" nil '(t nil) nil "rev-list"
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
399 "-1" rev "--" file))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
400 (goto-char (point-max))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
401 (bolp)
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
402 (zerop (forward-line -1))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
403 (bobp)
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
404 (buffer-substring-no-properties
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
405 (point)
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
406 (1- (point-max)))))))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
407 (and current-rev
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
408 (vc-git-symbolic-commit
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
409 (with-temp-buffer
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
410 (and
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
411 (zerop
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
412 (call-process "git" nil '(t nil) nil "rev-list"
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
413 "HEAD" "--" file))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
414 (goto-char (point-min))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
415 (search-forward current-rev nil t)
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
416 (zerop (forward-line -1))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
417 (buffer-substring-no-properties
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
418 (point)
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
419 (progn (forward-line 1) (1- (point))))))))))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
420
82066
f599171df164 (vc-git-delete-file, vc-git-rename-file): New functions.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82054
diff changeset
421 (defun vc-git-delete-file (file)
f599171df164 (vc-git-delete-file, vc-git-rename-file): New functions.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82054
diff changeset
422 (vc-git-command nil 0 file "rm" "-f" "--"))
82053
3cc1f1f9df04 (vc-git-checkin): Delete unused parameter and the code
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82052
diff changeset
423
82066
f599171df164 (vc-git-delete-file, vc-git-rename-file): New functions.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82054
diff changeset
424 (defun vc-git-rename-file (old new)
f599171df164 (vc-git-delete-file, vc-git-rename-file): New functions.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82054
diff changeset
425 (vc-git-command nil 0 (list old new) "mv" "-f" "--"))
82053
3cc1f1f9df04 (vc-git-checkin): Delete unused parameter and the code
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82052
diff changeset
426
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
427
82109
12d79fae7504 * vc-git.el (vc-git-log-view-mode): Port to the multi-file vc interface.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82098
diff changeset
428 ;;; Internal commands
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
429
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
430 (defun vc-git-root (file)
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
431 (vc-find-root file ".git"))
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
432
82038
7ee8cfeeb2b8 (vc-git-register, vc-git-checkin): Use vc-git-command,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82032
diff changeset
433 (defun vc-git-command (buffer okstatus file-or-list &rest flags)
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
434 "A wrapper around `vc-do-command' for use in vc-git.el.
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
435 The difference to vc-do-command is that this function always invokes `git'."
82038
7ee8cfeeb2b8 (vc-git-register, vc-git-checkin): Use vc-git-command,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82032
diff changeset
436 (apply 'vc-do-command buffer okstatus "git" file-or-list flags))
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
437
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
438 (defun vc-git--run-command-string (file &rest args)
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
439 "Run a git command on FILE and return its output as string."
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
440 (let* ((ok t)
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
441 (str (with-output-to-string
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
442 (with-current-buffer standard-output
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
443 (unless (eq 0 (apply #'call-process "git" nil '(t nil) nil
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
444 (append args (list (file-relative-name file)))))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
445 (setq ok nil))))))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
446 (and ok str)))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
447
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
448 (defun vc-git-symbolic-commit (commit)
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
449 "Translate COMMIT string into symbolic form.
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
450 Returns nil if not possible."
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
451 (and commit
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
452 (with-temp-buffer
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
453 (and
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
454 (zerop
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
455 (call-process "git" nil '(t nil) nil "name-rev"
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
456 "--name-only" "--tags"
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
457 commit))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
458 (goto-char (point-min))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
459 (= (forward-line 2) 1)
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
460 (bolp)
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
461 (buffer-substring-no-properties (point-min) (1- (point-max)))))))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
462
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
463 (provide 'vc-git)
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
464
82050
6223a0f48040 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 82049
diff changeset
465 ;; arch-tag: bd10664a-0e5b-48f5-a877-6c17b135be12
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
466 ;;; vc-git.el ends here