annotate lisp/vc-git.el @ 85087:1876f72f31dd

(follow-mode): Don't run hooks twice. Use `when'.
author Juanma Barranquero <lekktu@gmail.com>
date Mon, 08 Oct 2007 16:06:15 +0000
parents 768766d373a7
children 5039706521c9
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
82245
36893fdf92ab Change capitalization of VC backend names for new backends
Miles Bader <miles@gnu.org>
parents: 82183
diff changeset
33 ;; To install: put this file on the load-path and add Git to the list
82029
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 ;;
82245
36893fdf92ab Change capitalization of VC backend names for new backends
Miles Bader <miles@gnu.org>
parents: 82183
diff changeset
37 ;; (add-to-list 'vc-handled-backends 'Git)
82029
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
82843
768766d373a7 * vc-git.el (vc-git-mode-line-string): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82245
diff changeset
60 ;; - mode-line-string (file) OK
82032
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
82843
768766d373a7 * vc-git.el (vc-git-mode-line-string): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82245
diff changeset
211 (defun vc-git-mode-line-string (file)
768766d373a7 * vc-git.el (vc-git-mode-line-string): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82245
diff changeset
212 "Return string for placement into the modeline for FILE."
768766d373a7 * vc-git.el (vc-git-mode-line-string): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82245
diff changeset
213 (let* ((branch (vc-git-workfile-version file))
768766d373a7 * vc-git.el (vc-git-mode-line-string): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82245
diff changeset
214 (def-ml (vc-default-mode-line-string 'Git file))
768766d373a7 * vc-git.el (vc-git-mode-line-string): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82245
diff changeset
215 (help-echo (get-text-property 0 'help-echo def-ml)))
768766d373a7 * vc-git.el (vc-git-mode-line-string): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82245
diff changeset
216 (if (zerop (length branch))
768766d373a7 * vc-git.el (vc-git-mode-line-string): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82245
diff changeset
217 (propertize
768766d373a7 * vc-git.el (vc-git-mode-line-string): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82245
diff changeset
218 (concat def-ml "!")
768766d373a7 * vc-git.el (vc-git-mode-line-string): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82245
diff changeset
219 'help-echo (concat help-echo "\nNo current branch (detached HEAD)"))
768766d373a7 * vc-git.el (vc-git-mode-line-string): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82245
diff changeset
220 (propertize def-ml
768766d373a7 * vc-git.el (vc-git-mode-line-string): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82245
diff changeset
221 'help-echo (concat help-echo "\nCurrent branch: " branch)))))
768766d373a7 * vc-git.el (vc-git-mode-line-string): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82245
diff changeset
222
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
223 (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
224 "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
225 (let ((git-state (vc-state file)))
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
226 (if (eq git-state 'edited)
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
227 "(modified)"
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
228 ;; fall back to the default VC representation
82245
36893fdf92ab Change capitalization of VC backend names for new backends
Miles Bader <miles@gnu.org>
parents: 82183
diff changeset
229 (vc-default-dired-state-info 'Git file))))
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
230
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
231 ;;; STATE-CHANGING FUNCTIONS
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
232
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
233 (defun vc-git-create-repo ()
82245
36893fdf92ab Change capitalization of VC backend names for new backends
Miles Bader <miles@gnu.org>
parents: 82183
diff changeset
234 "Create a new Git repository."
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
235 (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
236
82038
7ee8cfeeb2b8 (vc-git-register, vc-git-checkin): Use vc-git-command,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82032
diff changeset
237 (defun vc-git-register (files &optional rev comment)
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
238 "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
239 (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
240
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
241 (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
242
82068
cbb38ceb3177 (vc-git-unregister): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82066
diff changeset
243 (defun vc-git-unregister (file)
cbb38ceb3177 (vc-git-unregister): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82066
diff changeset
244 (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
245
82068
cbb38ceb3177 (vc-git-unregister): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82066
diff changeset
246
82038
7ee8cfeeb2b8 (vc-git-register, vc-git-checkin): Use vc-git-command,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82032
diff changeset
247 (defun vc-git-checkin (files rev comment)
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
248 (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
249 (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
250
82053
3cc1f1f9df04 (vc-git-checkin): Delete unused parameter and the code
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82052
diff changeset
251 (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
252 (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
253 (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
254 (fullname (substring
82144
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
255 (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
256 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
257 0 -1)))
82144
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
258 (vc-git-command
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
259 buffer 0
82066
f599171df164 (vc-git-delete-file, vc-git-rename-file): New functions.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82054
diff changeset
260 (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
261
3cc1f1f9df04 (vc-git-checkin): Delete unused parameter and the code
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82052
diff changeset
262 (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
263 (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
264
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
265 (defun vc-git-revert (file &optional contents-done)
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
266 "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
267 (if contents-done
82053
3cc1f1f9df04 (vc-git-checkin): Delete unused parameter and the code
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82052
diff changeset
268 (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
269 (vc-git-command nil 0 file "checkout" "HEAD")))
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
270
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
271 ;;; HISTORY FUNCTIONS
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
272
82038
7ee8cfeeb2b8 (vc-git-register, vc-git-checkin): Use vc-git-command,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82032
diff changeset
273 (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
274 "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
275 (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
276 ;; 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
277 ;; 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
278 (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
279 ;; `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
280 ;; the command.
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
281 (vc-setup-buffer buffer)
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
282 ;; 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
283 ;; read-only.
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
284 (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
285 ;; 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
286 ;; 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
287 ;; 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
288 ;; "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
289 ;; 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
290 ;; 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
291 (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
292 (with-current-buffer
eabeaae7370e vc-git.el (vc-git-print-log): Fix previous change.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82091
diff changeset
293 buffer
eabeaae7370e vc-git.el (vc-git-print-log): Fix previous change.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82091
diff changeset
294 (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
295 (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
296 "rev-list" "--pretty" "HEAD" "--")))))
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
297
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
298 (defvar log-view-message-re)
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
299 (defvar log-view-file-re)
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
300 (defvar log-view-font-lock-keywords)
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
301
82245
36893fdf92ab Change capitalization of VC backend names for new backends
Miles Bader <miles@gnu.org>
parents: 82183
diff changeset
302 (define-derived-mode vc-git-log-view-mode log-view-mode "Git-Log-View"
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
303 (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
304 ;; 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
305 (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
306 (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
307 "^commit *\\([0-9a-z]+\\)")
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
308 (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
309 (append
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
310 `((,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
311 (,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
312 ;; Handle the case:
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
313 ;; user: foo@bar
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
314 '(("^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
315 (1 'change-log-email))
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
316 ;; Handle the case:
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
317 ;; user: FirstName LastName <foo@bar>
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
318 ("^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
319 (1 'change-log-name)
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
320 (2 'change-log-email))
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
321 ("^Date: \\(.+\\)" (1 'change-log-date))
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
322 ("^summary:[ \t]+\\(.+\\)" (1 'log-view-message))))))
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
323
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
324 (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
325 (let ((buf (or buffer "*vc-diff*")))
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
326 (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
327 (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
328 (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
329
82144
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
330 (defun vc-git-revision-table (file)
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
331 (let ((table (list "HEAD")))
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
332 (with-temp-buffer
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
333 (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
334 (goto-char (point-min))
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
335 (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
336 (push (match-string 2) table)))
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
337 table))
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
338
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
339 (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
340 (lexical-let ((file file)
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
341 table)
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
342 (setq table (lazy-completion-table
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
343 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
344 table))
d334990fbd70 vc-git.el (vc-git-revision-table)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82110
diff changeset
345
82053
3cc1f1f9df04 (vc-git-checkin): Delete unused parameter and the code
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82052
diff changeset
346 (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
347 (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
348
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
349 (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
350 ;; FIXME: rev is ignored
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
351 (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
352 (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
353
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
354 (defun vc-git-annotate-time ()
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
355 (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
356 (vc-annotate-convert-time
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
357 (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
358
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
359 (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
360 (save-excursion
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
361 (move-beginning-of-line 1)
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
362 (and (looking-at "[0-9a-f]+")
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
363 (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
364
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
365 ;;; 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
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 (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
368 (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
369 (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
370 (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
371 (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
372 (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
373
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
374 (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
375 (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
376 (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
377 ;; 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
378 ))
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
379
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
380
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
381 ;;; MISCELLANEOUS
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
382
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
383 (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
384 "Git-specific version of `vc-previous-version'."
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
385 (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
386 (file (file-name-nondirectory file)))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
387 (vc-git-symbolic-commit
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
388 (with-temp-buffer
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
389 (and
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
390 (zerop
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
391 (call-process "git" nil '(t nil) nil "rev-list"
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
392 "-2" rev "--" file))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
393 (goto-char (point-max))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
394 (bolp)
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
395 (zerop (forward-line -1))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
396 (not (bobp))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
397 (buffer-substring-no-properties
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
398 (point)
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
399 (1- (point-max))))))))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
400
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
401 (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
402 "Git-specific version of `vc-next-version'."
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
403 (let* ((default-directory (file-name-directory
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
404 (expand-file-name file)))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
405 (file (file-name-nondirectory file))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
406 (current-rev
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
407 (with-temp-buffer
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
408 (and
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
409 (zerop
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
410 (call-process "git" nil '(t nil) nil "rev-list"
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
411 "-1" rev "--" file))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
412 (goto-char (point-max))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
413 (bolp)
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
414 (zerop (forward-line -1))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
415 (bobp)
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
416 (buffer-substring-no-properties
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
417 (point)
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
418 (1- (point-max)))))))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
419 (and current-rev
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
420 (vc-git-symbolic-commit
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
421 (with-temp-buffer
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
422 (and
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
423 (zerop
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
424 (call-process "git" nil '(t nil) nil "rev-list"
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
425 "HEAD" "--" file))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
426 (goto-char (point-min))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
427 (search-forward current-rev nil t)
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
428 (zerop (forward-line -1))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
429 (buffer-substring-no-properties
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
430 (point)
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
431 (progn (forward-line 1) (1- (point))))))))))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
432
82066
f599171df164 (vc-git-delete-file, vc-git-rename-file): New functions.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82054
diff changeset
433 (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
434 (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
435
82066
f599171df164 (vc-git-delete-file, vc-git-rename-file): New functions.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82054
diff changeset
436 (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
437 (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
438
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
439
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
440 ;;; Internal commands
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
441
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
442 (defun vc-git-root (file)
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
443 (vc-find-root file ".git"))
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
444
82038
7ee8cfeeb2b8 (vc-git-register, vc-git-checkin): Use vc-git-command,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82032
diff changeset
445 (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
446 "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
447 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
448 (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
449
82029
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
450 (defun vc-git--run-command-string (file &rest args)
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
451 "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
452 (let* ((ok t)
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
453 (str (with-output-to-string
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
454 (with-current-buffer standard-output
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
455 (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
456 (append args (list (file-relative-name file)))))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
457 (setq ok nil))))))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
458 (and ok str)))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
459
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
460 (defun vc-git-symbolic-commit (commit)
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
461 "Translate COMMIT string into symbolic form.
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
462 Returns nil if not possible."
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
463 (and commit
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
464 (with-temp-buffer
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
465 (and
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
466 (zerop
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
467 (call-process "git" nil '(t nil) nil "name-rev"
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
468 "--name-only" "--tags"
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
469 commit))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
470 (goto-char (point-min))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
471 (= (forward-line 2) 1)
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
472 (bolp)
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
473 (buffer-substring-no-properties (point-min) (1- (point-max)))))))
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
474
57917570b513 vc-git.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
475 (provide 'vc-git)
82032
7d7ee463e4e9 (vc-git-revision-granularity,vc-git-root),
Dan Nicolaescu <dann@ics.uci.edu>
parents: 82029
diff changeset
476
82050
6223a0f48040 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 82049
diff changeset
477 ;; 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
478 ;;; vc-git.el ends here