emacs-diffs
[Top][All Lists]
Advanced

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

master b59d7094b6c: Allow vc-git-clone to check-out arbitrary revisions


From: Philip Kaludercic
Subject: master b59d7094b6c: Allow vc-git-clone to check-out arbitrary revisions
Date: Tue, 27 Feb 2024 04:33:14 -0500 (EST)

branch: master
commit b59d7094b6cb1a09f46f933807e9cd00a8bd1547
Author: Philip Kaludercic <philipk@posteo.net>
Commit: Philip Kaludercic <philipk@posteo.net>

    Allow vc-git-clone to check-out arbitrary revisions
    
    * lisp/vc/vc-git.el (vc-git-clone): If "git clone --branch"
    fails, then clone the repository regularly and checkout the
    requested revision.
---
 lisp/vc/vc-git.el | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index 456417e566e..18b4a8691e9 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -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



reply via email to

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