annotate lisp/vc-git.el @ 82144:d334990fbd70

vc-git.el (vc-git-revision-table) (vc-git-revision-completion-table): New functions.
author Dan Nicolaescu <dann@ics.uci.edu>
date Thu, 26 Jul 2007 17:26:08 +0000
parents b9d2156e3f5d
children f04985ac29f2
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
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
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 ;; XXX when this backend is considered sufficiently reliable this
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
118 ;; should be moved to vc-hooks.el
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
119 (add-to-list 'vc-handled-backends 'GIT)
82049
323f551584a7 (vc-directory-exclusion-list): Use eval-after-load.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82047
diff changeset
120 (eval-after-load "vc"
82091
535e5fa4eca9 vc-git.el (vc-git-checkout, vc-directory-exclusion-list): Fix
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82068
diff changeset
121 '(add-to-list 'vc-directory-exclusion-list ".git" t))
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
122
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
123 ;;; BACKEND PROPERTIES
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
124
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
125 (defun vc-git-revision-granularity ()
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
126 'repository)
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
127
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
128 ;;; STATE-QUERYING FUNCTIONS
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
129
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
130 ;;;###autoload (defun vc-git-registered (file)
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
131 ;;;###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
132 ;;;###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
133 ;;;###autoload (progn
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
134 ;;;###autoload (load "vc-git")
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
135 ;;;###autoload (vc-git-registered file))))
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
136
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
137 (defun vc-git-registered (file)
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
138 "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
139 (when (vc-git-root file)
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
140 (with-temp-buffer
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
141 (let* ((dir (file-name-directory file))
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
142 (name (file-relative-name file dir)))
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
143 (and (ignore-errors
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
144 (when dir (cd dir))
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
145 (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
146 (let ((str (buffer-string)))
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
147 (and (> (length str) (length name))
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
148 (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
149
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
150 (defun vc-git-state (file)
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
151 "Git-specific version of `vc-state'."
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
152 (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
153 (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
154 'edited
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
155 'up-to-date)))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
156
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
157 (defun vc-git-dir-state (dir)
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
158 (with-temp-buffer
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
159 (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
160 (goto-char (point-min))
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
161 (let ((status-char nil)
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
162 (file nil))
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
163 (while (not (eobp))
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
164 (setq status-char (char-after))
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
165 (setq file
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
166 (expand-file-name
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
167 (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
168 (cond
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
169 ;; 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
170 ;; R removed/deleted
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
171 ;; K to be killed
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
172 ;; 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
173 ;; here.
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
174 ((eq status-char ?H)
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
175 (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
176 ((eq status-char ?M)
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
177 (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
178 ((eq status-char ?C)
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
179 (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
180 ((eq status-char ??)
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
181 (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
182 (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
183 (forward-line)))))
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
184
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
185 (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
186 "Git-specific version of `vc-workfile-version'."
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
187 (let ((str (with-output-to-string
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
188 (with-current-buffer standard-output
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
189 (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
190 (if (string-match "^\\(refs/heads/\\)?\\(.+\\)$" str)
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
191 (match-string 2 str)
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
192 str)))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
193
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
194 (defun vc-git-checkout-model (file)
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
195 'implicit)
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
196
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
197 (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
198 ;; 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
199 ;; 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
200 ;; 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
201 ;; 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
202 ;; 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
203
82052
1776413f26d4 (vc-git-workfile-unchanged-p): Update comment.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82050
diff changeset
204 ;; 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
205 ;; 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
206 ;; back to its original state.
1776413f26d4 (vc-git-workfile-unchanged-p): Update comment.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82050
diff changeset
207
1776413f26d4 (vc-git-workfile-unchanged-p): Update comment.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82050
diff changeset
208 ;; 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
209 ;; 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
210 ;; 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
211 (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
212 (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
213 (and head
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
214 (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
215 (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
216
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
217 (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
218 "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
219 (let ((git-state (vc-state file)))
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
220 (if (eq git-state 'edited)
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
221 "(modified)"
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
222 ;; 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
223 (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
224
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
225 ;;; STATE-CHANGING FUNCTIONS
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
226
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
227 (defun vc-git-create-repo ()
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
228 "Create a new GIT repository."
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
229 (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
230
82038
7ee8cfeeb2b8 (vc-git-register, vc-git-checkin): Use vc-git-command,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82032
diff changeset
231 (defun vc-git-register (files &optional rev comment)
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
232 "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
233 (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
234
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
235 (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
236
82068
cbb38ceb3177 (vc-git-unregister): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82066
diff changeset
237 (defun vc-git-unregister (file)
cbb38ceb3177 (vc-git-unregister): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82066
diff changeset
238 (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
239
82068
cbb38ceb3177 (vc-git-unregister): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82066
diff changeset
240
82038
7ee8cfeeb2b8 (vc-git-register, vc-git-checkin): Use vc-git-command,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82032
diff changeset
241 (defun vc-git-checkin (files rev comment)
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
242 (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
243 (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
244
82053
3cc1f1f9df04 (vc-git-checkin): Delete unused parameter and the code
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82052
diff changeset
245 (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
246 (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
247 (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
248 (fullname (substring
82144
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
249 (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
250 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
251 0 -1)))
82144
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
252 (vc-git-command
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
253 buffer 0
82066
f599171df164 (vc-git-delete-file, vc-git-rename-file): New functions.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82054
diff changeset
254 (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
255
3cc1f1f9df04 (vc-git-checkin): Delete unused parameter and the code
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82052
diff changeset
256 (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
257 (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
258
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
259 (defun vc-git-revert (file &optional contents-done)
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
260 "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
261 (if contents-done
82053
3cc1f1f9df04 (vc-git-checkin): Delete unused parameter and the code
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82052
diff changeset
262 (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
263 (vc-git-command nil 0 file "checkout" "HEAD")))
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
264
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
265 ;;; HISTORY FUNCTIONS
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
266
82038
7ee8cfeeb2b8 (vc-git-register, vc-git-checkin): Use vc-git-command,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82032
diff changeset
267 (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
268 "Get change log associated with FILES."
82098
eabeaae7370e vc-git.el (vc-git-print-log): Fix previous change.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82091
diff changeset
269 (let ((coding-system-for-read git-commits-coding-system))
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
270 ;; `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
271 ;; the command.
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
272 (vc-setup-buffer buffer)
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
273 ;; 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
274 ;; read-only.
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
275 (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
276 ;; 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
277 ;; 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
278 ;; 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
279 ;; "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
280 ;; 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
281 ;; log. Maybe there is a way to do this with one command...
eabeaae7370e vc-git.el (vc-git-print-log): Fix previous change.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82091
diff changeset
282 (dolist (file files)
eabeaae7370e vc-git.el (vc-git-print-log): Fix previous change.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82091
diff changeset
283 (with-current-buffer
eabeaae7370e vc-git.el (vc-git-print-log): Fix previous change.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82091
diff changeset
284 buffer
eabeaae7370e vc-git.el (vc-git-print-log): Fix previous change.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82091
diff changeset
285 (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
286 (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
287 "rev-list" "--pretty" "HEAD" "--")))))
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
288
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
289 (defvar log-view-message-re)
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
290 (defvar log-view-file-re)
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
291 (defvar log-view-font-lock-keywords)
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
292
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
293 (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
294 (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
295 ;; 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
296 (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
297 (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
298 "^commit *\\([0-9a-z]+\\)")
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
299 (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
300 (append
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
301 `((,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
302 (,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
303 ;; Handle the case:
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
304 ;; user: foo@bar
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
305 '(("^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
306 (1 'change-log-email))
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
307 ;; Handle the case:
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
308 ;; user: FirstName LastName <foo@bar>
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
309 ("^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
310 (1 'change-log-name)
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
311 (2 'change-log-email))
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
312 ("^Date: \\(.+\\)" (1 'change-log-date))
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
313 ("^summary:[ \t]+\\(.+\\)" (1 'log-view-message))))))
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
314
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 (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
316 (let ((buf (or buffer "*vc-diff*")))
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
317 (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
318 (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
319 (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
320
82144
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
321 (defun vc-git-revision-table (file)
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
322 (let ((table (list "HEAD")))
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
323 (with-temp-buffer
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
324 (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
325 (goto-char (point-min))
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
326 (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
327 (push (match-string 2) table)))
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
328 table))
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
329
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
330 (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
331 (lexical-let ((file 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 (setq table (lazy-completion-table
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
334 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
335 table))
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
336
82053
3cc1f1f9df04 (vc-git-checkin): Delete unused parameter and the code
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82052
diff changeset
337 (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
338 (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
339
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
340 (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
341 ;; FIXME: rev is ignored
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
342 (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
343 (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
344
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
345 (defun vc-git-annotate-time ()
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
346 (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
347 (vc-annotate-convert-time
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
348 (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
349
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
350 (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
351 (save-excursion
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
352 (move-beginning-of-line 1)
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
353 (and (looking-at "[0-9a-f]+")
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
354 (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
355
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
356 ;;; 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
357
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 (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
359 (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
360 (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
361 (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
362 (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
363 (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
364
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 (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
366 (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
367 (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
368 ;; 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
369 ))
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
370
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
371
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
372 ;;; MISCELLANEOUS
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
373
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
374 (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
375 "Git-specific version of `vc-previous-version'."
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
376 (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
377 (file (file-name-nondirectory file)))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
378 (vc-git-symbolic-commit
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
379 (with-temp-buffer
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
380 (and
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
381 (zerop
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
382 (call-process "git" nil '(t nil) nil "rev-list"
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
383 "-2" rev "--" file))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
384 (goto-char (point-max))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
385 (bolp)
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
386 (zerop (forward-line -1))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
387 (not (bobp))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
388 (buffer-substring-no-properties
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
389 (point)
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
390 (1- (point-max))))))))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
391
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
392 (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
393 "Git-specific version of `vc-next-version'."
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
394 (let* ((default-directory (file-name-directory
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
395 (expand-file-name file)))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
396 (file (file-name-nondirectory file))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
397 (current-rev
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
398 (with-temp-buffer
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
399 (and
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
400 (zerop
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
401 (call-process "git" nil '(t nil) nil "rev-list"
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
402 "-1" rev "--" file))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
403 (goto-char (point-max))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
404 (bolp)
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
405 (zerop (forward-line -1))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
406 (bobp)
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
407 (buffer-substring-no-properties
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
408 (point)
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
409 (1- (point-max)))))))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
410 (and current-rev
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
411 (vc-git-symbolic-commit
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
412 (with-temp-buffer
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
413 (and
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
414 (zerop
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
415 (call-process "git" nil '(t nil) nil "rev-list"
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
416 "HEAD" "--" file))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
417 (goto-char (point-min))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
418 (search-forward current-rev nil t)
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
419 (zerop (forward-line -1))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
420 (buffer-substring-no-properties
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
421 (point)
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
422 (progn (forward-line 1) (1- (point))))))))))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
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-delete-file (file)
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 file "rm" "-f" "--"))
82053
3cc1f1f9df04 (vc-git-checkin): Delete unused parameter and the code
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82052
diff changeset
426
82066
f599171df164 (vc-git-delete-file, vc-git-rename-file): New functions.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82054
diff changeset
427 (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
428 (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
429
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
430
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
431 ;;; Internal commands
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
432
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
433 (defun vc-git-root (file)
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
434 (vc-find-root file ".git"))
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
435
82038
7ee8cfeeb2b8 (vc-git-register, vc-git-checkin): Use vc-git-command,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82032
diff changeset
436 (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
437 "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
438 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
439 (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
440
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
441 (defun vc-git--run-command-string (file &rest args)
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
442 "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
443 (let* ((ok t)
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
444 (str (with-output-to-string
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
445 (with-current-buffer standard-output
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
446 (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
447 (append args (list (file-relative-name file)))))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
448 (setq ok nil))))))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
449 (and ok str)))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
450
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
451 (defun vc-git-symbolic-commit (commit)
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
452 "Translate COMMIT string into symbolic form.
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
453 Returns nil if not possible."
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
454 (and commit
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
455 (with-temp-buffer
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
456 (and
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
457 (zerop
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
458 (call-process "git" nil '(t nil) nil "name-rev"
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
459 "--name-only" "--tags"
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
460 commit))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
461 (goto-char (point-min))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
462 (= (forward-line 2) 1)
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
463 (bolp)
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
464 (buffer-substring-no-properties (point-min) (1- (point-max)))))))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
465
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
466 (provide 'vc-git)
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
467
82050
6223a0f48040 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 82049
diff changeset
468 ;; 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
469 ;;; vc-git.el ends here