aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/vc/vc.el20
1 files changed, 11 insertions, 9 deletions
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index 132278e8230..c5584188b31 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -1460,20 +1460,22 @@ Argument BACKEND is the backend you are using."
1460;; Subroutine for `vc-git-ignore' and `vc-hg-ignore'. 1460;; Subroutine for `vc-git-ignore' and `vc-hg-ignore'.
1461(defun vc--add-line (string file) 1461(defun vc--add-line (string file)
1462 "Add STRING as a line to FILE." 1462 "Add STRING as a line to FILE."
1463 (with-temp-buffer 1463 (with-current-buffer (find-file-noselect file)
1464 (insert-file-contents file) 1464 (goto-char (point-min))
1465 (unless (re-search-forward (concat "^" (regexp-quote string) "$") nil t) 1465 (unless (re-search-forward (concat "^" (regexp-quote string) "$") nil t)
1466 (goto-char (point-max)) 1466 (goto-char (point-max))
1467 (insert (concat "\n" string)) 1467 (unless (bolp) (insert "\n"))
1468 (write-region (point-min) (point-max) file)))) 1468 (insert string "\n")
1469 (save-buffer))))
1469 1470
1470(defun vc--remove-regexp (regexp file) 1471(defun vc--remove-regexp (regexp file)
1471 "Remove all matching for REGEXP in FILE." 1472 "Remove all matching for REGEXP in FILE."
1472 (with-temp-buffer 1473 (if (file-exists-p file)
1473 (insert-file-contents file) 1474 (with-current-buffer (find-file-noselect file)
1474 (while (re-search-forward regexp nil t) 1475 (goto-char (point-min))
1475 (replace-match "")) 1476 (while (re-search-forward regexp nil t)
1476 (write-region (point-min) (point-max) file))) 1477 (replace-match ""))
1478 (save-buffer))))
1477 1479
1478(defun vc-checkout (file &optional rev) 1480(defun vc-checkout (file &optional rev)
1479 "Retrieve a copy of the revision REV of FILE. 1481 "Retrieve a copy of the revision REV of FILE.