Commit Diff


commit - e9a5df0576d660dfc5d1d3e6bbb45406654e7dde
commit + 5fb2f47455079158990731f00c405d0fa88788a6
blob - 92b9a8ce21c4aba9e220cf725ed790cd5f299db9
blob + 64c938c066f8aca7aa53d002963fdc36f69a8fb5
--- vc-got.el
+++ vc-got.el
@@ -78,7 +78,7 @@
 ;; - comment-history                    NOT IMPLEMENTED
 ;; - update-changelog                   NOT IMPLEMENTED
 ;; * diff                               DONE
-;; - revision-completion-table          NOT IMPLEMENTED
+;; - revision-completion-table          DONE
 ;; - annotate-command                   DONE
 ;; - annotate-time                      DONE
 ;; - annotate-current-time              NOT IMPLEMENTED
@@ -374,6 +374,21 @@ files on disk."
                            (when keep-local "-k")
                            file)))))
 
+(defun vc-got--ref ()
+  "Return a list of all references."
+  (let (process-file-side-effects
+        (re "^refs/\\(heads\\|remotes\\|tags\\)/\\(.*\\):")
+        ;; hardcoding HEAD because it's always present and the regexp
+        ;; won't match it.
+        (table (list "HEAD")))
+    (vc-got-with-worktree default-directory
+      (with-temp-buffer
+        (when (zerop (vc-got--call "ref" "-l"))
+          (goto-char (point-min))
+          (while (re-search-forward re nil t)
+            (push (match-string 2) table))
+          table)))))
+
 
 ;; Backend properties
 
@@ -707,6 +722,14 @@ Heavily inspired by `vc-git-log-view-mode'."
           ;; TODO: if rev2 is nil as well, diff against an empty tree
           ;; (i.e. get the patch from `got log -p rev1')
           (vc-got--diff rev1 rev2))))))
+
+(defun vc-got-revision-completion-table (_files)
+  "Return a completion table for existing revisions.
+Ignores FILES because GoT doesn't have the concept of ``file
+revisions''; instead, like with git, you have tags and branches."
+  (letrec ((table (lazy-completion-table
+                   table (lambda () (vc-got--ref)))))
+    table))
 
 (defun vc-got-annotate-command (file buf &optional rev)
   "Show annotated contents of FILE in buffer BUF.  If given, use revision REV."