]> git.eshelyaron.com Git - emacs.git/commitdiff
Allow vc-git-clone to check-out arbitrary revisions
authorPhilip Kaludercic <philipk@posteo.net>
Tue, 27 Feb 2024 09:32:08 +0000 (10:32 +0100)
committerEshel Yaron <me@eshelyaron.com>
Wed, 28 Feb 2024 17:53:31 +0000 (18:53 +0100)
* lisp/vc/vc-git.el (vc-git-clone): If "git clone --branch"
fails, then clone the repository regularly and checkout the
requested revision.

(cherry picked from commit b59d7094b6cb1a09f46f933807e9cd00a8bd1547)

lisp/vc/vc-git.el

index 456417e566e99c98aa3934cafc332b2019004c99..18b4a8691e942c73232687663e8b39ee80cc6618 100644 (file)
@@ -1411,9 +1411,16 @@ This prompts for a branch to merge from."
     (vc-message-unresolved-conflicts buffer-file-name)))
 
 (defun vc-git-clone (remote directory rev)
-  (if rev
-      (vc-git--out-ok "clone" "--branch" rev remote directory)
+  "Attempt to clone REMOTE repository into DIRECTORY at revision REV."
+  (cond
+   ((null rev)
     (vc-git--out-ok "clone" remote directory))
+   ((ignore-errors
+      (vc-git--out-ok "clone" "--branch" rev remote directory)))
+   ((vc-git--out-ok "clone" remote directory)
+    (let ((default-directory directory))
+      (vc-git--out-ok "checkout" rev)))
+   ((error "Failed to check out %s at %s" remote rev)))
   directory)
 
 ;;; HISTORY FUNCTIONS