commit - 489c6310a6f64bc73ea3eeda5dc9a96ad8bf5043
commit + 9b53f629f36d3301a0c9e41df4b5110d5ab61d9b
blob - 1c5aef4099c14a998dea30f500beabf642af6879
blob + 6f1b28ea6b78638cc4e6384ab69565a1baca162b
--- vc-got.el
+++ vc-got.el
"Add FILES to got, passing `vc-register-switches' to the command invocation."
(with-temp-buffer
(vc-got--call "add" vc-register-switches "--" files)))
+
+(defun vc-got--info (path)
+ "Execute got info in the worktree of PATH in the current buffer."
+ (let* ((process-file-side-effects nil))
+ (vc-got-with-worktree path
+ (zerop (save-excursion
+ (vc-got--call "info" "--" path))))))
(defun vc-got--log (&optional path limit start-commit stop-commit
search-pattern reverse include-diff)
(defun vc-got-working-revision (file)
"Return the last commit that touched FILE or \"0\" if it's newly added."
- (or
- (with-temp-buffer
- (when (vc-got--log file 1)
- (let (start)
- (goto-char (point-min))
- (forward-word) ; skip "commit"
- (forward-char) ; skip the space
- (setq start (point)) ; store start of the SHA
- (forward-word) ; goto SHA end
- (buffer-substring start (point)))))
- ;; special case: if this file is added but has no previous commits
- ;; touching it, got log will fail (as expected), but we have to
- ;; return "0".
- (when (eq (vc-got-state file) 'added)
- "0")))
+ (with-temp-buffer
+ (when (vc-got--info file)
+ (let ((pos (re-search-forward "^based on commit: " nil t)))
+ (if pos
+ (buffer-substring-no-properties pos (line-end-position))
+ "0")))))
(defun vc-got-checkout-model (_files)
"Return the checkout model.