help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Unable to a new branch with VC commit


From: Robert Pluim
Subject: Re: Unable to a new branch with VC commit
Date: Fri, 12 Mar 2021 16:14:53 +0100

>>>>> On Fri, 12 Mar 2021 15:21:12 +0100, Robert Pluim <rpluim@gmail.com> said:

>>>>> On Fri, 12 Mar 2021 14:39:05 +0200, Eli Zaretskii <eliz@gnu.org> said:
    >>> From: Robert Pluim <rpluim@gmail.com>
    >>> Date: Fri, 12 Mar 2021 10:50:10 +0100
    >>> Cc: help-gnu-emacs@gnu.org
    >>> 
    >>> Neither git nor Mercurial fall under the "On centralized version
    >>> control systems" clause of the 'Creating New Branches'
    >>> documentation.

    Eli> Is there any good reason why "C-u C-x v v" won't work for a dVCS?
    Eli> There's an advantage in keeping the UI consistent as much as
    Eli> reasonably practical, even though the two VCS types are very
    Eli> different.

    Robert> I donʼt see why it shouldn't. Someone just needs to add the right
    Robert> incantations to vc-git-checkin and vc-hg-checkin (and maybe
    Robert> vc-bazaar-checkin), and deprecate the vc-create-tag branch-creating
    Robert> usage.

Something like this untested patch for vc-git. Tero, does this work
for you?

diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index 465ed8735c..287512c255 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -915,7 +915,7 @@ vc-git-log-edit-mode
   "Major mode for editing Git log messages.
 It is based on `log-edit-mode', and has Git-specific extensions.")
 
-(defun vc-git-checkin (files comment &optional _rev)
+(defun vc-git-checkin (files comment &optional rev)
   (let* ((file1 (or (car files) default-directory))
          (root (vc-git-root file1))
          (default-directory (expand-file-name root))
@@ -937,6 +937,10 @@ vc-git-checkin
           (if (eq system-type 'windows-nt)
               (let ((default-directory (file-name-directory file1)))
                 (make-nearby-temp-file "git-msg")))))
+    ;; When specified 'rev' is a branch name to create.
+    (when rev
+      (vc-git-command nil 0 nil "update-index" "--refresh")
+      (vc-git-command nil 0 nil "checkout" "-b" rev))
     (cl-flet ((boolean-arg-fn
                (argument)
                (lambda (value) (when (equal value "yes") (list argument)))))

Robert
-- 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]