Commit Diff


commit - 424f5152bad72242de91a2638f286596ec9e5659
commit + 8014bde1e7ea7f7d61b9cbd5907e41413ed7a36f
blob - b9c71b275e017391ed6e836389e1b15f0a9dcf80
blob + f70e0482c9b38f1b2524dea53552da28d8dd5592
--- vc-got.el
+++ vc-got.el
@@ -89,7 +89,9 @@
 ;; - mergebase                          NOT IMPLEMENTED
 ;;
 ;; TAG SYSTEM
-;; - create-tag                         NOT IMPLEMENTED
+;; - create-tag                         PARTIALLY IMPLEMENTED
+;;      figure out how to read a message for the tag; can only create
+;;      branches.
 ;; - retrieve-tag                       NOT IMPLEMENTED
 ;;
 ;; MISCELLANEOUS                        NOT IMPLEMENTED
@@ -389,6 +391,16 @@ files on disk."
           (while (re-search-forward re nil t)
             (push (match-string 2) table))
           table)))))
+
+(defun vc-got--branch (name)
+  "Try to create and switch to the branch called NAME."
+  (let (process-file-side-effects)
+    (vc-got-with-worktree default-directory
+      (with-temp-buffer
+        (if (zerop (vc-got--call "branch" name))
+            t
+          (error "[vc-got] can't create branch %s: %s" name
+                 (buffer-string)))))))
 
 
 ;; Backend properties
@@ -785,6 +797,19 @@ Value is returned as floating point fractional number 
       (match-string-no-properties 1))))
 
 
+;; Tag system
+
+(defun vc-got-create-tag (_dir name branchp)
+  "Attach the tag NAME to the state of the worktree.
+DIR is ignored (tags are global, not per-file).
+If BRANCHP is true, NAME should create a new branch."
+  ;; TODO: vc reccomends to ensure that all the file are in a clean
+  ;; state, but is it useful?
+  (if branchp
+      (vc-got--branch name)
+    (error "[vc-got] create tags is not implemented (yet)")))
+
+
 ;; Miscellaneous
 
 (defun vc-got-previous-revision (file rev)