aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorDmitry Gutov2015-05-18 15:49:13 +0300
committerDmitry Gutov2015-05-18 15:50:57 +0300
commit69d24b40d2ed3cdfa7e79da4c729bddd381c8231 (patch)
treec48c2877459e95f1542663d546ec11682cceec2c /lisp
parentd3d50a9c99ef42a270127fe0f5a9e435eb760079 (diff)
downloademacs-69d24b40d2ed3cdfa7e79da4c729bddd381c8231.tar.gz
emacs-69d24b40d2ed3cdfa7e79da4c729bddd381c8231.zip
Improve handling of the first Git revision
* lisp/vc/log-view.el (log-view-toggle-entry-display): When there's no next entry, delete until the end of the buffer. (log-view-end-of-defun-1): Stop at eob. * lisp/vc/vc-annotate.el (vc-annotate-show-diff-revision-at-line-internal): Don't give up when previous-revision is nil. * lisp/vc/vc-git.el (vc-git-expanded-log-entry): End the arguments with `--' to avoid ambiguity. (vc-git-annotate-extract-revision-at-line): Exclude `^' from the returned revision string. (vc-git-annotate-time): Expect `^' before the first revision. * lisp/vc/vc-git.el (vc-git-diff): Diff against an empty tree if REV1 is nil, and REV2 is not. * lisp/vc/vc.el: Update the description of the `diff' function.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/vc/log-view.el9
-rw-r--r--lisp/vc/vc-annotate.el20
-rw-r--r--lisp/vc/vc-git.el19
-rw-r--r--lisp/vc/vc.el3
4 files changed, 30 insertions, 21 deletions
diff --git a/lisp/vc/log-view.el b/lisp/vc/log-view.el
index 042ea131a97..19bbc45f927 100644
--- a/lisp/vc/log-view.el
+++ b/lisp/vc/log-view.el
@@ -404,7 +404,9 @@ This calls `log-view-expanded-log-entry-function' to do the work."
404 (unless (and pos (log-view-inside-comment-p pos)) 404 (unless (and pos (log-view-inside-comment-p pos))
405 (error "Broken markup in `log-view-toggle-entry-display'")) 405 (error "Broken markup in `log-view-toggle-entry-display'"))
406 (delete-region pos 406 (delete-region pos
407 (next-single-property-change pos 'log-view-comment)) 407 (or
408 (next-single-property-change pos 'log-view-comment)
409 (point-max)))
408 (put-text-property beg (1+ beg) 'log-view-entry-expanded nil) 410 (put-text-property beg (1+ beg) 'log-view-entry-expanded nil)
409 (if (< opoint pos) 411 (if (< opoint pos)
410 (goto-char opoint))) 412 (goto-char opoint)))
@@ -469,7 +471,10 @@ It assumes that a log entry starts with a line matching
469 ((looking-back "Show 2X entries Show unlimited entries" 471 ((looking-back "Show 2X entries Show unlimited entries"
470 (line-beginning-position)) 472 (line-beginning-position))
471 (setq looping nil) 473 (setq looping nil)
472 (forward-line -1)))))) 474 (forward-line -1))
475 ;; There are no buttons if we've turned on unlimited entries.
476 ((eobp)
477 (setq looping nil))))))
473 478
474(defun log-view-end-of-defun (&optional arg) 479(defun log-view-end-of-defun (&optional arg)
475 "Move forward to the next Log View entry. 480 "Move forward to the next Log View entry.
diff --git a/lisp/vc/vc-annotate.el b/lisp/vc/vc-annotate.el
index d369c90915a..3a50c9b6a2d 100644
--- a/lisp/vc/vc-annotate.el
+++ b/lisp/vc/vc-annotate.el
@@ -582,17 +582,15 @@ the file in question, search for the log entry required and move point."
582 (setq prev-rev 582 (setq prev-rev
583 (vc-call-backend vc-annotate-backend 'previous-revision 583 (vc-call-backend vc-annotate-backend 'previous-revision
584 (if filediff fname nil) rev)) 584 (if filediff fname nil) rev))
585 (if (not prev-rev) 585 (vc-diff-internal
586 (message "Cannot diff from any revision prior to %s" rev) 586 t
587 (vc-diff-internal 587 ;; The value passed here should follow what
588 t 588 ;; `vc-deduce-fileset' returns.
589 ;; The value passed here should follow what 589 (list vc-annotate-backend
590 ;; `vc-deduce-fileset' returns. 590 (if filediff
591 (list vc-annotate-backend 591 (list fname)
592 (if filediff 592 nil))
593 (list fname) 593 prev-rev rev)))))
594 nil))
595 prev-rev rev))))))
596 594
597(defun vc-annotate-show-diff-revision-at-line () 595(defun vc-annotate-show-diff-revision-at-line ()
598 "Visit the diff of the revision at line from its previous revision." 596 "Visit the diff of the revision at line from its previous revision."
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index cbf3da3003f..e3cd5d4e3dc 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -960,14 +960,13 @@ or BRANCH^ (where \"^\" can be repeated)."
960 960
961(defun vc-git-expanded-log-entry (revision) 961(defun vc-git-expanded-log-entry (revision)
962 (with-temp-buffer 962 (with-temp-buffer
963 (apply 'vc-git-command t nil nil (list "log" revision "-1")) 963 (apply 'vc-git-command t nil nil (list "log" revision "-1" "--"))
964 (goto-char (point-min)) 964 (goto-char (point-min))
965 (unless (eobp) 965 (unless (eobp)
966 ;; Indent the expanded log entry. 966 ;; Indent the expanded log entry.
967 (indent-region (point-min) (point-max) 2) 967 (indent-region (point-min) (point-max) 2)
968 (buffer-string)))) 968 (buffer-string))))
969 969
970
971(defun vc-git-region-history (file buffer lfrom lto) 970(defun vc-git-region-history (file buffer lfrom lto)
972 (vc-git-command buffer 'async nil "log" "-p" ;"--follow" ;FIXME: not supported? 971 (vc-git-command buffer 'async nil "log" "-p" ;"--follow" ;FIXME: not supported?
973 (format "-L%d,%d:%s" lfrom lto (file-relative-name file)))) 972 (format "-L%d,%d:%s" lfrom lto (file-relative-name file))))
@@ -1019,12 +1018,18 @@ or BRANCH^ (where \"^\" can be repeated)."
1019 1018
1020(defun vc-git-diff (files &optional rev1 rev2 buffer async) 1019(defun vc-git-diff (files &optional rev1 rev2 buffer async)
1021 "Get a difference report using Git between two revisions of FILES." 1020 "Get a difference report using Git between two revisions of FILES."
1022 (let (process-file-side-effects) 1021 (let (process-file-side-effects
1022 (command "diff-tree"))
1023 (if rev2
1024 ;; Diffing against the empty tree.
1025 (unless rev1 (setq rev1 "4b825dc642cb6eb9a060e54bf8d69288fbee4904"))
1026 (setq command "diff-index")
1027 (unless rev1 (setq rev1 "HEAD")))
1023 (if vc-git-diff-switches 1028 (if vc-git-diff-switches
1024 (apply #'vc-git-command (or buffer "*vc-diff*") 1029 (apply #'vc-git-command (or buffer "*vc-diff*")
1025 (if async 'async 1) 1030 (if async 'async 1)
1026 files 1031 files
1027 (if (and rev1 rev2) "diff-tree" "diff-index") 1032 command
1028 "--exit-code" 1033 "--exit-code"
1029 (append (vc-switches 'git 'diff) 1034 (append (vc-switches 'git 'diff)
1030 (list "-p" (or rev1 "HEAD") rev2 "--"))) 1035 (list "-p" (or rev1 "HEAD") rev2 "--")))
@@ -1033,7 +1038,7 @@ or BRANCH^ (where \"^\" can be repeated)."
1033 (concat "diff " 1038 (concat "diff "
1034 (mapconcat 'identity 1039 (mapconcat 'identity
1035 (vc-switches nil 'diff) " ")) 1040 (vc-switches nil 'diff) " "))
1036 (or rev1 "HEAD") rev2 "--")))) 1041 rev1 rev2 "--"))))
1037 1042
1038(defun vc-git-revision-table (_files) 1043(defun vc-git-revision-table (_files)
1039 ;; What about `files'?!? --Stef 1044 ;; What about `files'?!? --Stef
@@ -1061,7 +1066,7 @@ or BRANCH^ (where \"^\" can be repeated)."
1061(declare-function vc-annotate-convert-time "vc-annotate" (&optional time)) 1066(declare-function vc-annotate-convert-time "vc-annotate" (&optional time))
1062 1067
1063(defun vc-git-annotate-time () 1068(defun vc-git-annotate-time ()
1064 (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) 1069 (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)
1065 (vc-annotate-convert-time 1070 (vc-annotate-convert-time
1066 (apply #'encode-time (mapcar (lambda (match) 1071 (apply #'encode-time (mapcar (lambda (match)
1067 (if (match-beginning match) 1072 (if (match-beginning match)
@@ -1072,7 +1077,7 @@ or BRANCH^ (where \"^\" can be repeated)."
1072(defun vc-git-annotate-extract-revision-at-line () 1077(defun vc-git-annotate-extract-revision-at-line ()
1073 (save-excursion 1078 (save-excursion
1074 (beginning-of-line) 1079 (beginning-of-line)
1075 (when (looking-at "\\([0-9a-f^][0-9a-f]+\\) \\(\\([^(]+\\) \\)?") 1080 (when (looking-at "\\^?\\([0-9a-f]+\\) \\(\\([^(]+\\) \\)?")
1076 (let ((revision (match-string-no-properties 1))) 1081 (let ((revision (match-string-no-properties 1)))
1077 (if (match-beginning 2) 1082 (if (match-beginning 2)
1078 (let ((fname (match-string-no-properties 3))) 1083 (let ((fname (match-string-no-properties 3)))
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index d5d0abe6517..1bd04e13430 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -367,7 +367,8 @@
367;; BUFFER is nil. If ASYNC is non-nil, run asynchronously. If REV1 367;; BUFFER is nil. If ASYNC is non-nil, run asynchronously. If REV1
368;; and REV2 are non-nil, report differences from REV1 to REV2. If 368;; and REV2 are non-nil, report differences from REV1 to REV2. If
369;; REV1 is nil, use the working revision (as found in the 369;; REV1 is nil, use the working revision (as found in the
370;; repository) as the older revision; if REV2 is nil, use the 370;; repository) as the older revision if REV2 is nil as well;
371;; otherwise, diff against an empty tree. If REV2 is nil, use the
371;; current working-copy contents as the newer revision. This 372;; current working-copy contents as the newer revision. This
372;; function should pass the value of (vc-switches BACKEND 'diff) to 373;; function should pass the value of (vc-switches BACKEND 'diff) to
373;; the backend command. It should return a status of either 0 (no 374;; the backend command. It should return a status of either 0 (no